-
Notifications
You must be signed in to change notification settings - Fork 0
/
biliDosign.js
76 lines (63 loc) · 1.9 KB
/
biliDosign.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
const $ = new initEnv();
const cookie = $.read("biliCookie");
dosign();
function dosign(){
const url = "https://api.live.bilibili.com/xlive/web-ucenter/v1/sign/DoSign";
const headers = {
"cookie":cookie,
"user-agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/101.0.4951.54 Safari/537.36 Edg/101.0.1210.39"
};
const myRequest = {
url:url,
headers:headers
}
$.get(myRequest,(error,response)=>{
if(error){
console.log(error);
}else{
let body = JSON.parse(response.body);
if(body.code===0){
$.notify("bili签到~",body.data.text,body.data.specialText);
}else{
$.notify("bili签到~",body.message,"");
}
}
$.done();
})
}
function initEnv() {
this.read = (key) => {
return $prefs.valueForKey(key);
}
this.notify = (title, subtitle, message) => {
$notify(title, subtitle, message);
}
this.getRandom = (min,max) => {
return Math.floor(Math.random() * (max - min + 1) ) + min;
}
this.sleep = (milliseconds) => {
const date = Date.now();
let currentDate = null;
do {
currentDate = Date.now();
} while (currentDate - date < milliseconds);
}
//get请求
this.get = (options, callback) => {
options["method"] = "GET"
$task.fetch(options).then(response => {
callback(null, response)
}, reason => callback(reason.error, null))
}
//post请求
this.post = (options, callback) => {
options["method"] = "POST"
$task.fetch(options).then(response => {
callback(null, response)
}, reason => callback(reason.error, null))
}
//结束
this.done = (resp={}) => {
$done(resp);
}
};