Skip to content

Commit d842d93

Browse files
author
GideonSenku
committed
添加[全民K歌]签到脚本
1 parent efaa42f commit d842d93

5 files changed

Lines changed: 253 additions & 9 deletions

File tree

‎QuantumultX_Local_Cookie.conf‎

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# 本配置适用于: QuanX TestFlight v1.0.6-build195 及以后版本
22
# 如果你是商店版, 请使用: QuantumultX_AppStore_Local_Cookie.conf
33

4-
hostname = api.dushu.io, pm.m.fenqile.com, maicai.api.ddxq.mobi, group.baicizhan.com, api.everphoto.cn, i.meituan.com, promotion.waimai.meituan.com, wx.10086.cn, www.maomicd.com, act.10010.com, api-takumi.mihoyo.com, m.gdoil.cn, credits.bz.mgtv.com, *.csdn.net, wapside.189.cn, *.acfun.cn, apk.tw, *.bilibili.com, api.dongqiudi.com, *.feng.com, www.flyertea.com, music.163.com, *.m.163.com, user.qunar.com, *.rr.tv, *.weixinjia.net, *.smzdm.com, tieba.baidu.com, *.v2ex.com, *.video.qq.com, v.qq.com, mobwsa.ximalaya.com, *.you.163.com, *.rrys2019.com, ios.zmzapi.com
4+
hostname = node.kg.qq.com, api.dushu.io, pm.m.fenqile.com, maicai.api.ddxq.mobi, group.baicizhan.com, api.everphoto.cn, i.meituan.com, promotion.waimai.meituan.com, wx.10086.cn, www.maomicd.com, act.10010.com, api-takumi.mihoyo.com, m.gdoil.cn, credits.bz.mgtv.com, *.csdn.net, wapside.189.cn, *.acfun.cn, apk.tw, *.bilibili.com, api.dongqiudi.com, *.feng.com, www.flyertea.com, music.163.com, *.m.163.com, user.qunar.com, *.rr.tv, *.weixinjia.net, *.smzdm.com, tieba.baidu.com, *.v2ex.com, *.video.qq.com, v.qq.com, mobwsa.ximalaya.com, *.you.163.com, *.rrys2019.com, ios.zmzapi.com
55

66
# 电信营业厅
77
^https:\/\/wapside.189.cn:9001\/api\/home\/homeInfo url script-request-header https://raw.githubusercontent.com/chavyleung/scripts/master/10000/10000.cookie.js
@@ -107,8 +107,7 @@ https:\/\/www.maomicd.com\/plugin.php\?id=k_misign:sign&operation=qiandao url sc
107107
^https://pm\.m\.fenqile\.com/route0014/star/sign/sign.json url script-request-body https://raw.githubusercontent.com/chavyleung/scripts/master/fenqile/fenqile.cookie.js
108108

109109
#樊登读书
110-
<<<<<<< HEAD
111110
^https://api\.dushu\.io/CheckIn url script-request-body https://raw.githubusercontent.com/chavyleung/scripts/master/fandeng/fandeng.cookie.js
112-
=======
113-
^https://api\.dushu\.io/CheckIn url script-request-body https://raw.githubusercontent.com/chavyleung/scripts/master/pandeng/pandeng.cookie.js
114-
>>>>>>> origin/master
111+
112+
#全民K歌
113+
^https://node\.kg\.qq\.com/webapp/proxy? url script-request-body https://raw.githubusercontent.com/chavyleung/scripts/master/qmkg/qmkg.cookie.js

‎QuantumultX_Local_Task.conf‎

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,6 @@
6565
# 分期乐
6666
1 0 * * * chavyleung/fenqile/fenqile.js
6767
#樊登读书
68-
<<<<<<< HEAD
6968
1 0 * * * chavyleung/fandeng/fandeng.js
70-
=======
71-
1 0 * * * chavyleung/pandeng/pandeng.js
72-
>>>>>>> origin/master
69+
#全民K歌
70+
1 0 * * * chavyleung/qmkg/qmkg.js

