B站热榜定时提醒
// ==UserScript==
// @name B站热榜定时提醒
// @namespace https://bbs.tampermonkey.net.cn/
// @version 0.1.0
// @description 定时提示B站热搜榜单。
// @author chen
// @grant GM_xmlhttpRequest
// @grant GM_notification
// @crontab * once * * *
// ==/UserScript==
return new Promise((resolve, reject) => {
GM_xmlhttpRequest({
url: "https://www.bilibili.com/v/popular/rank/all",
onload(res) {
const str = res.responseText;
let regex = /target="_blank" class="title">(.*?)</g;
let list=[];
let result;
//let regExp = new RegExp('target="_blank" class="title">(.*?)<', 'g');
while (( result = regex.exec(str))) {
list.push(result);
}
console.log(list)
let num_1 = list[0][1]
let num_2 = list[1][1]
let num_3 = list[3][1]
GM_notification({
title: "B站热榜",
image: "https://bbs.tampermonkey.net.cn/uc_server/avatar.php?uid=722&size=middle&ts=1",
text: "1:"+num_1+"\n2:"+num_2+"\n3:"+num_3
});
resolve();
},
onerror() {
GM_notification("error");
resolve();
}
})
});