[百度贴吧] 修复新版贴吧无法获取Cookie的问题 close #660

This commit is contained in:
blackmatrix7 2022-08-24 20:31:24 +08:00
parent f0babd07e8
commit ef60cf2ca4
6 changed files with 40 additions and 22 deletions

View File

@ -21,6 +21,10 @@
使用模块 使用模块
Surge在获取Cookie时需要在MITM中设置h2=false即关闭 MITM over HTTP/2否则会提示获取Cookie出现异常。
建议在获取Cookie时临时关闭获取成功后再开启或者等待客户端修复。
```ini ```ini
https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/script/tieba/tieba_checkin.sgmodule https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/script/tieba/tieba_checkin.sgmodule
``` ```
@ -32,16 +36,16 @@ https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/script/tie
https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/script/tieba/tieba_checkin.qxrewrite, tag=贴吧_获取Cookie, update-interval=86400, opt-parser=false, enabled=true https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/script/tieba/tieba_checkin.qxrewrite, tag=贴吧_获取Cookie, update-interval=86400, opt-parser=false, enabled=true
[task_local] [task_local]
30 0 * * * https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/script/tieba/tieba_checkin.js, tag=贴吧_每日签到, enabled=true 30 9 * * * https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/script/tieba/tieba_checkin.js, tag=贴吧_每日签到, enabled=true
``` ```
### Loon ### Loon
配置文 使用插
```ini ```ini
[Remote Script] [Remote Script]
https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/script/tieba/tieba_checkin.lnscript, tag=贴吧_每日签到, enabled=true https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/script/tieba/tieba_checkin.lnplugin, tag=贴吧_每日签到, enabled=true
``` ```
## 获取Cookie ## 获取Cookie

View File

@ -4,12 +4,13 @@
*/ */
const scirptName = "百度贴吧"; const scirptName = "百度贴吧";
const batchSize = 20; const batchSize = 20;
const retries = 5; // 签到失败重试次数 const retries = 10; // 签到失败重试次数
const interval = 2000; // 每次重试间隔 const interval = 5000; // 每次重试间隔
const tiebaCookieKey = "tieba_checkin_cookie"; const tiebaCookieKey = "tieba_checkin_cookie";
const tiebeGetCookieRegex = /https?:\/\/(c\.tieba\.baidu\.com|180\.97\.\d+\.\d+)\/c\/s\/login/; const tiebeGetCookieRegex1 = /https?:\/\/(c\.tieba\.baidu\.com|180\.97\.\d+\.\d+)\/c\/s\/login/;
const tiebeNewVersionGetCookieRegex = /^https?:\/\/c\.tieba\.baidu\.com\/c\/s\/channelIconConfig/; const tiebeGetCookieRegex2 = /^https?:\/\/c\.tieba\.baidu\.com\/c\/s\/channelIconConfig/;
let magicJS = MagicJS(scirptName, "INFO"); const tiebeGetCookieRegex3 = /https?:\/\/tiebac\.baidu\.com\/c\/u\/follow\/getFoldedMessageUserInfo/;
let magicJS = MagicJS(scirptName, "DEBUG");
magicJS.unifiedPushUrl = magicJS.read("tieba_unified_push_url") || magicJS.read("magicjs_unified_push_url"); magicJS.unifiedPushUrl = magicJS.read("tieba_unified_push_url") || magicJS.read("magicjs_unified_push_url");
let getTiebaListOptions = { let getTiebaListOptions = {
@ -109,7 +110,9 @@ function TiebaCheckIn(cookie, tbs, tieba) {
} }
(async () => { (async () => {
if (magicJS.isRequest && (tiebeGetCookieRegex.test(magicJS.request.url) || tiebeNewVersionGetCookieRegex.test(magicJS.request.url))) { if (magicJS.isRequest && (tiebeGetCookieRegex1.test(magicJS.request.url) ||
tiebeGetCookieRegex2.test(magicJS.request.url) ||
tiebeGetCookieRegex3.test(magicJS.request.url))) {
let cookie = magicJS.request.headers.Cookie; let cookie = magicJS.request.headers.Cookie;
let hisCookie = magicJS.read(tiebaCookieKey); let hisCookie = magicJS.read(tiebaCookieKey);
magicJS.logDebug(`当前贴吧Cookie\n${cookie}\n历史贴吧Cookie\n${hisCookie}`); magicJS.logDebug(`当前贴吧Cookie\n${cookie}\n历史贴吧Cookie\n${hisCookie}`);

View File

@ -0,0 +1,16 @@
#!name= 百度贴吧
#!desc= 百度贴吧每日签到
#!openUrl=https://github.com/blackmatrix7/ios_rule_script/tree/master/script/tieba
#!author= blackmatrix7
#!homepage= https://github.com/blackmatrix7/ios_rule_script
#!icon= https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/script/tieba/tieba.png
[URL Rewrite]
http-request ^https?:\/\/(c\.tieba\.baidu\.com|180\.97\.\d+\.\d+)\/c\/s\/login script-path=https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/script/tieba/tieba_checkin.js,tag=贴吧_获取Cookie1
http-request ^https?:\/\/c\.tieba\.baidu\.com\/c\/s\/channelIconConfig script-path=https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/script/tieba/tieba_checkin.js,tag=贴吧_新版Cookie2
http-request ^https?:\/\/tiebac\.baidu\.com\/c\/u\/follow\/getFoldedMessageUserInfo script-path=https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/script/tieba/tieba_checkin.js,tag=贴吧_新版Cookie3
cron "30 9 * * *" script-path=https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/script/tieba/tieba_checkin.js,timeout=60,tag=贴吧_每日签到
[MITM]
hostname = c.tieba.baidu.com, tiebac.baidu.com

View File

@ -1,7 +0,0 @@
# 百度贴吧签到
http-request ^https?:\/\/(c\.tieba\.baidu\.com|180\.97\.\d+\.\d+)\/c\/s\/login script-path=https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/script/tieba/tieba_checkin.js,tag=贴吧_获取Cookie
http-request ^https?:\/\/c\.tieba\.baidu\.com\/c\/s\/channelIconConfig script-path=https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/script/tieba/tieba_checkin.js,tag=贴吧_获取新版Cookie
cron "30 0 * * *" script-path=https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/script/tieba/tieba_checkin.js,timeout=60,tag=贴吧_每日签到
hostname = c.tieba.baidu.com

View File

@ -2,5 +2,6 @@
^https?:\/\/(c\.tieba\.baidu\.com|180\.97\.\d+\.\d+)\/c\/s\/login url script-request-header https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/script/tieba/tieba_checkin.js ^https?:\/\/(c\.tieba\.baidu\.com|180\.97\.\d+\.\d+)\/c\/s\/login url script-request-header https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/script/tieba/tieba_checkin.js
^https?:\/\/c\.tieba\.baidu\.com\/c\/s\/channelIconConfig url script-request-header https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/script/tieba/tieba_checkin.js ^https?:\/\/c\.tieba\.baidu\.com\/c\/s\/channelIconConfig url script-request-header https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/script/tieba/tieba_checkin.js
^https?:\/\/tiebac\.baidu\.com\/c\/u\/follow\/getFoldedMessageUserInfo url script-request-header https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/script/tieba/tieba_checkin.js
hostname = c.tieba.baidu.com hostname = c.tieba.baidu.com, tiebac.baidu.com

View File

@ -3,9 +3,10 @@
#!system=ios #!system=ios
[Script] [Script]
贴吧_每日签到 = type=cron,cronexp=30 0 * * *,timeout=60,script-path=https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/script/tieba/tieba_checkin.js 贴吧_每日签到 = type=cron,cronexp=30 9 * * *,timeout=60,script-path=https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/script/tieba/tieba_checkin.js
贴吧_获取cookie = type=http-request,pattern=^https?:\/\/(c\.tieba\.baidu\.com|180\.97\.\d+\.\d+)\/c\/s\/login,script-path=https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/script/tieba/tieba_checkin.js 贴吧_获取cookie1 = type=http-request,pattern=^https?:\/\/(c\.tieba\.baidu\.com|180\.97\.\d+\.\d+)\/c\/s\/login,script-path=https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/script/tieba/tieba_checkin.js
贴吧_获取新版cookie = type=http-request,pattern=^https?:\/\/c\.tieba\.baidu\.com\/c\/s\/channelIconConfig,script-path=https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/script/tieba/tieba_checkin.js 贴吧_获取cookie2 = type=http-request,pattern=^https?:\/\/c\.tieba\.baidu\.com\/c\/s\/channelIconConfig,script-path=https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/script/tieba/tieba_checkin.js
贴吧_获取cookie3 = type=http-request,pattern=^https?:\/\/tiebac\.baidu\.com\/c\/u\/follow\/getFoldedMessageUserInfo,script-path=https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/script/tieba/tieba_checkin.js
[MITM] [MITM]
hostname = %APPEND% c.tieba.baidu.com hostname = %APPEND% c.tieba.baidu.com, tiebac.baidu.com