From b1d5ad937daa49fc9a9dec924890c340030e98e7 Mon Sep 17 00:00:00 2001 From: blackmatrix7 <27717518+blackmatrix7@users.noreply.github.com> Date: Mon, 19 Apr 2021 16:00:17 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E9=83=A8=E5=88=86=E8=84=9A?= =?UTF-8?q?=E6=9C=AC=E6=8C=81=E4=B9=85=E5=8C=96=E6=95=B0=E6=8D=AE=E4=BD=BF?= =?UTF-8?q?=E7=94=A8=E7=9A=84Key?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- script/bilibili/bilibili_plus.js | 203 +++++++++--------- script/boxjs.json | 20 +- script/tieba/tieba_checkin.js | 2 +- source/README.md | 2 +- .../040e1c9f431bfc171244df659317c5f3.js | 13 -- .../4d3fe67365a3266b75047f38705d12e3.js | 23 -- .../9e569124280463491b2ea8ce15427e93.js | 43 ---- .../9fa2295d8beaa680d91a8cbf69c2a4ee.js | 8 - 8 files changed, 105 insertions(+), 209 deletions(-) delete mode 100644 source/script/040e1c9f431bfc171244df659317c5f3.js delete mode 100644 source/script/4d3fe67365a3266b75047f38705d12e3.js delete mode 100644 source/script/9e569124280463491b2ea8ce15427e93.js delete mode 100644 source/script/9fa2295d8beaa680d91a8cbf69c2a4ee.js diff --git a/script/bilibili/bilibili_plus.js b/script/bilibili/bilibili_plus.js index 9f4d4b2e9..1aad2b4e9 100644 --- a/script/bilibili/bilibili_plus.js +++ b/script/bilibili/bilibili_plus.js @@ -1,109 +1,107 @@ -const scriptName = 'BiliBili'; -const storyAidKey = 'story_aid'; -let magicJS = MagicJS(scriptName, 'INFO'); -const blackKey = 'blackmatrix7_bilibili_feed_black'; +const scriptName = "BiliBili"; +const storyAidKey = "bilibili_story_aid"; +const blackKey = "bilibili_feed_black"; +let magicJS = MagicJS(scriptName, "INFO"); //Customize blacklist let blacklist = []; -if (magicJS.read(blackKey)){ - blacklist = magicJS.read(blackKey).split(';'); +if (magicJS.read(blackKey)) { + blacklist = magicJS.read(blackKey).split(";"); } else { - const defaultList = ''; + const defaultList = ""; magicJS.write(blackKey, defaultList); - blacklist = defaultList.split(';'); + blacklist = defaultList.split(";"); } -;(() => { +(() => { let body = null; - if (magicJS.isResponse){ - switch (true){ + if (magicJS.isResponse) { + switch (true) { // 推荐去广告,最后问号不能去掉,以免匹配到story模式 case /^https:\/\/app\.bilibili\.com\/x\/v2\/feed\/index\?/.test(magicJS.request.url): - try{ + try { let obj = JSON.parse(magicJS.response.body); let items = []; - for (let item of obj['data']['items'] ){ - if (item.hasOwnProperty('banner_item')){ + for (let item of obj["data"]["items"]) { + if (item.hasOwnProperty("banner_item")) { let bannerItems = []; - for (let banner of item['banner_item']){ - if (banner['is_ad'] != true && banner['is_ad_loc'] != true){ + for (let banner of item["banner_item"]) { + if (banner["is_ad"] != true && banner["is_ad_loc"] != true) { bannerItems.push(banner); } } // 去除广告后,如果banner大于等于1个才添加到响应体 - if (bannerItems.length >= 1){ - item['banner_item'] = bannerItems; + if (bannerItems.length >= 1) { + item["banner_item"] = bannerItems; items.push(item); } - } - else if ( - !item.hasOwnProperty('ad_info') && - !blacklist.includes(item['args']['up_name']) && - item.card_goto.indexOf('ad') === -1 && - (item['card_type'] === 'small_cover_v2' || item['card_type'] === 'large_cover_v1') - ){ + } else if ( + !item.hasOwnProperty("ad_info") && + !blacklist.includes(item["args"]["up_name"]) && + item.card_goto.indexOf("ad") === -1 && + (item["card_type"] === "small_cover_v2" || item["card_type"] === "large_cover_v1") + ) { items.push(item); } } - obj['data']['items'] = items; + obj["data"]["items"] = items; body = JSON.stringify(obj); - } - catch (err){ + } catch (err) { magicJS.logError(`推荐去广告出现异常:${err}`); } break; // 匹配story模式,用于记录Story的aid case /^https:\/\/app\.bilibili\.com\/x\/v2\/feed\/index\/story\?/.test(magicJS.request.url): - try{ + try { let obj = JSON.parse(magicJS.response.body); - let lastItem = obj['data']['items'].pop(); - let aid = lastItem['stat']['aid'].toString(); + let lastItem = obj["data"]["items"].pop(); + let aid = lastItem["stat"]["aid"].toString(); magicJS.write(storyAidKey, aid); - } - catch (err){ + } catch (err) { magicJS.logError(`记录Story的aid出现异常:${err}`); } break; // 开屏广告处理 case /^https?:\/\/app\.bilibili\.com\/x\/v2\/splash\/list/.test(magicJS.request.url): - try{ + try { let obj = JSON.parse(magicJS.response.body); - obj['data']['max_time'] = 0; - obj['data']['min_interval'] = 31536000; - obj['data']['pull_interval'] = 31536000; - for(let i=0;i{return tabList.has(e.id);}); - obj['data']['tab'] = tab; + if (obj["data"]["tab"]) { + let tab = obj["data"]["tab"].filter((e) => { + return tabList.has(e.id); + }); + obj["data"]["tab"] = tab; } // 将 id(222 & 107)调整为Story功能按钮 let storyAid = magicJS.read(storyAidKey); - if (!storyAid){ - storyAid = '246834163'; + if (!storyAid) { + storyAid = "246834163"; } - if (obj['data']['top']){ - let top = obj['data']['top'].filter((e) =>{ - if (e.id === 222 || e.id === 107){ + if (obj["data"]["top"]) { + let top = obj["data"]["top"].filter((e) => { + if (e.id === 222 || e.id === 107) { e.uri = `bilibili://story/${storyAid}`; e.icon = "https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/script/bilibili/bilibili_icon.png"; e.tab_id = "Story_Top"; @@ -111,112 +109,109 @@ if (magicJS.read(blackKey)){ } return topList.has(e.id); }); - obj['data']['top'] = top; + obj["data"]["top"] = top; } - if (obj['data']['bottom']){ - let bottom = obj['data']['bottom'].filter((e) =>{return bottomList.has(e.id);}); - obj['data']['bottom'] = bottom; + if (obj["data"]["bottom"]) { + let bottom = obj["data"]["bottom"].filter((e) => { + return bottomList.has(e.id); + }); + obj["data"]["bottom"] = bottom; } body = JSON.stringify(obj); - } - catch (err){ + } catch (err) { magicJS.logError(`标签页处理出现异常:${err}`); } break; // 我的页面处理,去除一些推广按钮 case /^https?:\/\/app\.bilibili\.com\/x\/v2\/account\/mine/.test(magicJS.request.url): - try{ + try { let obj = JSON.parse(magicJS.response.body); // 425 开始为概念版id - const itemList = new Set([396,397,398,399,171,172,534,8,4,428,352,1,405,402,404,544,407,410,425,426,427,428,171,430,431,432]); - obj['data']['sections_v2'].forEach((element, index) => { - let items = element['items'].filter((e) =>{return itemList.has(e.id);}); - obj['data']['sections_v2'][index].button = {} - delete obj['data']['sections_v2'][index].be_up_title; - delete obj['data']['sections_v2'][index].tip_icon; - delete obj['data']['sections_v2'][index].tip_title; - obj['data']['sections_v2'][index]['items'] = items; + const itemList = new Set([396, 397, 398, 399, 171, 172, 534, 8, 4, 428, 352, 1, 405, 402, 404, 544, 407, 410, 425, 426, 427, 428, 171, 430, 431, 432]); + obj["data"]["sections_v2"].forEach((element, index) => { + let items = element["items"].filter((e) => { + return itemList.has(e.id); + }); + obj["data"]["sections_v2"][index].button = {}; + delete obj["data"]["sections_v2"][index].be_up_title; + delete obj["data"]["sections_v2"][index].tip_icon; + delete obj["data"]["sections_v2"][index].tip_title; + obj["data"]["sections_v2"][index]["items"] = items; }); body = JSON.stringify(obj); - } - catch (err){ + } catch (err) { magicJS.logError(`我的页面处理出现异常:${err}`); } break; // 直播去广告 case /^https?:\/\/api\.live\.bilibili\.com\/xlive\/app-room\/v1\/index\/getInfoByRoom/.test(magicJS.request.url): - try{ + try { let obj = JSON.parse(magicJS.response.body); - obj['data']['activity_banner_info'] = null; + obj["data"]["activity_banner_info"] = null; body = JSON.stringify(obj); - } - catch (err){ + } catch (err) { magicJS.logError(`直播去广告出现异常:${err}`); } break; // 追番去广告 case /^https?:\/\/api\.bilibili\.com\/pgc\/page\/bangumi/.test(magicJS.request.url): - try{ + try { let obj = JSON.parse(magicJS.response.body); - for (let card of obj.data.cards){ - delete card['extra']; + for (let card of obj.data.cards) { + delete card["extra"]; } - delete obj['data']['attentions']; + delete obj["data"]["attentions"]; body = JSON.stringify(obj); - } - catch (err){ + } catch (err) { magicJS.logError(`追番去广告出现异常:${err}`); } break; // 动态去广告 case /^https?:\/\/api\.vc\.bilibili\.com\/dynamic_svr\/v1\/dynamic_svr\/dynamic_(history|new)\?/.test(magicJS.request.url): - try{ + try { let obj = JSON.parse(magicJS.response.body); let cards = []; - obj.data.cards.forEach(element => { - if (element.hasOwnProperty('display') && element.card.indexOf('ad_ctx') <= 0){ + obj.data.cards.forEach((element) => { + if (element.hasOwnProperty("display") && element.card.indexOf("ad_ctx") <= 0) { // 解决number类型精度问题导致B站动态中图片无法打开的问题 - element['desc']['dynamic_id'] = element['desc']['dynamic_id_str']; - element['desc']['pre_dy_id'] = element['desc']['pre_dy_id_str']; - element['desc']['orig_dy_id'] = element['desc']['orig_dy_id_str']; - element['desc']['rid'] = element['desc']['rid_str']; + element["desc"]["dynamic_id"] = element["desc"]["dynamic_id_str"]; + element["desc"]["pre_dy_id"] = element["desc"]["pre_dy_id_str"]; + element["desc"]["orig_dy_id"] = element["desc"]["orig_dy_id_str"]; + element["desc"]["rid"] = element["desc"]["rid_str"]; cards.push(element); } }); obj.data.cards = cards; body = JSON.stringify(obj); - } - catch (err){ + } catch (err) { magicJS.logError(`动态去广告出现异常:${err}`); } break; // 去除统一设置的皮肤 case /^https?:\/\/app\.bilibili\.com\/x\/resource\/show\/skin\?/.test(magicJS.request.url): - try{ + try { let obj = JSON.parse(magicJS.response.body); - if (obj && obj.hasOwnProperty('data')){ - obj['data']['common_equip'] = {}; + if (obj && obj.hasOwnProperty("data")) { + obj["data"]["common_equip"] = {}; } body = JSON.stringify(obj); - } - catch (err){ + } catch (err) { magicJS.logError(`去除强制设置的皮肤出现异常:${err}`); } break; default: - magicJS.logWarning('触发意外的请求处理,请确认脚本或复写配置正常。'); + magicJS.logWarning("触发意外的请求处理,请确认脚本或复写配置正常。"); break; } + } else { + magicJS.logWarning("触发意外的请求处理,请确认脚本或复写配置正常。"); } - else{ - magicJS.logWarning('触发意外的请求处理,请确认脚本或复写配置正常。'); - } - if (body){ - magicJS.done({body}); - } - else{ + if (body) { + magicJS.done({ body }); + } else { magicJS.done(); } })(); -function MagicJS(e="MagicJS",t="INFO"){const s={accept:"Accept","accept-ch":"Accept-CH","accept-charset":"Accept-Charset","accept-features":"Accept-Features","accept-encoding":"Accept-Encoding","accept-language":"Accept-Language","accept-ranges":"Accept-Ranges","access-control-allow-credentials":"Access-Control-Allow-Credentials","access-control-allow-origin":"Access-Control-Allow-Origin","access-control-allow-methods":"Access-Control-Allow-Methods","access-control-allow-headers":"Access-Control-Allow-Headers","access-control-max-age":"Access-Control-Max-Age","access-control-expose-headers":"Access-Control-Expose-Headers","access-control-request-method":"Access-Control-Request-Method","access-control-request-headers":"Access-Control-Request-Headers",age:"Age",allow:"Allow",alternates:"Alternates",authorization:"Authorization","cache-control":"Cache-Control",connection:"Connection","content-encoding":"Content-Encoding","content-language":"Content-Language","content-length":"Content-Length","content-location":"Content-Location","content-md5":"Content-MD5","content-range":"Content-Range","content-security-policy":"Content-Security-Policy","content-type":"Content-Type",cookie:"Cookie",dnt:"DNT",date:"Date",etag:"ETag",expect:"Expect",expires:"Expires",from:"From",host:"Host","if-match":"If-Match","if-modified-since":"If-Modified-Since","if-none-match":"If-None-Match","if-range":"If-Range","if-unmodified-since":"If-Unmodified-Since","last-event-id":"Last-Event-ID","last-modified":"Last-Modified",link:"Link",location:"Location","max-forwards":"Max-Forwards",negotiate:"Negotiate",origin:"Origin",pragma:"Pragma","proxy-authenticate":"Proxy-Authenticate","proxy-authorization":"Proxy-Authorization",range:"Range",referer:"Referer","retry-after":"Retry-After","sec-websocket-extensions":"Sec-Websocket-Extensions","sec-websocket-key":"Sec-Websocket-Key","sec-websocket-origin":"Sec-Websocket-Origin","sec-websocket-protocol":"Sec-Websocket-Protocol","sec-websocket-version":"Sec-Websocket-Version",server:"Server","set-cookie":"Set-Cookie","set-cookie2":"Set-Cookie2","strict-transport-security":"Strict-Transport-Security",tcn:"TCN",te:"TE",trailer:"Trailer","transfer-encoding":"Transfer-Encoding",upgrade:"Upgrade","user-agent":"User-Agent","variant-vary":"Variant-Vary",vary:"Vary",via:"Via",warning:"Warning","www-authenticate":"WWW-Authenticate","x-content-duration":"X-Content-Duration","x-content-security-policy":"X-Content-Security-Policy","x-dnsprefetch-control":"X-DNSPrefetch-Control","x-frame-options":"X-Frame-Options","x-requested-with":"X-Requested-With","x-surge-skip-scripting":"X-Surge-Skip-Scripting"};return new class{constructor(){this.version="2.2.3.3";this.scriptName=e;this.logLevels={DEBUG:5,INFO:4,NOTIFY:3,WARNING:2,ERROR:1,CRITICAL:0,NONE:-1};this.isLoon=typeof $loon!=="undefined";this.isQuanX=typeof $task!=="undefined";this.isJSBox=typeof $drive!=="undefined";this.isNode=typeof module!=="undefined"&&!this.isJSBox;this.isSurge=typeof $httpClient!=="undefined"&&!this.isLoon;this.platform=this.getPlatform();this.node={request:undefined,fs:undefined,data:{}};this.iOSUserAgent="Mozilla/5.0 (iPhone; CPU iPhone OS 13_3_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0.5 Mobile/15E148 Safari/604.1";this.pcUserAgent="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.125 Safari/537.36 Edg/84.0.522.59";this.logLevel=t;this._unifiedPushUrl="";if(this.isNode){this.node.fs=require("fs");this.node.request=require("request");try{this.node.fs.accessSync("./magic.json",this.node.fs.constants.R_OK|this.node.fs.constants.W_OK)}catch(e){this.node.fs.writeFileSync("./magic.json","{}",{encoding:"utf8"})}this.node.data=require("./magic.json")}else if(this.isJSBox){if(!$file.exists("drive://MagicJS")){$file.mkdir("drive://MagicJS")}if(!$file.exists("drive://MagicJS/magic.json")){$file.write({data:$data({string:"{}"}),path:"drive://MagicJS/magic.json"})}}}set unifiedPushUrl(e){this._unifiedPushUrl=!!e?e.replace(/\/+$/g,""):""}set logLevel(e){this._logLevel=typeof e==="string"?e.toUpperCase():"DEBUG"}get logLevel(){return this._logLevel}get isRequest(){return typeof $request!=="undefined"&&typeof $response==="undefined"}get isResponse(){return typeof $response!=="undefined"}get request(){return typeof $request!=="undefined"?$request:undefined}get response(){if(typeof $response!=="undefined"){if($response.hasOwnProperty("status"))$response["statusCode"]=$response["status"];if($response.hasOwnProperty("statusCode"))$response["status"]=$response["statusCode"];return $response}else{return undefined}}getPlatform(){if(this.isSurge)return"Surge";else if(this.isQuanX)return"QuantumultX";else if(this.isLoon)return"Loon";else if(this.isJSBox)return"JSBox";else if(this.isNode)return"Node.js";else return"unknown"}read(e,t=""){let s="";if(this.isSurge||this.isLoon){s=$persistentStore.read(e)}else if(this.isQuanX){s=$prefs.valueForKey(e)}else if(this.isNode){s=this.node.data}else if(this.isJSBox){s=$file.read("drive://MagicJS/magic.json").string}try{if(this.isNode)s=s[e];if(this.isJSBox)s=JSON.parse(s)[e];if(!!t){if(typeof s==="string")s=JSON.parse(s);s=!!s&&typeof s==="object"?s[t]:null}}catch(i){this.logError(i);s=!!t?{}:null;this.del(e)}if(typeof s==="undefined")s=null;try{if(!!s&&typeof s==="string")s=JSON.parse(s)}catch(e){}this.logDebug(`READ DATA [${e}]${!!t?`[${t}]`:""}(${typeof s})\n${JSON.stringify(s)}`);return s}write(e,t,s=""){let i=!!s?{}:"";if(!!s&&(this.isSurge||this.isLoon)){i=$persistentStore.read(e)}else if(!!s&&this.isQuanX){i=$prefs.valueForKey(e)}else if(this.isNode){i=this.node.data}else if(this.isJSBox){i=JSON.parse($file.read("drive://MagicJS/magic.json").string)}if(!!s){try{if(typeof i==="string")i=JSON.parse(i);i=typeof i==="object"&&!!i?i:{}}catch(t){this.logError(t);this.del(e);i={}}if(this.isJSBox||this.isNode){if(!i.hasOwnProperty(e)||typeof i[e]!=="object"||i[e]===null){i[e]={}}if(!i[e].hasOwnProperty(s)){i[e][s]=null}if(typeof t==="undefined"){delete i[e][s]}else{i[e][s]=t}}else{if(typeof t==="undefined"){delete i[s]}else{i[s]=t}}}else{if(this.isNode||this.isJSBox){if(typeof t==="undefined"){delete i[e]}else{i[e]=t}}else{if(typeof t==="undefined"){i=null}else{i=t}}}if(typeof i==="object")i=JSON.stringify(i);if(this.isSurge||this.isLoon){$persistentStore.write(i,e)}else if(this.isQuanX){$prefs.setValueForKey(i,e)}else if(this.isNode){this.node.fs.writeFileSync("./magic.json",i)}else if(this.isJSBox){$file.write({data:$data({string:i}),path:"drive://MagicJS/magic.json"})}this.logDebug(`WRITE DATA [${e}]${!!s?`[${s}]`:""}(${typeof t})\n${JSON.stringify(t)}`)}del(e,t=""){this.logDebug(`DELETE KEY [${e}]${!!t?`[${t}]`:""}`);this.write(e,null,t)}notify(e=this.scriptName,t="",s="",i=""){let o=e=>{let t={};if(this.isSurge||this.isQuanX||this.isLoon){if(typeof e==="string"){if(this.isLoon)t={openUrl:e};else if(this.isQuanX)t={"open-url":e};else if(this.isSurge)t={url:e}}else if(typeof e==="object"){let s={Surge:{openUrl:"url","open-url":"url"},Loon:{url:"openUrl","open-url":"openUrl","media-url":"mediaUrl"},QuantumultX:{url:"open-url",openUrl:"open-url",mediaUrl:"media-url"}};let i=Object.keys(e);for(let o=0;o{})}if(this.isSurge||this.isLoon){$notification.post(e,t,s,i)}else if(this.isQuanX){$notify(e,t,s,i)}else if(this.isJSBox){let i={title:e,body:!!t?`${t}\n${s}`:s};$push.schedule(i)}}log(e,t="INFO"){if(!(this.logLevels[this._logLevel]{if(typeof i.body==="undefined")return"";return`${encodeURIComponent(e)}=${encodeURIComponent(i.body[e])}`}).join("&");if(i.url.indexOf("?")<0)i.url+="?";if(i.url.lastIndexOf("&")+1!=i.url.length&&i.url.lastIndexOf("?")+1!=i.url.length)i.url+="&";i.url+=e;delete i.body}if(this.isQuanX){if(i.hasOwnProperty("body")&&typeof i["body"]!=="string")i["body"]=JSON.stringify(i["body"]);i["method"]=t}else if(this.isNode){delete i.headers["Accept-Encoding"];if(typeof i.body==="object"){if(t==="GET"){i.qs=i.body;delete i.body}else if(t==="POST"){i["json"]=true;i.body=i.body}}}else if(this.isJSBox){i["header"]=i["headers"];delete i["headers"]}return i}get(e,t){let s=this.adapterHttpOptions(e,"GET");this.logDebug(`HTTP GET: ${JSON.stringify(s)}`);if(this.isSurge||this.isLoon){$httpClient.get(s,t)}else if(this.isQuanX){$task.fetch(s).then(e=>{e["status"]=e.statusCode;t(null,e,e.body)},e=>t(e.error,null,null))}else if(this.isNode){return this.node.request.get(s,t)}else if(this.isJSBox){s["handler"]=(e=>{let s=e.error?JSON.stringify(e.error):undefined;let i=typeof e.data==="object"?JSON.stringify(e.data):e.data;t(s,e.response,i)});$http.get(s)}}post(e,t){let s=this.adapterHttpOptions(e,"POST");this.logDebug(`HTTP POST: ${JSON.stringify(s)}`);if(this.isSurge||this.isLoon){$httpClient.post(s,t)}else if(this.isQuanX){$task.fetch(s).then(e=>{e["status"]=e.statusCode;t(null,e,e.body)},e=>{t(e.error,null,null)})}else if(this.isNode){return this.node.request.post(s,t)}else if(this.isJSBox){s["handler"]=(e=>{let s=e.error?JSON.stringify(e.error):undefined;let i=typeof e.data==="object"?JSON.stringify(e.data):e.data;t(s,e.response,i)});$http.post(s)}}done(e={}){if(typeof $done!=="undefined"){$done(e)}}isToday(e){if(e==null){return false}else{let t=new Date;if(typeof e=="string"){e=new Date(e)}if(t.getFullYear()==e.getFullYear()&&t.getMonth()==e.getMonth()&&t.getDay()==e.getDay()){return true}else{return false}}}isNumber(e){return parseFloat(e).toString()==="NaN"?false:true}attempt(e,t=null){return e.then(e=>{return[null,e]}).catch(e=>{this.logError(e);return[e,t]})}retry(e,t=5,s=0,i=null){return(...o)=>{return new Promise((r,n)=>{function a(...o){Promise.resolve().then(()=>e.apply(this,o)).then(e=>{if(typeof i==="function"){Promise.resolve().then(()=>i(e)).then(()=>{r(e)}).catch(e=>{this.logError(e);if(t>=1&&s>0){setTimeout(()=>a.apply(this,o),s)}else if(t>=1){a.apply(this,o)}else{n(e)}t--})}else{r(e)}}).catch(e=>{this.logError(e);if(t>=1&&s>0){setTimeout(()=>a.apply(this,o),s)}else if(t>=1){a.apply(this,o)}else{n(e)}t--})}a.apply(this,o)})}}formatTime(e,t="yyyy-MM-dd hh:mm:ss"){var s={"M+":e.getMonth()+1,"d+":e.getDate(),"h+":e.getHours(),"m+":e.getMinutes(),"s+":e.getSeconds(),"q+":Math.floor((e.getMonth()+3)/3),S:e.getMilliseconds()};if(/(y+)/.test(t))t=t.replace(RegExp.$1,(e.getFullYear()+"").substr(4-RegExp.$1.length));for(let e in s)if(new RegExp("("+e+")").test(t))t=t.replace(RegExp.$1,RegExp.$1.length==1?s[e]:("00"+s[e]).substr((""+s[e]).length));return t}now(){return this.formatTime(new Date,"yyyy-MM-dd hh:mm:ss")}today(){return this.formatTime(new Date,"yyyy-MM-dd")}sleep(e){return new Promise(t=>setTimeout(t,e))}}(e)} +// prettier-ignore +function MagicJS(scriptName="MagicJS",logLevel="INFO"){return new class{constructor(){if(this.version="2.2.3.3",this.scriptName=scriptName,this.logLevels={DEBUG:5,INFO:4,NOTIFY:3,WARNING:2,ERROR:1,CRITICAL:0,NONE:-1},this.isLoon="undefined"!=typeof $loon,this.isQuanX="undefined"!=typeof $task,this.isJSBox="undefined"!=typeof $drive,this.isNode="undefined"!=typeof module&&!this.isJSBox,this.isSurge="undefined"!=typeof $httpClient&&!this.isLoon,this.node={request:void 0,fs:void 0,data:{}},this.iOSUserAgent="Mozilla/5.0 (iPhone; CPU iPhone OS 13_3_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0.5 Mobile/15E148 Safari/604.1",this.pcUserAgent="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.125 Safari/537.36 Edg/84.0.522.59",this.logLevel=logLevel,this._barkUrl="",this.isNode){this.node.fs=require("fs"),this.node.request=require("request");try{this.node.fs.accessSync("./magic.json",this.node.fs.constants.R_OK|this.node.fs.constants.W_OK)}catch(err){this.node.fs.writeFileSync("./magic.json","{}",{encoding:"utf8"})}this.node.data=require("./magic.json")}else this.isJSBox&&($file.exists("drive://MagicJS")||$file.mkdir("drive://MagicJS"),$file.exists("drive://MagicJS/magic.json")||$file.write({data:$data({string:"{}"}),path:"drive://MagicJS/magic.json"}))}set barkUrl(url){this._barkUrl=url.replace(/\/+$/g,"")}set logLevel(level){this._logLevel="string"==typeof level?level.toUpperCase():"DEBUG"}get logLevel(){return this._logLevel}get isRequest(){return"undefined"!=typeof $request&&"undefined"==typeof $response}get isResponse(){return"undefined"!=typeof $response}get request(){return"undefined"!=typeof $request?$request:void 0}get response(){return"undefined"!=typeof $response?($response.hasOwnProperty("status")&&($response.statusCode=$response.status),$response.hasOwnProperty("statusCode")&&($response.status=$response.statusCode),$response):void 0}get platform(){return this.isSurge?"Surge":this.isQuanX?"Quantumult X":this.isLoon?"Loon":this.isJSBox?"JSBox":this.isNode?"Node.js":"Unknown"}read(key,session=""){let val="";this.isSurge||this.isLoon?val=$persistentStore.read(key):this.isQuanX?val=$prefs.valueForKey(key):this.isNode?val=this.node.data:this.isJSBox&&(val=$file.read("drive://MagicJS/magic.json").string);try{this.isNode&&(val=val[key]),this.isJSBox&&(val=JSON.parse(val)[key]),session&&("string"==typeof val&&(val=JSON.parse(val)),val=val&&"object"==typeof val?val[session]:null)}catch(err){this.logError(err),val=session?{}:null,this.del(key)}void 0===val&&(val=null);try{val&&"string"==typeof val&&(val=JSON.parse(val))}catch(err){}return this.logDebug(`READ DATA [${key}]${session?`[${session}]`:""}(${typeof val})\n${JSON.stringify(val)}`),val}write(key,val,session=""){let data=session?{}:"";if(session&&(this.isSurge||this.isLoon)?data=$persistentStore.read(key):session&&this.isQuanX?data=$prefs.valueForKey(key):this.isNode?data=this.node.data:this.isJSBox&&(data=JSON.parse($file.read("drive://MagicJS/magic.json").string)),session){try{"string"==typeof data&&(data=JSON.parse(data)),data="object"==typeof data&&data?data:{}}catch(err){this.logError(err),this.del(key),data={}}this.isJSBox||this.isNode?(data[key]&&"object"==typeof data[key]||(data[key]={}),data[key].hasOwnProperty(session)||(data[key][session]=null),void 0===val?delete data[key][session]:data[key][session]=val):void 0===val?delete data[session]:data[session]=val}else this.isNode||this.isJSBox?void 0===val?delete data[key]:data[key]=val:data=void 0===val?null:val;"object"==typeof data&&(data=JSON.stringify(data)),this.isSurge||this.isLoon?$persistentStore.write(data,key):this.isQuanX?$prefs.setValueForKey(data,key):this.isNode?this.node.fs.writeFileSync("./magic.json",data):this.isJSBox&&$file.write({data:$data({string:data}),path:"drive://MagicJS/magic.json"}),this.logDebug(`WRITE DATA [${key}]${session?`[${session}]`:""}(${typeof val})\n${JSON.stringify(val)}`)}del(key,session=""){this.logDebug(`DELETE KEY [${key}]${session?`[${session}]`:""}`),this.write(key,null,session)}notify(title=this.scriptName,subTitle="",body="",opts=""){let convertOptions;if(opts=(_opts=>{let newOpts={};if("string"==typeof _opts)this.isLoon?newOpts={openUrl:_opts}:this.isQuanX?newOpts={"open-url":_opts}:this.isSurge&&(newOpts={url:_opts});else if("object"==typeof _opts)if(this.isLoon)newOpts.openUrl=_opts["open-url"]?_opts["open-url"]:"",newOpts.mediaUrl=_opts["media-url"]?_opts["media-url"]:"";else if(this.isQuanX)newOpts=_opts["open-url"]||_opts["media-url"]?_opts:{};else if(this.isSurge){let openUrl=_opts["open-url"]||_opts.openUrl;newOpts=openUrl?{url:openUrl}:{}}return newOpts})(opts),1==arguments.length&&(title=this.scriptName,subTitle="",body=arguments[0]),this.logNotify(`title:${title}\nsubTitle:${subTitle}\nbody:${body}\noptions:${"object"==typeof opts?JSON.stringify(opts):opts}`),this.isSurge)$notification.post(title,subTitle,body,opts);else if(this.isLoon)opts?$notification.post(title,subTitle,body,opts):$notification.post(title,subTitle,body);else if(this.isQuanX)$notify(title,subTitle,body,opts);else if(this.isNode){if(this._barkUrl){let content=encodeURI(`${title}/${subTitle}\n${body}`);this.get(`${this._barkUrl}/${content}`,()=>{})}}else if(this.isJSBox){let push={title:title,body:subTitle?`${subTitle}\n${body}`:body};$push.schedule(push)}}notifyDebug(title=this.scriptName,subTitle="",body="",opts=""){"DEBUG"===this.logLevel&&(1==arguments.length&&(title=this.scriptName,subTitle="",body=arguments[0]),this.notify(title,subTitle,body,opts))}log(msg,level="INFO"){this.logLevels[this._logLevel]void 0===_options.body?"":`${encodeURIComponent(key)}=${encodeURIComponent(_options.body[key])}`).join("&");_options.url.indexOf("?")<0&&(_options.url+="?"),_options.url.lastIndexOf("&")+1!=_options.url.length&&_options.url.lastIndexOf("?")+1!=_options.url.length&&(_options.url+="&"),_options.url+=qs,delete _options.body}return this.isQuanX?(_options.hasOwnProperty("body")&&"string"!=typeof _options.body&&(_options.body=JSON.stringify(_options.body)),_options.method=method):this.isNode?(delete _options.headers["Accept-Encoding"],"object"==typeof _options.body&&("GET"===method?(_options.qs=_options.body,delete _options.body):"POST"===method&&(_options.json=!0,_options.body=_options.body))):this.isJSBox&&(_options.header=_options.headers,delete _options.headers),_options}adapterHttpResponse(resp){let _resp={body:resp.body,headers:resp.headers,json:()=>JSON.parse(_resp.body)};return resp.hasOwnProperty("statusCode")&&resp.statusCode&&(_resp.status=resp.statusCode),_resp}get(options,callback){let _options=this.adapterHttpOptions(options,"GET");this.logDebug(`HTTP GET: ${JSON.stringify(_options)}`),this.isSurge||this.isLoon?$httpClient.get(_options,callback):this.isQuanX?$task.fetch(_options).then(resp=>{resp.status=resp.statusCode,callback(null,resp,resp.body)},reason=>callback(reason.error,null,null)):this.isNode?this.node.request.get(_options,(err,resp,data)=>{resp=this.adapterHttpResponse(resp),callback(err,resp,data)}):this.isJSBox&&(_options.handler=resp=>{let err=resp.error?JSON.stringify(resp.error):void 0,data="object"==typeof resp.data?JSON.stringify(resp.data):resp.data;callback(err,resp.response,data)},$http.get(_options))}getPromise(options){return new Promise((resolve,reject)=>{magicJS.get(options,(err,resp)=>{err?reject(err):resolve(resp)})})}post(options,callback){let _options=this.adapterHttpOptions(options,"POST");if(this.logDebug(`HTTP POST: ${JSON.stringify(_options)}`),this.isSurge||this.isLoon)$httpClient.post(_options,callback);else if(this.isQuanX)$task.fetch(_options).then(resp=>{resp.status=resp.statusCode,callback(null,resp,resp.body)},reason=>{callback(reason.error,null,null)});else if(this.isNode){let resp=this.node.request.post(_options,callback);resp.status=resp.statusCode,delete resp.statusCode}else this.isJSBox&&(_options.handler=resp=>{let err=resp.error?JSON.stringify(resp.error):void 0,data="object"==typeof resp.data?JSON.stringify(resp.data):resp.data;callback(err,resp.response,data)},$http.post(_options))}get http(){return{get:this.getPromise,post:this.post}}done(value={}){"undefined"!=typeof $done&&$done(value)}isToday(day){if(null==day)return!1;{let today=new Date;return"string"==typeof day&&(day=new Date(day)),today.getFullYear()==day.getFullYear()&&today.getMonth()==day.getMonth()&&today.getDay()==day.getDay()}}isNumber(val){return"NaN"!==parseFloat(val).toString()}attempt(promise,defaultValue=null){return promise.then(args=>[null,args]).catch(ex=>(this.logError(ex),[ex,defaultValue]))}retry(fn,retries=5,interval=0,callback=null){return(...args)=>new Promise((resolve,reject)=>{function _retry(...args){Promise.resolve().then(()=>fn.apply(this,args)).then(result=>{"function"==typeof callback?Promise.resolve().then(()=>callback(result)).then(()=>{resolve(result)}).catch(ex=>{retries>=1?interval>0?setTimeout(()=>_retry.apply(this,args),interval):_retry.apply(this,args):reject(ex),retries--}):resolve(result)}).catch(ex=>{this.logRetry(ex),retries>=1&&interval>0?setTimeout(()=>_retry.apply(this,args),interval):retries>=1?_retry.apply(this,args):reject(ex),retries--})}_retry.apply(this,args)})}formatTime(time,fmt="yyyy-MM-dd hh:mm:ss"){var o={"M+":time.getMonth()+1,"d+":time.getDate(),"h+":time.getHours(),"m+":time.getMinutes(),"s+":time.getSeconds(),"q+":Math.floor((time.getMonth()+3)/3),S:time.getMilliseconds()};/(y+)/.test(fmt)&&(fmt=fmt.replace(RegExp.$1,(time.getFullYear()+"").substr(4-RegExp.$1.length)));for(let k in o)new RegExp("("+k+")").test(fmt)&&(fmt=fmt.replace(RegExp.$1,1==RegExp.$1.length?o[k]:("00"+o[k]).substr((""+o[k]).length)));return fmt}now(){return this.formatTime(new Date,"yyyy-MM-dd hh:mm:ss")}today(){return this.formatTime(new Date,"yyyy-MM-dd")}sleep(time){return new Promise(resolve=>setTimeout(resolve,time))}}(scriptName)} diff --git a/script/boxjs.json b/script/boxjs.json index c241a21e2..373076ff1 100644 --- a/script/boxjs.json +++ b/script/boxjs.json @@ -20,10 +20,10 @@ { "id": "blackmatrix7.bilibili", "name": "哔哩哔哩去广告", - "keys": ["story_aid", "blackmatrix7_bilibili_feed_black"], + "keys": ["bilibili_story_aid", "bilibili_feed_black"], "settings": [ { - "id": "blackmatrix7_bilibili_feed_black", + "id": "bilibili_feed_black", "name": "首页UP主黑名单", "val": "", "type": "textarea", @@ -108,7 +108,7 @@ { "id": "blackmatrix7.famijia", "name": "Fa米家", - "keys": ["famijia_checkin_cookie", "famijia_device_id_cookie", "famijia_black_box"], + "keys": ["famijia_checkin_cookie", "famijia_device_id", "famijia_black_box"], "author": "@blackmatrix7", "repo": "https://github.com/blackmatrix7/ios_rule_script/tree/master/script/famijia", "icons": [ @@ -184,7 +184,7 @@ { "id": "blackmatrix7.tieba", "name": "百度贴吧", - "keys": ["tieba_cookie_key"], + "keys": ["tieba_checkin_cookie"], "author": "@blackmatrix7", "repo": "https://github.com/blackmatrix7/ios_rule_script/tree/master/script/tieba", "icons": [ @@ -205,18 +205,6 @@ ], "script": "https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/script/wanda/wanda_checkin.js" }, - { - "id": "blackmatrix7.youpin", - "name": "小米有品", - "keys": ["youpin_checkin_cookie"], - "author": "@blackmatrix7", - "repo": "https://github.com/blackmatrix7/ios_rule_script/tree/master/script/youpin", - "icons": [ - "https://raw.githubusercontent.com/Orz-3/mini/master/Alpha/xiaomiyp.png", - "https://raw.githubusercontent.com/Orz-3/mini/master/Color/xiaomiyp.png" - ], - "script": "https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/script/youpin/youpin_checkin.js" - }, { "id": "blackmatrix7.zhihu", "name": "知乎助手", diff --git a/script/tieba/tieba_checkin.js b/script/tieba/tieba_checkin.js index 41ba6fbc9..f34157c96 100644 --- a/script/tieba/tieba_checkin.js +++ b/script/tieba/tieba_checkin.js @@ -6,7 +6,7 @@ const scirptName = '百度贴吧'; const batchSize = 20; const retries = 5; // 签到失败重试次数 const interval = 2000; // 每次重试间隔 -const tiebaCookieKey = 'tieba_cookie_key'; +const tiebaCookieKey = 'tieba_checkin_cookie'; const tiebeGetCookieRegex = /https?:\/\/c\.tieba\.baidu\.com\/c\/s\/login/; let magicJS = MagicJS(scirptName, "INFO"); magicJS.unifiedPushUrl = magicJS.read('tieba_unified_push_url') || magicJS.read('magicjs_unified_push_url'); diff --git a/source/README.md b/source/README.md index 0788d06b7..853928b74 100644 --- a/source/README.md +++ b/source/README.md @@ -1,3 +1,3 @@ # 数据源 -本目录下所有文件仅作爬虫程序数据源使用,请勿直接引用本目录下的任何文件。 \ No newline at end of file +本目录下所有文件仅为程序生成规则使用,请勿直接引用任何文件。 \ No newline at end of file diff --git a/source/script/040e1c9f431bfc171244df659317c5f3.js b/source/script/040e1c9f431bfc171244df659317c5f3.js deleted file mode 100644 index 94f8567fd..000000000 --- a/source/script/040e1c9f431bfc171244df659317c5f3.js +++ /dev/null @@ -1,13 +0,0 @@ -/* -利用 GitHub Education 解锁 Working Copy - -启用此脚本后再 Safari 打开 https://workingcopy.app/education/ 点击「tap here to access all pro features.」中的 here 跳转到 Working Copy,登录自己的 GitHub 账号即可解锁 - -http-response ^https:\/\/education\.github\.com\/api\/user$ requires-body=1,max-size=0,script-path=scripts/WorkingCopy.js - -MitM = education.github.com - -作者 @ImSingee,请勿外传 -*/ - -$done({body: '{"student": true}'}) \ No newline at end of file diff --git a/source/script/4d3fe67365a3266b75047f38705d12e3.js b/source/script/4d3fe67365a3266b75047f38705d12e3.js deleted file mode 100644 index ca38bd516..000000000 --- a/source/script/4d3fe67365a3266b75047f38705d12e3.js +++ /dev/null @@ -1,23 +0,0 @@ -var body = $response.body; -var url = $request.url; - -const path1 = '/api/subscriptions/2.1/user-subscriptions/'; - -let obj = JSON.parse(body); - -if (url.indexOf(path1) != -1) { - obj.user_subscription["expires_on_sec"] = 1655536094; - obj.user_subscription["expired"] = false; - obj.user_subscription["payment_type"] = 2; - obj.user_subscription["is_trial_period"] = true; - obj.user_subscription["starts_on_sec"] = 1560831070; - obj.user_subscription["is_active"] = true; - obj.user_subscription["auto_renew"] = true; - obj.user_subscription["last_verified_sec"] = 1560831070; - obj.user_subscription["subscription_code"] = "VSCOANNUAL"; - obj.user_subscription["user_id"] = 54624336; - obj.user_subscription["source"] = 1; - body = JSON.stringify(obj); - } - -$done({body}); diff --git a/source/script/9e569124280463491b2ea8ce15427e93.js b/source/script/9e569124280463491b2ea8ce15427e93.js deleted file mode 100644 index 8405172b6..000000000 --- a/source/script/9e569124280463491b2ea8ce15427e93.js +++ /dev/null @@ -1,43 +0,0 @@ -/* -克拉壁纸解锁付费壁纸 - -Surge4: -http-response ^https:\/\/claritywallpaper\.com\/clarity\/api\/(userInfo|special\/queryByCatalogAll) requires-body=1,max-size=262144,script-path=resources/js/clarity.js -QX: -^https:\/\/claritywallpaper\.com\/clarity\/api\/(userInfo|special\/queryByCatalogAll) url script-response-body clarity.js - -Surge & QX MITM = claritywallpaper.com -*/ -/* -克拉壁纸解锁付费壁纸 - -Surge4: -http-response ^https:\/\/claritywallpaper\.com\/clarity\/api\/(userInfo|special\/queryByCatalogAll) requires-body=1,max-size=262144,script-path=resources/js/clarity.js -QX: -^https:\/\/claritywallpaper\.com\/clarity\/api\/(userInfo|special\/queryByCatalogAll) url script-response-body clarity.js - -Surge & QX MITM = claritywallpaper.com -*/ - -var body = $response.body; -var url = $request.url; -var obj = JSON.parse(body); - -const userinfo = '/userInfo'; - -const setfree = '/special/queryByCatalogAll'; - -if (url.indexOf(setfree) != -1) { - for (var i = 0; i < obj.data.length; i++) { - obj.data[i].isFree = true; - } - body = JSON.stringify(obj); -} - -if (url.indexOf(userinfo) != -1) { - obj.data.level = 5; - obj.data.expireTime = 4070965662; - body = JSON.stringify(obj); -} - -$done({body}); \ No newline at end of file diff --git a/source/script/9fa2295d8beaa680d91a8cbf69c2a4ee.js b/source/script/9fa2295d8beaa680d91a8cbf69c2a4ee.js deleted file mode 100644 index 09975db39..000000000 --- a/source/script/9fa2295d8beaa680d91a8cbf69c2a4ee.js +++ /dev/null @@ -1,8 +0,0 @@ -/* -不背单词解锁装备 @Ljm666888 -https://sapi.beingfine.cn/v3/report/launch/ -不背单词解锁装备 = type=http-response,pattern=^https:\/\/sapi\.beingfine\.cn\/v3\/report\/launch\/,requires-body=1,max-size=0,script-path=bubei.js, -*/ -let obj = JSON.parse($response.body); -obj.data_body = obj.data_body.replace(/expire_date":\d+/g, 'expire_date":1884436316000').replace(/granted":\d+/g, 'granted":1').replace(/user_type":\d+/g, 'user_type":3').replace(/collins_user_type":\d+/g, 'collins_user_type":3'); -$done({body: JSON.stringify(obj)}); \ No newline at end of file