From 8678d668b517fc23932ade33cee5be5902fca20a Mon Sep 17 00:00:00 2001 From: blackmatrix7 <27717518+blackmatrix7@users.noreply.github.com> Date: Sat, 11 Feb 2023 10:59:16 +0800 Subject: [PATCH] =?UTF-8?q?[=E5=BC=80=E5=B1=8F]=20=E5=8E=BB=E9=99=A4?= =?UTF-8?q?=E7=88=B1=E5=A5=87=E8=89=BA=E5=BC=80=E5=B1=8F=E5=B9=BF=E5=91=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- script/startup/README.md | 39 ++--- script/startup/startup.js | 153 ++++++++++++++---- script/startup/startup.lnplugin | 16 +- script/startup/startup.sgmodule | 11 +- .../{startup.qxrewrite => startup.snippet} | 8 +- script/startup/startup.stoverride | 104 ++++++++++++ 6 files changed, 271 insertions(+), 60 deletions(-) rename script/startup/{startup.qxrewrite => startup.snippet} (68%) create mode 100644 script/startup/startup.stoverride diff --git a/script/startup/README.md b/script/startup/README.md index eaf4f5482ef..25deb392a19 100644 --- a/script/startup/README.md +++ b/script/startup/README.md @@ -2,34 +2,35 @@ 使用脚本,通过修改开屏广告图片大小、开屏广告持续时间、开屏广告生效时间等方法,去除缓存到本地的APP开屏广告。 -维护去广告项目耗费的精力要远高于维护签到项目,所以当前仅能满足个人常用APP的开屏广告去除,并且不保证去除效果。 - -实在是精力有限,暂时无法帮忙去除其他APP开屏广告,欢迎大佬贡献其他去除开屏广告的代码。 +目前精力有限,仅能满足个人常用APP的开屏广告去除,并且不保证去除效果。 ## 配置说明 -大部分去广告的链接,都已经被整合型的去广告脚本拦截,脚本无法接管请求。如果出现拦截失败,请抓包检查相关请求是不是在脚本处理前就已经被拦截。 +大部分去广告的链接,都已经被整合型的去广告脚本拦截,脚本无法接管请求。 -### Surge +如果出现拦截失败,请抓包检查相关请求是不是在脚本处理前就已经被拦截。 -使用模块 +## 模块 +```ini https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/script/startup/startup.sgmodule - -### Loon - -使用远程脚本配置 - -```ini -[Plugin] -https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/script/startup/startup.lnplugin, tag=开屏去广告, enabled=true ``` -### Quantumult X - -配置文件 +## 插件 ```ini -[rewrite_remote] -https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/script/startup/startup.qxrewrite, tag=开屏去广告, enabled=true +https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/script/startup/startup.lnplugin ``` + +## 重写 + +```ini +https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/script/startup/startup.snippet +``` + +## 覆写 + +```ini +https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/script/startup/startup.stoverride +``` + diff --git a/script/startup/startup.js b/script/startup/startup.js index 8073b166ddc..673c6b861dd 100644 --- a/script/startup/startup.js +++ b/script/startup/startup.js @@ -1,15 +1,59 @@ const scriptName = "去除APP启动广告"; -let magicJS = MagicJS(scriptName, "INFO"); +const $ = MagicJS(scriptName, "INFO"); (() => { let response = null; - if (magicJS.isResponse) { + if ($.isResponse) { switch (true) { - // 嘀嗒出行 - case /^https?:\/\/capis(-?\w*)?\.didapinche\.com\/ad\/cx\/startup\?/.test(magicJS.request.url): + // 爱奇艺 + case /^https?:\/\/\w*\.cupid\.iqiyi\.com\/mixer\?/.test($.request.url): try { - let obj = JSON.parse(magicJS.response.body); - if (obj.hasOwnProperty("startupPages") == true) { + let obj = JSON.parse($.response.body); + delete obj["adSlots"]; + response = { body: JSON.stringify(obj) }; + } catch (err) { + $.logger.error(`爱奇艺开屏去广告出现异常:${err}`); + } + break; + // BiliBili + case /^https?:\/\/app\.bilibili\.com\/x\/v2\/splash\/list/.test($.request.url): + try { + let obj = JSON.parse($.response.body); + obj["data"]["max_time"] = 0; + obj["data"]["min_interval"] = 31536000; + obj["data"]["pull_interval"] = 31536000; + // for (let i = 0; i < obj["data"]["show"].length; i++) { + // obj["data"]["show"][i]["begin_time"] = 1915027200; + // obj["data"]["show"][i]["end_time"] = 1924272000; + // } + obj["data"]["list"]["show"] = []; + for (let i = 0; i < obj["data"]["list"].length; i++) { + obj["data"]["list"][i]["duration"] = 0; + obj["data"]["list"][i]["begin_time"] = 1915027200; + obj["data"]["list"][i]["end_time"] = 1924272000; + } + body = JSON.stringify(obj); + } catch (err) { + $.logger.error(`BiliBili开屏去广告出现异常:${err}`); + } + break; + // Fa米家 + case /^https?:\/\/fmapp\.chinafamilymart\.com\.cn\/api\/app\/market\/start\/ad/.test($.request.url): + try { + let obj = JSON.parse($.response.body); + if (obj.code === "200") { + obj.data.relayDisplayUrl = ""; + } + obj.data = {}; + response = { body: JSON.stringify(obj) }; + } catch (err) { + $.logger.error(`Fa米家开屏去广告出现异常:${err}`); + } + // 嘀嗒出行 + case /^https?:\/\/capis(-?\w*)?\.didapinche\.com\/ad\/cx\/startup\?/.test($.request.url): + try { + let obj = JSON.parse($.response.body); + if (obj.hasOwnProperty("startupPages") === true) { obj.show_time = 1; obj.full_screen = 0; let startupPages = []; @@ -17,30 +61,38 @@ let magicJS = MagicJS(scriptName, "INFO"); element["width"] = 1; element["height"] = 1; element["page_url"] = "#"; + element["create_time"] = "20990101000000"; + element["start_time"] = "20990101000000"; + element["end_time"] = "20990101000000"; startupPages.push(element); }); obj.startupPages = startupPages; response = { body: JSON.stringify(obj) }; } } catch (err) { - magicJS.logError(`嘀嗒出行开屏去广告出现异常:${err}`); + $.logger.error(`嘀嗒出行开屏去广告出现异常:${err}`); } break; // 美团外卖 - case /^https?:\/\/wmapi\.meituan\.com\/api\/v\d+\/loadInfo?/.test(magicJS.request.url): + case /^https?:\/\/wmapi\.meituan\.com\/api\/v\d+\/loadInfo?/.test($.request.url): try { - let obj = JSON.parse(magicJS.response.body); - obj.data.startpicture.ad = []; - obj.data.startpicture.mk = []; + let obj = JSON.parse($.response.body); + if (obj.data.startpicture.hasOwnProperty("ad")) { + obj.data.startpicture.ad = []; + } else if (obj.data.startpicture.hasOwnProperty("mk")) { + obj.data.startpicture.mk = []; + } else { + obj.data.startpicture = []; + } response = { body: JSON.stringify(obj) }; } catch (err) { - magicJS.logError(`美团外卖开屏去广告出现异常:${err}`); + $.logger.error(`美团外卖开屏去广告出现异常:${err}`); } break; // 小爱音箱 - case /^https?:\/\/hd\.mina\.mi\.com\/splashscreen\/alert/.test(magicJS.request.url): + case /^https?:\/\/hd\.mina\.mi\.com\/splashscreen\/alert/.test($.request.url): try { - let obj = JSON.parse(magicJS.response.body); + let obj = JSON.parse($.response.body); let data = []; for (let i = 0; i < obj.data.length; i++) { let ad = obj.data[i]; @@ -53,13 +105,13 @@ let magicJS = MagicJS(scriptName, "INFO"); obj.data = data; response = { body: JSON.stringify(obj) }; } catch (err) { - magicJS.logError(`小爱音箱开屏去广告出现异常:${err}`); + $.logger.error(`小爱音箱开屏去广告出现异常:${err}`); } break; // 京东 - case /^https?:\/\/api\.m\.jd\.com\/client\.action\?functionId=start/.test(magicJS.request.url): + case /^https?:\/\/api\.m\.jd\.com\/client\.action\?functionId=start/.test($.request.url): try { - let obj = JSON.parse(magicJS.response.body); + let obj = JSON.parse($.response.body); for (let i = 0; i < obj.images.length; i++) { for (let j = 0; j < obj.images[i].length; j++) { if (obj.images[i][j].showTimes) { @@ -74,48 +126,89 @@ let magicJS = MagicJS(scriptName, "INFO"); obj.showTimesDaily = 0; response = { body: JSON.stringify(obj) }; } catch (err) { - magicJS.logError(`京东开屏去广告出现异常:${err}`); + $.logger.error(`京东开屏去广告出现异常:${err}`); } break; // 联享家 - case /^https?:\/\/mi\.gdt\.qq\.com\/gdt_mview.fcg/.test(magicJS.request.url): + case /^https?:\/\/mi\.gdt\.qq\.com\/gdt_mview.fcg/.test($.request.url): try { - let obj = JSON.parse(magicJS.response.body); + let obj = JSON.parse($.response.body); obj.seq = "0"; obj.reqinterval = 0; - delete obj.last_ads; + delete obj["last_ads"]; delete obj.data; response = { body: JSON.stringify(obj) }; } catch (err) { - magicJS.logError(`联享家开屏去广告出现异常:${err}`); + $.logger.error(`联享家开屏去广告出现异常:${err}`); } break; // 多点 - case /^https?:\/\/cmsapi\.dmall\.com\/app\/home\/homepageStartUpPic/.test(magicJS.request.url): + case /^https?:\/\/cmsapi\.dmall\.com\/app\/home\/homepageStartUpPic/.test($.request.url): try { - let obj = JSON.parse(magicJS.response.body); + let obj = JSON.parse($.response.body); for (let i = 0; i < obj["data"]["welcomePage"].length; i++) { obj["data"]["welcomePage"][i]["onlineTime"] = 1915027200000; obj["data"]["welcomePage"][i]["offlineTime"] = 1924272000000; } response = { body: JSON.stringify(obj) }; } catch (err) { - magicJS.logError(`多点开屏广告处理出现异常:${err}`); + $.logger.error(`多点开屏广告处理出现异常:${err}`); + } + break; + // 轻牛健康 + case /^https?:\/\/gw\.yolanda\.hk\/api\/servlets\?endpoint=banners\/show_launch_banner/.test($.request.url): + try { + let obj = { + "code": "200", + "msg": "ok", + "data": { + "present_flag": 1, + "banner": { + "banner_id": "1861064161258799417", + "image": "http://qnplus-banner.glb.qnniu.com/banner_1636700135", + "image_type": 1, + "jump_link": "https://app-h5.yolanda.hk/redirect_center.html?type=fascia_gun", + "jump_type": 1, + "duration": 5, + "frequency": 1, + "updated_at": 1638157314 + } + } + } + response = { body: JSON.stringify(obj) }; + } catch (err) { + $.logger.error(`轻牛健康开屏广告处理出现异常:${err}`); } break; default: - magicJS.logWarning("触发意外的请求处理,请确认脚本或复写配置正常。"); + $.logger.warning(`触发意外的请求处理,请确认脚本或复写配置正常。URL:\n${$.request.url}`); break; } } else { - magicJS.logWarning("触发意外的请求处理,请确认脚本或复写配置正常。"); + $.logger.warning(`触发意外的请求处理,请确认脚本或复写配置正常。URL:\n${$.request.url}`); } if (response) { - magicJS.done(response); + $.done(response); } else { - magicJS.done(); + $.done(); } })(); // prettier-ignore -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"){const MagicEnvironment=()=>{const isLoon=typeof $loon!=="undefined";const isQuanX=typeof $task!=="undefined";const isNode=typeof module!=="undefined";const isSurge=typeof $httpClient!=="undefined"&&!isLoon;const isStorm=typeof $storm!=="undefined";const isStash=typeof $environment!=="undefined"&&typeof $environment["stash-build"]!=="undefined";const isSurgeLike=isSurge||isLoon||isStorm||isStash;const isScriptable=typeof importModule!=="undefined";return{isLoon:isLoon,isQuanX:isQuanX,isNode:isNode,isSurge:isSurge,isStorm:isStorm,isStash:isStash,isSurgeLike:isSurgeLike,isScriptable:isScriptable,get name(){if(isLoon){return"Loon"}else if(isQuanX){return"QuantumultX"}else if(isNode){return"NodeJS"}else if(isSurge){return"Surge"}else if(isScriptable){return"Scriptable"}else{return"unknown"}},get build(){if(isSurge){return $environment["surge-build"]}else if(isStash){return $environment["stash-build"]}else if(isStorm){return $storm.buildVersion}},get language(){if(isSurge||isStash){return $environment["language"]}},get version(){if(isSurge){return $environment["surge-version"]}else if(isStash){return $environment["stash-version"]}else if(isStorm){return $storm.appVersion}else if(isNode){return process.version}},get system(){if(isSurge){return $environment["system"]}else if(isNode){return process.platform}},get systemVersion(){if(isStorm){return $storm.systemVersion}},get deviceName(){if(isStorm){return $storm.deviceName}}}};const MagicLogger=(scriptName,logLevel="INFO")=>{let _level=logLevel;const logLevels={SNIFFER:6,DEBUG:5,INFO:4,NOTIFY:3,WARNING:2,ERROR:1,CRITICAL:0,NONE:-1};const logEmoji={SNIFFER:"",DEBUG:"",INFO:"",NOTIFY:"",WARNING:"❗ ",ERROR:"❌ ",CRITICAL:"❌ ",NONE:""};const _log=(msg,level="INFO")=>{if(!(logLevels[_level]{_level=logLevel};return{getLevel:()=>{return _level},setLevel:setLevel,sniffer:msg=>{_log(msg,"SNIFFER")},debug:msg=>{_log(msg,"DEBUG")},info:msg=>{_log(msg,"INFO")},notify:msg=>{_log(msg,"NOTIFY")},warning:msg=>{_log(msg,"WARNING")},error:msg=>{_log(msg,"ERROR")},retry:msg=>{_log(msg,"RETRY")}}};return new class{constructor(scriptName,logLevel){this._startTime=Date.now();this.version="3.0.0";this.scriptName=scriptName;this.env=MagicEnvironment();this.logger=MagicLogger(scriptName,logLevel);this.http=typeof MagicHttp==="function"?MagicHttp(this.env,this.logger):undefined;this.data=typeof MagicData==="function"?MagicData(this.env,this.logger):undefined;this.notification=typeof MagicNotification==="function"?MagicNotification(this.scriptName,this.env,this.logger,this.http):undefined;this.utils=typeof MagicUtils==="function"?MagicUtils(this.env,this.logger):undefined;this.qinglong=typeof MagicQingLong==="function"?MagicQingLong(this.env,this.data,this.logger):undefined;if(typeof this.data!=="undefined"){let magicLoglevel=this.data.read("magic_loglevel");const barkUrl=this.data.read("magic_bark_url");if(magicLoglevel){this.logger.setLevel(magicLoglevel.toUpperCase())}if(barkUrl){this.notification.setBark(barkUrl)}}}get isRequest(){return typeof $request!=="undefined"&&typeof $response==="undefined"}get isResponse(){return typeof $response!=="undefined"}get isDebug(){return this.logger.level==="DEBUG"}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}}done=(value={})=>{this._endTime=Date.now();let span=(this._endTime-this._startTime)/1e3;this.logger.info(`SCRIPT COMPLETED: ${span} S.`);if(typeof $done!=="undefined"){$done(value)}}}(scriptName,logLevel)} diff --git a/script/startup/startup.lnplugin b/script/startup/startup.lnplugin index 042eef93d96..cd1bbad7f97 100644 --- a/script/startup/startup.lnplugin +++ b/script/startup/startup.lnplugin @@ -1,9 +1,15 @@ -# 开屏去广告 +#!name= 开屏去广告 +#!desc= 通过脚本去除部分APP顽固开屏广告 +#!openUrl= https://github.com/blackmatrix7/ios_rule_script +#!author= blackmatrix7 +#!homepage= https://github.com/blackmatrix7/ios_rule_script +#!icon= https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/source/avatar.jpg [Script] -http-response ^https?:\/\/capis(-?\w*)?\.didapinche\.com\/ad\/cx\/startup\? requires-body=1,script-path=https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/script/bilibili/bilibili_plus.js,tag=嘀嗒出行_开屏去广告 -http-response ^https?:\/\/fmapp\.chinafamilymart\.com\.cn\/api\/app\/market\/start\/ad requires-body=1,script-path=https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/script/famijia/famijia_checkin.js,tag=Fa米家_开屏去广告 -http-response ^https?:\/\/app\.bilibili\.com\/x\/v2\/splash\/list requires-body=1,script-path=https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/script/bilibili/bilibili_plus.js,tag=BiliBili_开屏去广告 +http-response ^https?:\/\/(t7z|kjp)\.cupid\.iqiyi\.com\/mixer\? requires-body=1,script-path=https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/script/startup/startup.js,tag=爱奇艺_开屏去广告 +http-response ^https?:\/\/capis(-?\w*)?\.didapinche\.com\/ad\/cx\/startup\? requires-body=1,script-path=https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/script/startup/startup.js,tag=嘀嗒出行_开屏去广告 +http-response ^https?:\/\/fmapp\.chinafamilymart\.com\.cn\/api\/app\/market\/start\/ad requires-body=1,script-path=https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/script/startup/startup.js,tag=Fa米家_开屏去广告 +http-response ^https?:\/\/app\.bilibili\.com\/x\/v2\/splash\/(show|list) requires-body=1,script-path=https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/script/startup/startup.js,tag=BiliBili_开屏去广告 http-response ^https?:\/\/wmapi\.meituan\.com\/api\/v\d+\/loadInfo? requires-body=1,script-path=https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/script/startup/startup.js,tag=美团外卖_开屏去广告 http-response ^https?:\/\/hd\.mina\.mi\.com\/splashscreen\/alert requires-body=1,script-path=https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/script/startup/startup.js,tag=小爱音箱_开屏去广告 http-response ^https?:\/\/hd\.mina\.mi\.com\/splashscreen\/alert requires-body=1,script-path=https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/script/startup/startup.js,tag=京东_开屏去广告 @@ -11,4 +17,4 @@ http-response ^https?:\/\/mi\.gdt\.qq\.com\/gdt_mview.fcg requires-body=1,script http-response ^https?:\/\/cmsapi\.dmall\.com\/app\/home\/homepageStartUpPic requires-body=1,script-path=https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/script/startup/startup.js,tag=多点_开屏去广告 [MITM] -hostname = capis.didapinche.com,capis*.didapinche.com,fmapp.chinafamilymart.com.cn,app.bilibili.com,wmapi.meituan.com,hd.mina.mi.com,api.m.jd.com,mi.gdt.qq.com,cmsapi.dmall.com \ No newline at end of file +hostname = capis.didapinche.com,capis*.didapinche.com,fmapp.chinafamilymart.com.cn,app.bilibili.com,wmapi.meituan.com,hd.mina.mi.com,api.m.jd.com,mi.gdt.qq.com,cmsapi.dmall.com,*.cupid.iqiyi.com \ No newline at end of file diff --git a/script/startup/startup.sgmodule b/script/startup/startup.sgmodule index 3307e2ab627..9e6ac2b695f 100644 --- a/script/startup/startup.sgmodule +++ b/script/startup/startup.sgmodule @@ -2,15 +2,20 @@ #!desc=通过脚本去除部分APP的顽固开屏广告 #!system=ios +[General] +force-http-engine-hosts = %APPEND% t7z.cupid.iqiyi.com,kjp.cupid.iqiyi.com,*.didapinche.com + [Script] +爱奇艺_开屏去广告 = type=http-response,requires-body=1,max-size=0,pattern=^https?:\/\/(t7z|kjp)\.cupid\.iqiyi\.com\/mixer\?,script-path=https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/script/startup/startup.js 嘀嗒出行_开屏去广告 = type=http-response,requires-body=1,max-size=0,pattern=^https?:\/\/capis(-?\w*)?\.didapinche\.com\/ad\/cx\/startup\?,script-path=https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/script/startup/startup.js -Fa米家_开屏去广告 = type=http-response,requires-body=1,max-size=0,pattern=^https?:\/\/fmapp\.chinafamilymart\.com\.cn\/api\/app\/market\/start\/ad,script-path=https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/script/famijia/famijia_checkin.js -BiliBili_开屏去广告 = type=http-response,requires-body=1,max-size=0,pattern=^https?:\/\/app\.bilibili\.com\/x\/v2\/splash\/list,script-path=https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/script/bilibili/bilibili_plus.js +Fa米家_开屏去广告 = type=http-response,requires-body=1,max-size=0,pattern=^https?:\/\/fmapp\.chinafamilymart\.com\.cn\/api\/app\/market\/start\/ad,script-path=https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/script/startup/startup.js +BiliBili_开屏去广告 = type=http-response,requires-body=1,max-size=0,pattern=^https?:\/\/app\.bilibili\.com\/x\/v2\/splash\/(show|list),script-path=https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/script/startup/startup.js 美团外卖_开屏去广告 = type=http-response,requires-body=1,max-size=0,pattern=^https?:\/\/wmapi\.meituan\.com\/api\/v\d+\/loadInfo?,script-path=https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/script/startup/startup.js 小爱音箱_开屏去广告 = type=http-response,requires-body=1,max-size=0,pattern=^https?:\/\/hd\.mina\.mi\.com\/splashscreen\/alert,script-path=https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/script/startup/startup.js 京东_开屏去广告 = type=http-response,requires-body=1,max-size=0,pattern=^https?:\/\/api\.m\.jd\.com\/client\.action\?functionId=start,script-path=https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/script/startup/startup.js 联享家_开屏去广告 = type=http-response,requires-body=1,max-size=0,pattern=^https?:\/\/mi\.gdt\.qq\.com\/gdt_mview.fcg,script-path=https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/script/startup/startup.js 多点_开屏去广告 = type=http-response,requires-body=1,max-size=0,pattern=^https?:\/\/cmsapi\.dmall\.com\/app\/home\/homepageStartUpPic,script-path=https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/script/startup/startup.js +轻牛健康_开屏去广告 = type=http-response,requires-body=1,max-size=0,pattern=^https?:\/\/gw\.yolanda\.hk\/api\/servlets\?endpoint=banners\/show_launch_banner,script-path=https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/script/startup/startup.js [MITM] -hostname = %APPEND% capis.didapinche.com,capis*.didapinche.com,fmapp.chinafamilymart.com.cn,app.bilibili.com,wmapi.meituan.com,hd.mina.mi.com,api.m.jd.com,mi.gdt.qq.com,cmsapi.dmall.com \ No newline at end of file +hostname = %APPEND% capis.didapinche.com,capis*.didapinche.com,fmapp.chinafamilymart.com.cn,app.bilibili.com,wmapi.meituan.com,hd.mina.mi.com,api.m.jd.com,mi.gdt.qq.com,cmsapi.dmall.com,gw.yolanda.hk,t7z.cupid.iqiyi.com,kjp.cupid.iqiyi.com \ No newline at end of file diff --git a/script/startup/startup.qxrewrite b/script/startup/startup.snippet similarity index 68% rename from script/startup/startup.qxrewrite rename to script/startup/startup.snippet index f360a6e975b..472b98cd19e 100644 --- a/script/startup/startup.qxrewrite +++ b/script/startup/startup.snippet @@ -1,9 +1,11 @@ +# 爱奇艺 +^https?:\/\/(t7z|kjp)\.cupid\.iqiyi\.com\/mixer\? url script-response-body https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/script/startup/startup.js # 嘀嗒出行 ^https?:\/\/capis(-?\w*)?\.didapinche\.com\/ad\/cx\/startup\? url script-response-body https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/script/startup/startup.js # Fa米家 -^https?:\/\/fmapp\.chinafamilymart\.com\.cn\/api\/app\/market\/start\/ad url script-response-body https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/script/famijia/famijia_checkin.js +^https?:\/\/fmapp\.chinafamilymart\.com\.cn\/api\/app\/market\/start\/ad url script-response-body https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/script/startup/startup.js # BiliBili -^https?:\/\/app\.bilibili\.com\/x\/v2\/splash\/list url script-response-body https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/script/bilibili/bilibili_plus.js +^https?:\/\/app\.bilibili\.com\/x\/v2\/splash\/(show|list) url script-response-body https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/script/startup/startup.js # 美团外卖 ^https?:\/\/wmapi\.meituan\.com\/api\/v\d+\/loadInfo? url script-response-body https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/script/startup/startup.js # 小爱音箱 @@ -15,4 +17,4 @@ # 多点 ^https?:\/\/cmsapi\.dmall\.com\/app\/home\/homepageStartUpPic url script-response-body https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/script/startup/startup.js -hostname = capis.didapinche.com,capis*.didapinche.com,fmapp.chinafamilymart.com.cn,app.bilibili.com,wmapi.meituan.com,hd.mina.mi.com,api.m.jd.com,mi.gdt.qq.com,cmsapi.dmall.com +hostname = *.didapinche.com,fmapp.chinafamilymart.com.cn,app.bilibili.com,wmapi.meituan.com,hd.mina.mi.com,api.m.jd.com,mi.gdt.qq.com,cmsapi.dmall.com,*.cupid.iqiyi.com diff --git a/script/startup/startup.stoverride b/script/startup/startup.stoverride new file mode 100644 index 00000000000..73fa53f7e46 --- /dev/null +++ b/script/startup/startup.stoverride @@ -0,0 +1,104 @@ +name: 开屏去广告 +desc: 通过脚本去除部分APP的顽固开屏广告 + +http: + script: + # 爱奇艺_开屏去广告 + - match: ^https?:\/\/(t7z|kjp)\.cupid\.iqiyi\.com\/mixer\? + name: startup.js + type: response + require-body: true + timeout: 30 + argument: '' + + # 嘀嗒出行_开屏去广告 + - match: ^https?:\/\/capis(-?\w*)?\.didapinche\.com\/ad\/cx\/startup\? + name: startup.js + type: response + require-body: true + timeout: 30 + argument: '' + + # Fa米家_开屏去广告 + - match: ^https?:\/\/fmapp\.chinafamilymart\.com\.cn\/api\/app\/market\/start\/ad + name: startup.js + type: response + require-body: true + timeout: 30 + argument: '' + + # BiliBili_开屏去广告 + - match: ^https?:\/\/app\.bilibili\.com\/x\/v2\/splash\/(show|list) + name: startup.js + type: response + require-body: true + timeout: 30 + argument: '' + + # 美团外卖_开屏去广告 + - match: ^https?:\/\/wmapi\.meituan\.com\/api\/v\d+\/loadInfo? + name: startup.js + type: response + require-body: true + timeout: 30 + argument: '' + + # 小爱音箱_开屏去广告 + - match: ^https?:\/\/hd\.mina\.mi\.com\/splashscreen\/alert + name: startup.js + type: response + require-body: true + timeout: 30 + argument: '' + + # 京东_开屏去广告 + - match: ^https?:\/\/api\.m\.jd\.com\/client\.action\?functionId=start + name: startup.js + type: response + require-body: true + timeout: 30 + argument: '' + + # 联享家_开屏去广告 + - match: ^https?:\/\/mi\.gdt\.qq\.com\/gdt_mview.fcg + name: startup.js + type: response + require-body: true + timeout: 30 + argument: '' + + # 多点_开屏去广告 + - match: ^https?:\/\/cmsapi\.dmall\.com\/app\/home\/homepageStartUpPic + name: startup.js + type: response + require-body: true + timeout: 30 + argument: '' + + # 轻牛健康_开屏去广告 + - match: ^https?:\/\/gw\.yolanda\.hk\/api\/servlets\?endpoint=banners\/show_launch_banner + name: startup.js + type: response + require-body: true + timeout: 30 + argument: '' + + mitm: + - "capis.didapinche.com" + - "capis*.didapinche.com" + - "fmapp.chinafamilymart.com.cn" + - "app.bilibili.com" + - "wmapi.meituan.com" + - "hd.mina.mi.com" + - "api.m.jd.com" + - "mi.gdt.qq.com" + - "cmsapi.dmall.com" + - "gw.yolanda.hk" + - "t7z.cupid.iqiyi.com" + - "kjp.cupid.iqiyi.com" + +script-providers: + startup.js: + url: https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/script/startup/startup.js + interval: 86400 +