mirror of https://github.com/NobyDa/Script.git
Minor improvements.
This commit is contained in:
parent
eb2eabc073
commit
60a1f67f99
|
@ -4,6 +4,7 @@
|
|||
脚本兼容: QuantumultX, Surge, Loon
|
||||
电报频道:@NobyDa
|
||||
问题反馈:@NobyDa_bot
|
||||
更新日期:04/04/2023
|
||||
如果转载,请注明出处
|
||||
|
||||
说明:
|
||||
|
@ -43,7 +44,10 @@ const cookie = $.getdata("CookieBM") || ''; // 哔哩哔哩漫画Cookie
|
|||
const barkKey = ''; //Bark APP 通知推送Key
|
||||
|
||||
if (typeof $request !== 'undefined') {
|
||||
GetCookie()
|
||||
GetCookie(cookie)
|
||||
} else if (!cookie) {
|
||||
$.msg($.name, ``, `签到Cookie失效/未获取 ⚠️`);
|
||||
$.done();
|
||||
} else {
|
||||
checkin()
|
||||
}
|
||||
|
@ -53,6 +57,7 @@ function checkin() {
|
|||
url: 'https://manga.bilibili.com/twirp/activity.v1.Activity/ClockIn',
|
||||
headers: {
|
||||
Cookie: cookie,
|
||||
"User-Agent": "comic-universal/1552 CFNetwork/1406.0.4 Darwin/22.4.0 os/ios model/iPhone 12 mobi_app/iphone_comic build/1552 osVer/16.4 network/2 channel/AppStore"
|
||||
},
|
||||
body: "platform=ios"
|
||||
};
|
||||
|
@ -62,9 +67,10 @@ function checkin() {
|
|||
} else if (parseInt(response.status) == 200) {
|
||||
$.msgBody = "签到成功!🎉";
|
||||
} else if (/duplicate/.test(data)) {
|
||||
$.msgBody = "今日已签过 ⚠️";
|
||||
$.msgBody = "签到失败,今日已签过 ⚠️";
|
||||
} else if (/uid must/.test(data)) {
|
||||
$.msgBody = "Cookie失效 ‼️‼️";
|
||||
$.msgBody = "签到失败,Cookie失效(已清除) ⚠️";
|
||||
$.setdata("", "CookieBM");
|
||||
} else {
|
||||
$.msgBody = `签到失败 ‼️\n${data}`;
|
||||
}
|
||||
|
@ -76,37 +82,21 @@ function checkin() {
|
|||
})
|
||||
}
|
||||
|
||||
function GetCookie() {
|
||||
var CookieName = "B站漫画";
|
||||
var CookieKey = "CookieBM";
|
||||
var regex = /SESSDATA=.+?;/;
|
||||
if ($request.headers) {
|
||||
var header = Object.keys($request.headers).reduce((t, i) => (t[i.toLowerCase()] = $request.headers[i], t), {})['cookie'] || '';
|
||||
if (header.indexOf("SESSDATA=") != -1) {
|
||||
var CookieValue = regex.exec(header)[0];
|
||||
if ($.getdata(CookieKey)) {
|
||||
if ($.getdata(CookieKey) != CookieValue) {
|
||||
var cookie = $.setdata(CookieValue, CookieKey);
|
||||
if (!cookie) {
|
||||
$.msg("更新" + CookieName + "Cookie失败‼️", "", "");
|
||||
function GetCookie(oldCookie) {
|
||||
const req = JSON.stringify($request);
|
||||
if (!req.includes(`_comic`)) {
|
||||
$.log($.name, `非${$.name}客户端URL请求,跳过脚本 ⚠️`);
|
||||
} else if (!req.includes(`SESSDATA=`)) {
|
||||
$.msg($.name, ``, `获取Cookie失败,关键值缺失 ⚠️`);
|
||||
} else {
|
||||
$.msg("更新" + CookieName + "Cookie成功 🎉", "", "");
|
||||
}
|
||||
}
|
||||
const cookieValue = req.split(/(SESSDATA=.+?;)/)[1];
|
||||
const setCookie = $.setdata(cookieValue, `CookieBM`);
|
||||
if (oldCookie) {
|
||||
$.log($.name, `更新Cookie${setCookie ? `成功 🎉` : `失败 ⚠️`}`);
|
||||
} else {
|
||||
var cookie = $.setdata(CookieValue, CookieKey);
|
||||
if (!cookie) {
|
||||
$.msg("首次写入" + CookieName + "Cookie失败‼️", "", "");
|
||||
} else {
|
||||
$.msg("首次写入" + CookieName + "Cookie成功 🎉", "", "");
|
||||
$.msg($.name, ``, `获取Cookie${setCookie ? `成功 🎉` : `失败 ⚠️`}`);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$.msg("写入" + CookieName + "Cookie失败‼️", "", "Cookie关键值缺失");
|
||||
}
|
||||
} else {
|
||||
$.msg("写入" + CookieName + "Cookie失败‼️", "", "配置错误, 无法读取请求头,");
|
||||
}
|
||||
$.done()
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue