Skip to content

Commit e6929df

Browse files
committed
更新[百度]签到脚本: 支持贴吧、文库、知道
1 parent 7bfd5a1 commit e6929df

2 files changed

Lines changed: 66 additions & 8 deletions

File tree

tieba/README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1-
# 百度贴吧 (Surge & QuanX 二合一签到脚本)
1+
# 百度签到 (Surge & QuanX 二合一签到脚本)
22

33
> 代码已同时兼容 Surge & QuanX, 使用同一份签到脚本即可
44
5+
> 目前支持签到: 贴吧、文库、知道
6+
57
## 配置 (Surge)
68

79
```properties

tieba/tieba.js

Lines changed: 63 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@ const cookieVal = chavy.getdata(cookieKey)
66
sign()
77

88
function sign() {
9-
let url = {
10-
url: `https://tieba.baidu.com/mo/q/newmoindex`,
11-
headers: {
12-
Cookie: cookieVal
13-
}
14-
}
9+
signTieba()
10+
signWenku()
11+
signZhidao()
12+
}
1513

14+
function signTieba() {
15+
let url = { url: `https://tieba.baidu.com/mo/q/newmoindex`, headers: { Cookie: cookieVal } }
1616
chavy.post(url, (error, response, data) => {
1717
let result = JSON.parse(data)
1818
let tbs = result.data.tbs
@@ -54,13 +54,69 @@ function sign() {
5454
function signBar(bar, tbs, cb) {
5555
let url = {
5656
url: `https://tieba.baidu.com/sign/add`,
57-
method: 'POST',
5857
headers: { Cookie: cookieVal },
5958
body: `ie=utf-8&kw=${bar.forum_name.split('&').join('%26')}&tbs=${tbs}`
6059
}
6160
chavy.post(url, cb)
6261
}
6362

63+
function signWenku() {
64+
let url = { url: `https://wenku.baidu.com/task/submit/signin`, headers: { Cookie: cookieVal } }
65+
url.headers['Content-Type'] = 'application/x-www-form-urlencoded; charset=UTF-8'
66+
chavy.get(url, (error, response, data) => {
67+
const signresult = JSON.parse(data)
68+
const title = '百度文库'
69+
let subTitle = ''
70+
let detail = ''
71+
if (signresult.errno == '0') {
72+
subTitle = '签到结果: 成功'
73+
chavy.msg(title, subTitle, detail)
74+
chavy.log(`[${title}] ${subTitle}`)
75+
} else {
76+
subTitle = '签到结果: 未知'
77+
detail = '详见日志'
78+
chavy.msg(title, subTitle, detail)
79+
chavy.log(`[${title}] 签到结果: 未知, ${data}`)
80+
}
81+
})
82+
}
83+
84+
function signZhidao() {
85+
let url = {
86+
url: `https://zhidao.baidu.com/`,
87+
headers: { Cookie: cookieVal }
88+
}
89+
chavy.get(url, (error, response, data) => {
90+
const timestamp = Date.parse(new Date())
91+
const utdata = `61,61,7,0,0,0,12,61,5,2,12,4,24,5,4,1,4,${timestamp}`
92+
const stoken = [...data.matchAll(/"stoken"[^"]*"([^"]*)"/g)][0][1]
93+
const signurl = { url: `https://zhidao.baidu.com/submit/user`, headers: { Cookie: cookieVal }, body: {} }
94+
signurl.body = `cm=100509&utdata=${utdata}&stoken=${stoken}`
95+
chavy.post(signurl, (signerror, signresp, signdata) => {
96+
const signresult = JSON.parse(signdata)
97+
const title = '百度知道'
98+
let subTitle = ''
99+
let detail = ''
100+
if (signresult.errorNo == 0) {
101+
subTitle = '签到结果: 成功'
102+
detail = `活跃: ${signresult.data.signInDataNum}天, 说明: ${signresult.errorMsg}`
103+
chavy.msg(title, subTitle, detail)
104+
chavy.log(`[${title}] ${subTitle}, ${signdata}`)
105+
} else if (signresult.errorNo == 2) {
106+
subTitle = `签到结果: 成功 (重复签到)`
107+
detail = `活跃: ${signresult.data.signInDataNum}天, 说明: ${signresult.errorMsg}`
108+
chavy.msg(title, subTitle, detail)
109+
chavy.log(`[${title}] ${subTitle}, ${signdata}`)
110+
} else {
111+
subTitle = '签到结果: 失败'
112+
detail = `说明: ${signresult.errorMsg}`
113+
chavy.msg(title, subTitle, detail)
114+
chavy.log(`[${title}] ${subTitle}`)
115+
}
116+
})
117+
})
118+
}
119+
64120
function check(forums, signinfo, checkms = 0) {
65121
let title = `${cookieName}`
66122
let subTitle = ``

0 commit comments

Comments
 (0)