forked from evilbutcher/Scriptables
-
Notifications
You must be signed in to change notification settings - Fork 0
/
RRShare.js
126 lines (113 loc) · 2.88 KB
/
RRShare.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
// Variables used by Scriptable.
// These must be at the very top of the file. Do not edit.
// icon-color: blue; icon-glyph: film;
/*
* Author: evilbutcher
* Github: https://github.com/evilbutcher
* 本脚本使用了@Gideon_Senku的Env.scriptable,感谢!
*/
const goupdate = true;
const $ = importModule("Env");
var num = 6; //自定义显示数量
var rancolor = true; //true为开启随机颜色
try {
var { rrnum, rrrancolor } = importModule("Config");
num = rrnum();
rancolor = rrrancolor();
console.log("将使用配置文件内人人影视配置");
} catch (e) {
console.log("将使用脚本内人人影视配置");
}
const res = await getinfo();
let widget = createWidget(res);
Script.setWidget(widget);
Script.complete();
function createWidget(res) {
items = [];
for (var i = 0; i < num; i++) {
var item = res[i]["file_name"];
items.push(item);
}
console.log(items);
const w = new ListWidget();
const bgColor = new LinearGradient();
bgColor.colors = [new Color("#1c1c1c"), new Color("#29323c")];
bgColor.locations = [0.0, 1.0];
w.backgroundGradient = bgColor;
w.addSpacer();
w.spacing = 5;
const firstLine = w.addText(`🎬人人影视`);
firstLine.font = new Font('SF Mono', 15);
firstLine.textColor = Color.white();
firstLine.textOpacity = 0.7;
for (var i = 0; i < items.length; i++) {
addTextToListWidget(`• ${items[i]}`, w);
}
w.addSpacer();
w.spacing = 5;
w.presentSmall();
return w;
}
async function getinfo() {
const zmzRequest = {
url: `http://file.apicvn.com/file/list?page=1&order=create_time&sort=desc`,
headers: {
Host: "file.apicvn.com",
"Content-Type": "application/x-www-form-urlencoded",
"User-Agent": "Mozilla/5.0",
},
};
const res = await $.get(zmzRequest);
log(res);
return res;
}
function addTextToListWidget(text, listWidget) {
let item = listWidget.addText(text);
if (rancolor == true) {
item.textColor = new Color(color16());
} else {
item.textColor = Color.white();
}
item.font = new Font('SF Mono', 12);
}
function color16() {
var r = Math.floor(Math.random() * 256);
if (r + 50 < 255) {
r = r + 50;
}
if (r > 230 && r < 255) {
r = r - 50;
}
var g = Math.floor(Math.random() * 256);
if (g + 50 < 255) {
g = g + 50;
}
if (g > 230 && g < 255) {
g = g - 50;
}
var b = Math.floor(Math.random() * 256);
if (b + 50 < 255) {
b = b + 50;
}
if (b > 230 && b < 255) {
b = b - 50;
}
var color = "#" + r.toString(16) + g.toString(16) + b.toString(16);
return color;
}
//更新代码
function update() {
log("🔔更新脚本开始!");
scripts.forEach(async (script) => {
await $.getFile(script);
});
log("🔔更新脚本结束!");
}
const scripts = [
{
moduleName: "RRShare",
url:
"https://raw.githubusercontent.com/evilbutcher/Scriptables/master/RRShare.js",
},
];
if (goupdate == true) update();