‎qmkg/README.md‎

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
# 全民K歌
2+
3+
> 代码已同时兼容 Surge & QuanX, 使用同一份签到脚本即可
4+
5+
> QuanX 需要: v1.0.6-build195 及以后版本 (TestFlight)
6+
7+
> 感谢 [@GideonSenku](https://github.com/GideonSenku) Commit
8+
9+
## 配置 (Surge)
10+
11+
```properties
12+
[MITM]
13+
node.kg.qq.com
14+
15+
[Script]
16+
http-request ^https://node\.kg\.qq\.com/webapp/proxy? script-path=https://raw.githubusercontent.com/chavyleung/scripts/master/qmkg/qmkg.cookie.js, requires-body=true
17+
18+
cron "10 0 0 * * *" script-path=https://raw.githubusercontent.com/chavyleung/scripts/master/qmkg/qmkg.js
19+
```
20+
21+
## 配置 (QuanX)
22+
23+
```properties
24+
[MITM]
25+
node.kg.qq.com
26+
27+
[rewrite_local]
28+
29+
# [商店版] QuanX v1.0.6-build194 及更早版本
30+
# 不支持
31+
32+
# [TestFlight] QuanX v1.0.6-build195 及以后版本
33+
^https://node\.kg\.qq\.com/webapp/proxy? url script-request-body https://raw.githubusercontent.com/chavyleung/scripts/master/qmkg/qmkg.cookie.js
34+
35+
[task_local]
36+
1 0 * * * qmkg.js
37+
```
38+
39+
## 说明
40+
41+
1. 先把`node.kg.qq.com`加到`[MITM]`
42+
2. 再配置重写规则:
43+
- Surge: 把两条远程脚本放到`[Script]`
44+
- QuanX: 把`qmkg.cookie.js`和`qmkg.js`传到`On My iPhone - Quantumult X - Scripts` (传到 iCloud 相同目录也可, 注意要打开 quanx 的 iCloud 开关)
45+
3. 打开 APP 手动签到一次: 访问下右下角 `我的` > `乐星` > `签到`
46+
4. 系统提示: `获取Cookie: 成功`
47+
5. 把获取 Cookie 的脚本注释掉
48+
6. 运行一次脚本, 如果提示重复签到, 那就算成功了!
49+
50+
> 第 1 条脚本是用来获取 cookie 的, 用浏览器访问一次获取 cookie 成功后就可以删掉或注释掉了, 但请确保在`登录成功`后再获取 cookie.
51+
52+
> 第 2 条脚本是签到脚本, 每天`00:00:10`执行一次.
53+
54+
## 常见问题
55+
56+
1. 无法写入 Cookie
57+
58+
- 检查 Surge 系统通知权限放开了没
59+
- 如果你用的是 Safari, 请尝试在浏览地址栏`手动输入网址`(不要用复制粘贴)
60+
61+
2. 写入 Cookie 成功, 但签到不成功
62+
63+
- 看看是不是在登录前就写入 Cookie 了
64+
- 如果是,请确保在登录成功后,再尝试写入 Cookie
65+
66+
3. 为什么有时成功有时失败
67+
68+
- 很正常,网络问题,哪怕你是手工签到也可能失败(凌晨签到容易拥堵就容易失败)
69+
- 暂时不考虑代码级的重试机制,但咱有配置级的(暴力美学):
70+
71+
- `Surge`配置:
72+
73+
```properties
74+
# 没有什么是一顿饭解决不了的:
75+
cron "10 0 0 * * *" script-path=xxx.js # 每天00:00:10执行一次
76+
# 如果有,那就两顿:
77+
cron "20 0 0 * * *" script-path=xxx.js # 每天00:00:20执行一次
78+
# 实在不行,三顿也能接受:
79+
cron "30 0 0 * * *" script-path=xxx.js # 每天00:00:30执行一次
80+
81+
# 再粗暴点,直接:
82+
cron "* */60 * * * *" script-path=xxx.js # 每60分执行一次
83+
```
84+
85+
- `QuanX`配置:
86+
87+
```properties
88+
[task_local]
89+
1 0 * * * xxx.js # 每天00:01执行一次
90+
2 0 * * * xxx.js # 每天00:02执行一次
91+
3 0 * * * xxx.js # 每天00:03执行一次
92+
93+
*/60 * * * * xxx.js # 每60分执行一次
94+
```
95+
96+
## 感谢
97+
98+
[@NobyDa](https://github.com/NobyDa)
99+
100+
[@lhie1](https://github.com/lhie1)
101+
102+
[@ConnersHua](https://github.com/ConnersHua)
103+
104+
[@GideonSenku](https://github.com/GideonSenku)

‎qmkg/qmkg.cookie.js‎

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
const cookieName = '全民K歌'
2+
const signurlKey = 'senku_signurl_qmkg'
3+
const signheaderKey = 'senku_signheader_qmkg'
4+
const signbodyKey = 'senku_signbody_qmkg'
5+
const senku = init()
6+
7+
const requrl = $request.url
8+
if ($request && $request.method != 'OPTIONS') {
9+
const signurlVal = requrl
10+
const signheaderVal = JSON.stringify($request.headers)
11+
const signbodyVal = $request.body
12+
const cmd = JSON.parse($request.body).cmd
13+
senku.log(`signurlVal:${signurlVal}`)
14+
senku.log(`signheaderVal:${signheaderVal}`)
15+
senku.log(`signbodyVal:${signbodyVal}`)
16+
if (signurlVal) senku.setdata(signurlVal, signurlKey)
17+
if (signheaderVal) senku.setdata(signheaderVal, signheaderKey)
18+
if (signbodyVal && cmd=='task.revisionSignInGetAward') {
19+
senku.setdata(signbodyVal, signbodyKey)
20+
senku.msg(cookieName, `获取Cookie: 成功`, ``)
21+
}
22+
}
23+
24+
function init() {
25+
isSurge = () => {
26+
return undefined === this.$httpClient ? false : true
27+
}
28+
isQuanX = () => {
29+
return undefined === this.$task ? false : true
30+
}
31+
getdata = (key) => {
32+
if (isSurge()) return $persistentStore.read(key)
33+
if (isQuanX()) return $prefs.valueForKey(key)
34+
}
35+
setdata = (key, val) => {
36+
if (isSurge()) return $persistentStore.write(key, val)
37+
if (isQuanX()) return $prefs.setValueForKey(key, val)
38+
}
39+
msg = (title, subtitle, body) => {
40+
if (isSurge()) $notification.post(title, subtitle, body)
41+
if (isQuanX()) $notify(title, subtitle, body)
42+
}
43+
log = (message) => console.log(message)
44+
get = (url, cb) => {
45+
if (isSurge()) {
46+
$httpClient.get(url, cb)
47+
}
48+
if (isQuanX()) {
49+
url.method = 'GET'
50+
$task.fetch(url).then((resp) => cb(null, {}, resp.body))
51+
}
52+
}
53+
post = (url, cb) => {
54+
if (isSurge()) {
55+
$httpClient.post(url, cb)
56+
}
57+
if (isQuanX()) {
58+
url.method = 'POST'
59+
$task.fetch(url).then((resp) => cb(null, {}, resp.body))
60+
}
61+
}
62+
done = (value = {}) => {
63+
$done(value)
64+
}
65+
return { isSurge, isQuanX, msg, log, getdata, setdata, get, post, done }
66+
}
67+
senku.done()

‎qmkg/qmkg.js‎

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
const cookieName = '分期乐'
2+
const signurlKey = 'senku_signurl_qmkg'
3+
const signheaderKey = 'senku_signheader_qmkg'
4+
const signbodyKey = 'senku_signbody_qmkg'
5+
const senku = init()
6+
const signurlVal = senku.getdata(signurlKey)
7+
const signheaderVal = senku.getdata(signheaderKey)
8+
const signBodyVal = senku.getdata(signbodyKey)
9+
10+
sign()
11+
12+
function sign() {
13+
const url = { url: signurlVal, headers: JSON.parse(signheaderVal), body: signBodyVal }
14+
senku.post(url, (error, response, data) => {
15+
const result = JSON.parse(data)
16+
const total = result.data['task.revisionSignInGetAward'].total
17+
const ret = result.data['task.revisionSignInGetAward'].ret
18+
let subTitle = ``
19+
let detail = ``
20+
if (total != 0) {
21+
const num = result.data['task.revisionSignInGetAward'].awards[0].num
22+
subTitle = `签到结果: 成功`
23+
detail = `获得鲜花: ${num}朵,已连续签到:${total}天`
24+
} else if (ret == -11532) {
25+
subTitle = `签到结果: 成功 (重复签到)`
26+
} else {
27+
subTitle = `签到结果: 失败`
28+
}
29+
senku.msg(cookieName, subTitle, detail)
30+
senku.done()
31+
})
32+
}
33+
34+
function init() {
35+
isSurge = () => {
36+
return undefined === this.$httpClient ? false : true
37+
}
38+
isQuanX = () => {
39+
return undefined === this.$task ? false : true
40+
}
41+
getdata = (key) => {
42+
if (isSurge()) return $persistentStore.read(key)
43+
if (isQuanX()) return $prefs.valueForKey(key)
44+
}
45+
setdata = (key, val) => {
46+
if (isSurge()) return $persistentStore.write(key, val)
47+
if (isQuanX()) return $prefs.setValueForKey(key, val)
48+
}
49+
msg = (title, subtitle, body) => {
50+
if (isSurge()) $notification.post(title, subtitle, body)
51+
if (isQuanX()) $notify(title, subtitle, body)
52+
}
53+
log = (message) => console.log(message)
54+
get = (url, cb) => {
55+
if (isSurge()) {
56+
$httpClient.get(url, cb)
57+
}
58+
if (isQuanX()) {
59+
url.method = 'GET'
60+
$task.fetch(url).then((resp) => cb(null, resp, resp.body))
61+
}
62+
}
63+
post = (url, cb) => {
64+
if (isSurge()) {
65+
$httpClient.post(url, cb)
66+
}
67+
if (isQuanX()) {
68+
url.method = 'POST'
69+
$task.fetch(url).then((resp) => cb(null, resp, resp.body))
70+
}
71+
}
72+
done = (value = {}) => {
73+
$done(value)
74+
}
75+
return { isSurge, isQuanX, msg, log, getdata, setdata, get, post, done }
76+
}

0 commit comments

Comments
 (0)