Skip to content

Commit c93e0ed

Browse files
committed
quanx - 添加[网易云音乐]签到脚本
1 parent 41c90d9 commit c93e0ed

3 files changed

Lines changed: 132 additions & 0 deletions

File tree

‎neteasemusic/quanx/README.md‎

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# 网易云音乐
2+
3+
## 配置
4+
5+
```properties
6+
[MITM]
7+
music.163.com
8+
9+
[rewrite_local]
10+
^https:\/\/music\.163\.com\/m\/ url script-response-body neteasemusic.cookie.js
11+
12+
[task_local]
13+
1 0 * * * neteasemusic.js
14+
```
15+
16+
## 说明
17+
18+
1. 先把`music.163.com`加到`[MITM]`
19+
2. 把`neteasemusic.cookie.js`和`neteasemusic.js`传到`On My iPhone - Quantumult X - Scripts` (传到 iCloud 相同目录也可, 注意要打开 quanx 的 iCloud 开关)
20+
3. 再把两条脚本分别放到`[rewrite_local]`和`[task_local]`
21+
4. 浏览器访问并登录: https://music.163.com/m/login
22+
5. 打开浏览器访问: http://music.163.com (注意了, 是 http, 没有 s)
23+
6. `Surge`提示: `Cookie [网易云音乐] 写入成功`
24+
7. 最后就可以把`[rewrite_local]`的脚本注释掉了
25+
26+
> 第 1 条脚本是用来获取 cookie 的, 用浏览器访问一次获取 cookie 成功后就可以删掉或注释掉了, 但请确保在`登录成功`后再获取 cookie.
27+
28+
> 第 2 条脚本是签到脚本, 每天`00:01:00`执行一次.
29+
30+
## 常见问题
31+
32+
1. 无法写入 Cookie
33+
34+
- 检查 Surge 系统通知权限放开了没
35+
- 如果你用的是 Safari, 请尝试在浏览地址栏`手动输入网址`(不要用复制粘贴)
36+
- 注意: 写入 Cookie 的网址是`http`开头的(不是 https, 没有 s, 没有 s, 没有要)
37+
38+
2. 写入 Cookie 成功, 但签到不成功
39+
40+
- 看看是不是在登录前就写入 Cookie 了
41+
- 如果是,请确保在登录成功后,再尝试写入 Cookie
42+
43+
## 感谢
44+
45+
[@NobyDa](https://github.com/NobyDa)
46+
47+
[@lhie1](https://github.com/lhie1)
48+
49+
[@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+
* [rewrite_local]
7+
* ^https:\/\/music\.163\.com\/m\/ url script-response-body neteasemusic.cookie.js
8+
*
9+
* [task_local]
10+
* 1 0 0 * * neteasemusic.js
11+
*
12+
*/
13+
14+
const cookieName = "网易云音乐";
15+
const cookieKey = "chavy_cookie_neteasemusic";
16+
const cookieVal = $request.headers["Cookie"];
17+
18+
if (cookieVal) {
19+
let cookie = $prefs.setValueForKey(cookieVal, cookieKey);
20+
if (cookie) {
21+
let msg = `Cookie [${cookieName}] 写入成功!`;
22+
$notify(msg, "", "详见日志");
23+
}
24+
}
25+
26+
$done({});

‎neteasemusic/quanx/neteasemusic.js‎

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
/**
2+
*
3+
* [MITM]
4+
* music.163.com
5+
*
6+
* [rewrite_local]
7+
* ^https:\/\/music\.163\.com\/m\/ url script-response-body neteasemusic.cookie.js
8+
*
9+
* [task_local]
10+
* 1 0 0 * * neteasemusic.js
11+
*
12+
*/
13+
14+
function sign() {
15+
const cookieName = "网易云音乐";
16+
const ccookieKey = "chavy_cookie_neteasemusic";
17+
const cookieVal = $prefs.valueForKey(cookieKey);
18+
19+
const pc = `http://music.163.com/api/point/dailyTask?type=1`;
20+
const mobile = `http://music.163.com/api/point/dailyTask?type=0`;
21+
22+
let url = {
23+
url: null,
24+
headers: {
25+
Cookie: cookieVal
26+
}
27+
};
28+
url.url = pc;
29+
$task.fetch(url).then(response => {
30+
log("网易云音乐(PC端)", response.body);
31+
});
32+
33+
url.url = mobile;
34+
$task.fetch(url).then(response => {
35+
log("网易云音乐(移动端)", response.body);
36+
});
37+
}
38+
39+
function log(title, data) {
40+
let result = JSON.parse(data);
41+
if (result.code == 200) {
42+
console.log(`签到成功: ${title}`);
43+
$notify("签到成功", title, "");
44+
} else if (result.code == -2) {
45+
console.log(
46+
`签到跳过: ${title}, 编码: ${result.code}, 原因: ${result.msg}`
47+
);
48+
$notify("签到跳过", title, `原因: ${result.msg}`);
49+
} else {
50+
console.log(
51+
`签到失败: ${title}, 编码: ${result.code}, 原因: ${result.msg}`
52+
);
53+
$notify("签到失败", title, `原因: ${result.msg}`);
54+
}
55+
}
56+
57+
sign();

0 commit comments

Comments
 (0)