Skip to content

Commit 98438e1

Browse files
committed
update
1 parent 725361e commit 98438e1

File tree

5 files changed

+73
-74
lines changed

5 files changed

+73
-74
lines changed

README.md

+16
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,22 @@
1919
- 需要借助`BoxJs`,不知道的同学,到这里就可以放弃了。
2020
- 需要借助[@senku](https://github.com/chavyleung/scripts/blob/master/follow/follow.js)佬脚本使用的账号数据,这里不知道的同学,也可以放弃了。
2121

22+
### 更新日志
23+
24+
#### 1.0.1
25+
- 同步@Honye的脚本更新
26+
- 优化代码
27+
28+
#### 1.0.0
29+
- 发布
30+
31+
### 预览
32+
![follow小组件](https://image.bmqy.net/upload/IMG_3807.jpeg)
33+
![follow小组件](https://image.bmqy.net/upload/IMG_3808.jpeg)
34+
![follow小组件](https://image.bmqy.net/upload/IMG_3804.jpeg)
35+
![follow小组件](https://image.bmqy.net/upload/IMG_3805.jpeg)
36+
37+
2238
## 特别鸣谢
2339
- [Honye](https://github.com/Honye/scriptable-scripts)
2440
- [dompling](https://github.com/dompling/Scriptable)

src/follow.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
if (typeof require === 'undefined') require = importModule
22
const { withSettings, writeSettings } = require('./withSettings.module')
33
const { i18n, useCache, timeOffset } = require('./utils.module')
4-
const { httpRequest, getBoxJsData, renderHeader, renderNone, getRefreshTime, reopenScript } = require('./tools.module')
4+
const { httpRequest, getBoxJsData, renderHeader, renderNone, getRefreshTime } = require('./tools.module')
55

66
const preference = {
77
name: 'Follow',
@@ -293,7 +293,6 @@ const setColorRecommend = () => {
293293
preference.colorDark = colorRecommend.color
294294
preference.backgroundColorDark = colorRecommend.backgroundColor
295295
writeSettings(preference, { useICloud: preference.useICloud })
296-
reopenScript()
297296
}
298297

299298
await withSettings({

src/follow.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"version": "1.0.0",
2+
"version": "1.0.1",
33
"setting": {
44
"icon-glyph": "rss-square",
55
"icon-color": "red"

src/tools.module.js

+3-36
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const { useCache } = importModule('utils.module')
1+
const { useCache, hashCode } = importModule('utils.module')
22
const cache = useCache()
33
const ScriptName = Script.name()
44

@@ -10,35 +10,6 @@ SFSymbol.named = (str) => {
1010
}
1111
return current
1212
}
13-
14-
/**
15-
* base64 编码字符串
16-
* @param {string} str 要编码的字符串
17-
*/
18-
const base64Encode = (str) => {
19-
const data = Data.fromString(str)
20-
return data.toBase64String()
21-
}
22-
/**
23-
* base64解码数据 返回字符串
24-
* @param {string} b64 base64编码的数据
25-
*/
26-
const base64Decode = (b64) => {
27-
const data = Data.fromBase64String(b64)
28-
return data.toRawString()
29-
}
30-
/**
31-
* md5 加密字符串
32-
* @param {string} str 要加密成md5的数据
33-
*/
34-
// prettier-ignore
35-
// eslint-disable-next-line
36-
const md5 = (str)=>{function d(n,t){var r=(65535&n)+(65535&t);return(((n>>16)+(t>>16)+(r>>16))<<16)|(65535&r)}function f(n,t,r,e,o,u){return d(((c=d(d(t,n),d(e,u)))<<(f=o))|(c>>>(32-f)),r);var c,f}function l(n,t,r,e,o,u,c){return f((t&r)|(~t&e),n,t,o,u,c)}function v(n,t,r,e,o,u,c){return f((t&e)|(r&~e),n,t,o,u,c)}function g(n,t,r,e,o,u,c){return f(t^r^e,n,t,o,u,c)}function m(n,t,r,e,o,u,c){return f(r^(t|~e),n,t,o,u,c)}function i(n,t){var r,e,o,u;(n[t>>5]|=128<<t%32),(n[14+(((t+64)>>>9)<<4)]=t);for(var c=1732584193,f=-271733879,i=-1732584194,a=271733878,h=0;h<n.length;h+=16)(c=l((r=c),(e=f),(o=i),(u=a),n[h],7,-680876936)),(a=l(a,c,f,i,n[h+1],12,-389564586)),(i=l(i,a,c,f,n[h+2],17,606105819)),(f=l(f,i,a,c,n[h+3],22,-1044525330)),(c=l(c,f,i,a,n[h+4],7,-176418897)),(a=l(a,c,f,i,n[h+5],12,1200080426)),(i=l(i,a,c,f,n[h+6],17,-1473231341)),(f=l(f,i,a,c,n[h+7],22,-45705983)),(c=l(c,f,i,a,n[h+8],7,1770035416)),(a=l(a,c,f,i,n[h+9],12,-1958414417)),(i=l(i,a,c,f,n[h+10],17,-42063)),(f=l(f,i,a,c,n[h+11],22,-1990404162)),(c=l(c,f,i,a,n[h+12],7,1804603682)),(a=l(a,c,f,i,n[h+13],12,-40341101)),(i=l(i,a,c,f,n[h+14],17,-1502002290)),(c=v(c,(f=l(f,i,a,c,n[h+15],22,1236535329)),i,a,n[h+1],5,-165796510,)),(a=v(a,c,f,i,n[h+6],9,-1069501632)),(i=v(i,a,c,f,n[h+11],14,643717713)),(f=v(f,i,a,c,n[h],20,-373897302)),(c=v(c,f,i,a,n[h+5],5,-701558691)),(a=v(a,c,f,i,n[h+10],9,38016083)),(i=v(i,a,c,f,n[h+15],14,-660478335)),(f=v(f,i,a,c,n[h+4],20,-405537848)),(c=v(c,f,i,a,n[h+9],5,568446438)),(a=v(a,c,f,i,n[h+14],9,-1019803690)),(i=v(i,a,c,f,n[h+3],14,-187363961)),(f=v(f,i,a,c,n[h+8],20,1163531501)),(c=v(c,f,i,a,n[h+13],5,-1444681467)),(a=v(a,c,f,i,n[h+2],9,-51403784)),(i=v(i,a,c,f,n[h+7],14,1735328473)),(c=g(c,(f=v(f,i,a,c,n[h+12],20,-1926607734)),i,a,n[h+5],4,-378558,)),(a=g(a,c,f,i,n[h+8],11,-2022574463)),(i=g(i,a,c,f,n[h+11],16,1839030562)),(f=g(f,i,a,c,n[h+14],23,-35309556)),(c=g(c,f,i,a,n[h+1],4,-1530992060)),(a=g(a,c,f,i,n[h+4],11,1272893353)),(i=g(i,a,c,f,n[h+7],16,-155497632)),(f=g(f,i,a,c,n[h+10],23,-1094730640)),(c=g(c,f,i,a,n[h+13],4,681279174)),(a=g(a,c,f,i,n[h],11,-358537222)),(i=g(i,a,c,f,n[h+3],16,-722521979)),(f=g(f,i,a,c,n[h+6],23,76029189)),(c=g(c,f,i,a,n[h+9],4,-640364487)),(a=g(a,c,f,i,n[h+12],11,-421815835)),(i=g(i,a,c,f,n[h+15],16,530742520)),(c=m(c,(f=g(f,i,a,c,n[h+2],23,-995338651)),i,a,n[h],6,-198630844,)),(a=m(a,c,f,i,n[h+7],10,1126891415)),(i=m(i,a,c,f,n[h+14],15,-1416354905)),(f=m(f,i,a,c,n[h+5],21,-57434055)),(c=m(c,f,i,a,n[h+12],6,1700485571)),(a=m(a,c,f,i,n[h+3],10,-1894986606)),(i=m(i,a,c,f,n[h+10],15,-1051523)),(f=m(f,i,a,c,n[h+1],21,-2054922799)),(c=m(c,f,i,a,n[h+8],6,1873313359)),(a=m(a,c,f,i,n[h+15],10,-30611744)),(i=m(i,a,c,f,n[h+6],15,-1560198380)),(f=m(f,i,a,c,n[h+13],21,1309151649)),(c=m(c,f,i,a,n[h+4],6,-145523070)),(a=m(a,c,f,i,n[h+11],10,-1120210379)),(i=m(i,a,c,f,n[h+2],15,718787259)),(f=m(f,i,a,c,n[h+9],21,-343485551)),(c=d(c,r)),(f=d(f,e)),(i=d(i,o)),(a=d(a,u));return[c,f,i,a]}function a(n){for(var t='',r=32*n.length,e=0;e<r;e+=8)t+=String.fromCharCode((n[e>>5]>>>e%32)&255);return t}function h(n){var t=[];for(t[(n.length>>2)-1]=void 0,e=0;e<t.length;e+=1)t[e]=0;for(var r=8*n.length,e=0;e<r;e+=8)t[e>>5]|=(255&n.charCodeAt(e/8))<<e%32;return t}function e(n){for(var t,r='0123456789abcdef',e='',o=0;o<n.length;o+=1)(t=n.charCodeAt(o)),(e+=r.charAt((t>>>4)&15)+r.charAt(15&t));return e}function r(n){return unescape(encodeURIComponent(n))}function o(n){return a(i(h((t=r(n))),8*t.length));var t}function u(n,t){return(function(n,t){var r,e,o=h(n),u=[],c=[];for(u[15]=c[15]=void 0,16<o.length&&(o=i(o,8*n.length)),r=0;r<16;r+=1)(u[r]=909522486^o[r]),(c[r]=1549556828^o[r]);return((e=i(u.concat(h(t)),512+8*t.length)),a(i(c.concat(e),640)))})(r(n),r(t))}function t(n,t,r){return t?(r?u(t,n):e(u(t,n))):r?o(n):e(o(n))}return t(str)}
37-
38-
const reopenScript = () => {
39-
Safari.open(`scriptable:///run/${encodeURIComponent(ScriptName)}`)
40-
}
41-
4213
// 获取 Request 对象
4314
const getRequest = (url = '') => {
4415
return new Request(url)
@@ -56,7 +27,7 @@ const http = async (
5627
try {
5728
if (type === 'IMG') {
5829
const fm = FileManager.local()
59-
const fileName = await md5(options.url)
30+
const fileName = `${hashCode(options.url)}`
6031
const filePath = fm.joinPath(cache.cacheDirectory, fileName)
6132
request = getRequest(options.url)
6233
let response
@@ -197,9 +168,5 @@ module.exports = {
197168
getBoxJsData,
198169
getRefreshTime,
199170
renderHeader,
200-
renderNone,
201-
base64Encode,
202-
base64Decode,
203-
md5,
204-
reopenScript
171+
renderNone
205172
}

src/withSettings.module.js

+52-35
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*
77
* GitHub: https://github.com/honye
88
*
9-
* @version 1.6.2
9+
* @version 1.7.1
1010
* @author Honye
1111
*/
1212

@@ -131,7 +131,7 @@ const previewsHTML =
131131

132132
const copyrightHTML =
133133
`<footer>
134-
<div class="copyright">© UI powered by <a href="javascript:invoke('safari','https://www.imarkr.com');">iMarkr</a>.</div>
134+
<div class="copyright">© UI powered by <a href="javascript:invoke('safari','https://www.imarkr.com');">iMarkr</a></div>
135135
</footer>`
136136

137137
/**
@@ -182,35 +182,48 @@ const present = async (options, isFirstPage, others = {}) => {
182182
const style =
183183
`:root {
184184
--color-primary: #007aff;
185-
--divider-color: rgba(60,60,67,0.36);
185+
--text-color: #1e1f24;
186+
--text-secondary: #8b8d98;
187+
--divider-color: #eff0f3;
186188
--card-background: #fff;
187189
--card-radius: 10px;
188-
--list-header-color: rgba(60,60,67,0.6);
190+
--bg-input: #f9f9fb;
189191
}
190192
* {
191193
-webkit-user-select: none;
192194
user-select: none;
193195
}
196+
:focus-visible {
197+
outline-width: 2px;
198+
}
194199
body {
195200
margin: 10px 0;
196201
-webkit-font-smoothing: antialiased;
197202
font-family: "SF Pro Display","SF Pro Icons","Helvetica Neue","Helvetica","Arial",sans-serif;
198203
accent-color: var(--color-primary);
204+
color: var(--text-color);
199205
}
200206
input {
201207
-webkit-user-select: auto;
202208
user-select: auto;
203209
}
210+
input:where([type="date"], [type="time"], [type="datetime-local"], [type="month"], [type="week"]) {
211+
accent-color: var(--text-color);
212+
white-space: nowrap;
213+
}
214+
select {
215+
accent-color: var(--text-color);
216+
}
204217
body {
205218
background: #f2f2f7;
206219
}
207220
button {
208221
font-size: 16px;
209-
background: var(--color-primary);
210-
color: #fff;
222+
background: var(--card-background);
223+
color: var(--text-color);
211224
border-radius: 8px;
212225
border: none;
213-
padding: 0.24em 0.5em;
226+
padding: 0.5em;
214227
}
215228
button .iconfont {
216229
margin-right: 6px;
@@ -220,7 +233,7 @@ button .iconfont {
220233
}
221234
.list__header {
222235
margin: 0 20px;
223-
color: var(--list-header-color);
236+
color: var(--text-secondary);
224237
font-size: 13px;
225238
}
226239
.list__body {
@@ -256,11 +269,14 @@ button .iconfont {
256269
}
257270
.form-item__input-wrapper {
258271
flex: 1;
259-
overflow: hidden;
260272
text-align: right;
273+
box-sizing: border-box;
274+
padding: 2px;
275+
margin-right: -2px;
276+
overflow: hidden;
261277
}
262278
.form-item__input {
263-
max-width: 100%;
279+
max-width: calc(100% - 4px);
264280
}
265281
.form-item .iconfont {
266282
margin-right: 4px;
@@ -270,6 +286,13 @@ button .iconfont {
270286
font-size: 14px;
271287
text-align: right;
272288
}
289+
.form-item input:not([type=color]),
290+
.form-item select {
291+
border-radius: 99px;
292+
background-color: var(--bg-input);
293+
border: none;
294+
color: var(--text-color);
295+
}
273296
.form-item input[type="checkbox"] {
274297
width: 1.25em;
275298
height: 1.25em;
@@ -281,24 +304,26 @@ input[type="date"] {
281304
min-width: 6.4em;
282305
}
283306
input[type='checkbox'][role='switch'] {
307+
margin: 0;
284308
position: relative;
285309
display: inline-block;
286310
appearance: none;
287311
width: 40px;
288-
height: 24px;
289-
border-radius: 24px;
290-
background: #ccc;
312+
height: 25px;
313+
border-radius: 25px;
314+
background: var(--bg-input);
291315
transition: 0.3s ease-in-out;
292316
}
293317
input[type='checkbox'][role='switch']::before {
294318
content: '';
295319
position: absolute;
296320
left: 2px;
297321
top: 2px;
298-
width: 20px;
299-
height: 20px;
322+
width: 21px;
323+
height: 21px;
300324
border-radius: 50%;
301325
background: #fff;
326+
box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.04), 0 2px 6px 0 rgba(0, 0, 0, 0.15), 0 2px 1px 0 rgba(0, 0, 0, 0.06);
302327
transition: 0.3s ease-in-out;
303328
}
304329
input[type='checkbox'][role='switch']:checked {
@@ -309,15 +334,18 @@ input[type='checkbox'][role='switch']:checked::before {
309334
}
310335
.actions {
311336
margin: 15px;
337+
display: grid;
338+
grid-template-columns: repeat(3, 1fr);
339+
column-gap: 12px;
312340
}
313341
.copyright {
314342
margin: 15px;
315343
margin-inline: 18px;
316344
font-size: 12px;
317-
color: #86868b;
345+
color: var(--text-secondary);
318346
}
319347
.copyright a {
320-
color: #515154;
348+
color: var(--text-color);
321349
text-decoration: none;
322350
}
323351
.preview.loading {
@@ -342,33 +370,22 @@ input[type='checkbox'][role='switch']:checked::before {
342370
}
343371
@media (prefers-color-scheme: dark) {
344372
:root {
345-
--divider-color: rgba(84,84,88,0.65);
346-
--card-background: #1c1c1e;
347-
--list-header-color: rgba(235,235,245,0.6);
373+
--text-color: #eeeef0;
374+
--text-secondary: #6c6e79;
375+
--divider-color: #222325;
376+
--card-background: #19191b;
377+
--bg-input: #303136;
348378
}
349379
body {
350-
background: #000;
351-
color: #fff;
352-
}
353-
input {
354-
background-color: rgb(58, 57, 57);
355-
color: var(--color-primary);
356-
}
357-
input[type='checkbox'][role='switch'] {
358-
background-color: rgb(56, 56, 60);
380+
background: #111113;
359381
}
360382
input[type='checkbox'][role='switch']::before {
361383
background-color: rgb(206, 206, 206);
362384
}
363-
select {
364-
background-color: rgb(82, 82, 82);
365-
border: none;
366-
}
367385
.form-item[media="(prefers-color-scheme: dark)"] {
368386
display: flex;
369387
}
370-
}
371-
`
388+
}`
372389

373390
const js =
374391
`(() => {

0 commit comments

Comments
 (0)