Skip to content

Commit c6b9d37

Browse files
committed
添加[网易云音乐]签到脚本
1 parent 9038e1f commit c6b9d37

3 files changed

Lines changed: 110 additions & 0 deletions

File tree

‎neteasemusic/README.md‎

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# 网易云音乐
2+
3+
## 配置
4+
5+
```properties
6+
[MITM]
7+
music.163.com
8+
9+
[Script]
10+
http-request ^http://music.163.com/ script-path=https://raw.githubusercontent.com/chavyleung/scripts/master/neteasemusic/neteasemusic.cookie.js
11+
cron "10 0 0 * * *" script-path=https://raw.githubusercontent.com/chavyleung/scripts/master/neteasemusic/neteasemusic.js
12+
```
13+
14+
## 说明
15+
16+
1. 先把`music.163.com`加到`[MITM]`
17+
2. 再把两条远程脚本放到`[Script]`
18+
3. 用浏览器访问下: http://music.163.com/ (需要登录)
19+
4. `Surge`提示: `Cookie [网易云音乐] 写入成功`
20+
5. 最后就可以把第 1 条脚本注释掉了
21+
22+
> 第 1 条脚本是用来获取 cookie 的, 用浏览器访问一次获取 cookie 成功后就可以删掉或注释掉了
23+
24+
> 第 2 条脚本是签到脚本, 每天`00:00:10`执行一次.
25+
26+
## 感谢
27+
28+
[@NobyDa](https://github.com/NobyDa)
29+
30+
[@lhie1](https://github.com/lhie1)
31+
32+
[@ConnersHua](https://github.com/ConnersHua)
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/**
2+
*
3+
* [MITM]
4+
* music.163.com
5+
*
6+
* [Script]
7+
* http-request ^http://music.163.com/ script-path=https://raw.githubusercontent.com/chavyleung/scripts/master/neteasemusic/neteasemusic.cookie.js
8+
* cron "10 0 0 * * *" script-path=https://raw.githubusercontent.com/chavyleung/scripts/master/neteasemusic/neteasemusic.js
9+
*
10+
*/
11+
12+
const cookieName = '网易云音乐'
13+
const cookieKey = 'chavy_cookie_neteasemusic'
14+
const cookieVal = $request.headers['Cookie']
15+
16+
if (cookieVal) {
17+
let cookie = $persistentStore.write(cookieVal, cookieKey)
18+
if (cookie) {
19+
let msg = `Cookie [${cookieName}] 写入成功!`
20+
$notification.post(msg, '', '详见日志')
21+
console.log(msg)
22+
console.log(cookieVal)
23+
}
24+
}
25+
26+
$done({})

‎neteasemusic/neteasemusic.js‎

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
/**
2+
*
3+
* [MITM]
4+
* music.163.com
5+
*
6+
* [Script]
7+
* http-request ^http://music.163.com/ script-path=https://raw.githubusercontent.com/chavyleung/scripts/master/neteasemusic/neteasemusic.cookie.js
8+
* cron "10 0 0 * * *" script-path=https://raw.githubusercontent.com/chavyleung/scripts/master/neteasemusic/neteasemusic.js
9+
*
10+
*/
11+
12+
const cookieName = '网易云音乐'
13+
const cookieKey = 'chavy_cookie_neteasemusic'
14+
const cookieVal = $persistentStore.read(cookieKey)
15+
16+
const pc = `http://music.163.com/api/point/dailyTask?type=1`
17+
const mobile = `http://music.163.com/api/point/dailyTask?type=0`
18+
19+
function sign() {
20+
let url = {
21+
url: null,
22+
headers: {
23+
Cookie: cookieVal
24+
}
25+
}
26+
27+
url.url = pc
28+
$httpClient.post(url, (error, response, data) => {
29+
log('网易云音乐(PC端)', data)
30+
})
31+
32+
url.url = mobile
33+
$httpClient.post(url, (error, response, data) => {
34+
log('网易云音乐(移动端)', data)
35+
})
36+
37+
$done({})
38+
}
39+
40+
function log(title, data) {
41+
let result = JSON.parse(data)
42+
console.log(result)
43+
if (result.code == 200) {
44+
console.log(`签到成功: ${title}`)
45+
} else {
46+
console.log(
47+
`签到失败: ${title}, 错误编码: ${result.code}, 错误原因: ${result.msg}`
48+
)
49+
}
50+
}
51+
52+
sign()

0 commit comments

Comments
 (0)