forked from evilbutcher/Scriptables
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathWeiboMonitor.js
77 lines (69 loc) · 1.94 KB
/
WeiboMonitor.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
// Variables used by Scriptable.
// These must be at the very top of the file. Do not edit.
// icon-color: yellow; icon-glyph: fire;
/*
* Author: evilbutcher
* Github: https://github.com/evilbutcher
* 本脚本使用了@Gideon_Senku的Env.scriptable,感谢!
*/
const goupdate = true;
const $ = importModule("Env");
const title = `🔥 微博热搜`;
const preview = "medium";
const spacing = 5;
const res = await getinfo();
let widget = await createWidget(res);
Script.setWidget(widget);
Script.complete();
async function createWidget(res) {
if (res.data.cards[0].title == "实时热点,每分钟更新一次") {
var group = res.data.cards[0]["card_group"];
items = [];
for (var i = 0; i < 6; i++) {
var item = group[i].desc;
items.push(item);
}
console.log(items);
const opts = {
title,
texts: {
text1: { text: `📌 ${items[0]}`, url: group[0].scheme },
text2: { text: `• ${items[1]}`, url: group[1].scheme },
text3: { text: `• ${items[2]}`, url: group[2].scheme },
text4: { text: `• ${items[3]}`, url: group[3].scheme },
text5: { text: `• ${items[4]}`, url: group[4].scheme },
text6: { text: `• ${items[5]}`, url: group[5].scheme },
battery: "true",
},
preview,
spacing,
};
let widget = await $.createWidget(opts);
return widget;
}
}
async function getinfo() {
const url = {
url:
"https://m.weibo.cn/api/container/getIndex?containerid=106003%26filter_type%3Drealtimehot",
};
const res = await $.get(url);
//log(res);
return res;
}
//更新代码
function update() {
log("🔔更新脚本开始!");
scripts.forEach(async (script) => {
await $.getFile(script);
});
log("🔔更新脚本结束!");
}
const scripts = [
{
moduleName: "WeiboMonitor",
url:
"https://raw.githubusercontent.com/evilbutcher/Scriptables/master/WeiboMonitor.js",
},
];
if (goupdate == true) update();