-
Notifications
You must be signed in to change notification settings - Fork 1
/
Tampermonkey.js
67 lines (61 loc) · 2.02 KB
/
Tampermonkey.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
// 感谢@1523789353贡献的代码
// ==UserScript==
// @name qtmdBili
// @description 哔哩哔哩营销号屏蔽
// @author xvhuan
// @namespace xvhuan
// @version 0.0.1
// @create 2024-04-03
// @lastmodified 2024-04-03
// @note 首次更新
// @charset UTF-8
// @match *://*.bilibili.com/*
// @connect localhost
// @connect qaq.al
// @run-at document-start
// @grant unsafeWindow
// @grant GM_xmlhttpRequest
// @grant GM_registerMenuCommand
// @compatible chrome
// @license MIT
// ==/UserScript==
(async function () {
const bili_jct = (await cookieStore.get('bili_jct')).value;
function sleep(ms) {
return new Promise(res => setTimeout(res, ms));
}
async function getUidList() {
const { promise, resolve, reject } = Promise.withResolvers();
// 油猴提供的跨域请求方法
GM_xmlhttpRequest({
url: 'https://qaq.al/x.txt',
method: 'GET',
onload: res => resolve(res.responseText),
onerror: reject
});
return promise;
}
async function addToBlackList(uid) {
return fetch('https://api.bilibili.com/x/relation/modify', {
method: 'POST',
headers: {
'Content-Type': 'application/x-www-form-urlencoded'
},
credentials: 'include',
body: `fid=${uid}&act=5&csrf=${bili_jct}`
})
.then(async res => void console.log('请求成功, 响应体: ', await res.text()))
.catch(err => void console.error('请求错误', err));
}
async function updateBlackList() {
const reqText = await getUidList();
const uidList = reqText.split('^');
for (let uid of uidList) {
console.log('正在拉黑: ', uid);
await addToBlackList(uid);
await sleep(200);
}
console.log('ok了老铁');
}
GM_registerMenuCommand("更新营销号黑名单", updateBlackList);
})();