diff --git a/README.md b/README.md index b778da5c7..b454af6b0 100644 --- a/README.md +++ b/README.md @@ -64,11 +64,11 @@ https://github.com/blackmatrix7/ios_rule_script/tree/master/rewrite | [中国联通](https://github.com/blackmatrix7/ios_rule_script/tree/master/script/10010) | 每日自动签到、美团外卖30-3优惠券、4次抽奖、话费流量语音情况推送 | 正常 | | [联享家](https://github.com/blackmatrix7/ios_rule_script/tree/master/script/lxj) | 去广告、拦截检测更新 | 正常 | | [开屏去广告](https://github.com/blackmatrix7/ios_rule_script/tree/master/script/startup) | 通过脚本去除缓存到本地的APP开屏广告 | 正常 | -| [嘀嗒出行](https://github.com/blackmatrix7/ios_rule_script/tree/master/script/didachuxing) | 每日自动签到 | 正常 | -| [滴滴出行](https://github.com/blackmatrix7/ios_rule_script/tree/master/script/didichuxing) | 每日自动签到、福利金抽奖、天天有奖签到 | 正常 | +| ~~[嘀嗒出行](https://github.com/blackmatrix7/ios_rule_script/tree/master/script/didachuxing)~~ | ~~每日自动签到~~ | 失效 | +| ~~[滴滴出行](https://github.com/blackmatrix7/ios_rule_script/tree/master/script/didichuxing)~~ | ~~每日自动签到、福利金抽奖、天天有奖签到~~ | 失效 | | [家长帮](https://github.com/blackmatrix7/ios_rule_script/tree/master/script/jiazhangbang) | 每日自动签到 | 正常 | | [慢慢买](https://github.com/blackmatrix7/ios_rule_script/tree/master/script/manmanbuy) | 每日自动签到 | 正常 | -| [~~小米有品~~](https://github.com/blackmatrix7/ios_rule_script/tree/master/script/youpin) | ~~每日自动签到~~ | 停止 | +| [~~小米有品~~](https://github.com/blackmatrix7/ios_rule_script/tree/master/script/youpin) | ~~每日自动签到~~ | 失效 | | [叮咚买菜](https://github.com/blackmatrix7/ios_rule_script/tree/master/script/dingdong) | 每日自动签到 | 正常 | | [万达电影](https://github.com/blackmatrix7/ios_rule_script/tree/master/script/wanda) | 每日自动签到,月末将剩余能量抽奖 | 正常 | | [饿了么](https://github.com/blackmatrix7/ios_rule_script/tree/master/script/eleme) | 每日自动领取会员任务 | 正常 | diff --git a/script/smzdm/backup/smzdm_remove_ads.js b/script/smzdm/backup/smzdm_remove_ads.js new file mode 100644 index 000000000..7b937c55b --- /dev/null +++ b/script/smzdm/backup/smzdm_remove_ads.js @@ -0,0 +1,78 @@ +let body = $response.body; +body=JSON.parse(body); + +let homepage_regex = /^https?:\/\/homepage-api.smzdm.com\/home/; +let haojia_regex = /^https?:\/\/haojia-api.smzdm.com\/home\/list/; +let article_regex = /^https?:\/\/article-api.smzdm.com\/article\/index_home_page/; +let util_regex = /^https?:\/\/app-api\.smzdm\.com\/util\/update/; +let sou_regex = /^https?:\/\/s-api\.smzdm\.com\/sou\/list/; + +// 去除首页推荐广告 +if (homepage_regex.test($request.url)){ + if (!!body){ + if (body['data'].hasOwnProperty('banner')){ + if (body['data']['banner'].hasOwnProperty('big_banner')){ + delete body['data']['banner']['big_banner']; + } + if (body['data']['banner'].hasOwnProperty('tonglan_banner')){ + delete body['data']['banner']['tonglan_banner']; + } + } + if (body.hasOwnProperty('data') && body['data'].hasOwnProperty('rows')){ + let rows = body['data']['rows'].filter((item) =>{ + return item['model_type'] != 'ads' && item['model_type'] != 'cluster'; + }) + body['data']['rows'] = rows; + } + delete body['data']['widget']; + } +} +// 好价去广告 +else if(haojia_regex.test($request.url)){ + if (body['data'].hasOwnProperty('banner')){ + if (body['data']['banner'].hasOwnProperty('two_banner')){ + delete body['data']['banner']['two_banner']; + } + if (body['data']['banner'].hasOwnProperty('big_banner')){ + delete body['data']['banner']['big_banner']; + } + if (body['data']['banner'].hasOwnProperty('calendar_banner')){ + delete body['data']['banner']['calendar_banner']; + } + if (body['data']['banner'].hasOwnProperty('hongbao_banner')){ + delete body['data']['banner']['hongbao_banner']; + } + } + let rows = body['data']['rows'].filter((item) =>{ + return item['tag'] != '广告'; + }) + body['data']['rows'] = rows; +} +// 社区好文去广告 +else if(article_regex.test($request.url)){ + if (body['data'].hasOwnProperty('big_banner')){ + delete body['data']['big_banner']; + } + if (body['data'].hasOwnProperty('notice')){ + delete body['data']['notice']; + } +} +// 去除浮动广告 +else if (util_regex.test($request.url)){ + delete body['data']['ad_filter']; + delete body['data']['operation_float_7_0']; + delete body['data']['operation_full']; + delete body['data']['operation_float_screen']; + delete body['data']['operation_float']; +} +// 去除搜索结果广告 +else if (sou_regex.test($request.url)){ + if (body.hasOwnProperty('data') && body['data'].hasOwnProperty('rows')){ + let rows = body['data']['rows'].filter((item) =>{ + return item['model_type'] != 'ads'; + }) + body['data']['rows'] = rows; + } +} +body=JSON.stringify(body); +$done({body}); diff --git a/script/smzdm/backup/smzdm_remove_ads.lnplugin b/script/smzdm/backup/smzdm_remove_ads.lnplugin new file mode 100644 index 000000000..001c682de --- /dev/null +++ b/script/smzdm/backup/smzdm_remove_ads.lnplugin @@ -0,0 +1,16 @@ +# 什么值得买去广告 + +[URL Rewrite] +^https?:\/\/haojia\.m\.smzdm\.com\/detail_modul\/banner - reject +^https?:\/\/api\.smzdm\.com\/v\d\/util\/(banner|loading) - reject +^https?:\/\/app-api\.smzdm\.com\/util\/loading - reject + +[Script] +http-response ^https?:\/\/homepage-api\.smzdm\.com\/home script-path=https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/script/smzdm/backup/smzdm_remove_ads.js, requires-body=true, timeout=10, tag=什么值得买_首页去广告 +http-response ^https?:\/\/haojia-api\.smzdm\.com\/home\/list script-path=https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/script/smzdm/backup/smzdm_remove_ads.js, requires-body=true, timeout=10, tag=什么值得买_好价去广告 +http-response ^https?:\/\/app-api\.smzdm\.com\/util\/update script-path=https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/script/smzdm/backup/smzdm_remove_ads.js, requires-body=true, timeout=10, tag=什么值得买_去浮动广告 +http-response ^https?:\/\/article-api\.smzdm\.com\/article\/index_home_page script-path=https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/script/smzdm/backup/smzdm_remove_ads.js, requires-body=true, timeout=10, tag=什么值得买_首页去广告 +http-response ^https?:\/\/s-api\.smzdm\.com\/sou\/list script-path=https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/script/smzdm/backup/smzdm_remove_ads.js, requires-body=true, timeout=10, tag=什么值得买_搜索去广告 + +[MITM] +hostname = homepage-api.smzdm.com,haojia-api.smzdm.com,article-api.smzdm.com,haojia.m.smzdm.com,app-api.smzdm.com,s-api.smzdm.com \ No newline at end of file diff --git a/script/smzdm/backup/smzdm_remove_ads.qxrewrite b/script/smzdm/backup/smzdm_remove_ads.qxrewrite new file mode 100644 index 000000000..4b20de947 --- /dev/null +++ b/script/smzdm/backup/smzdm_remove_ads.qxrewrite @@ -0,0 +1,19 @@ +# 什么值得买去广告 + +# 详情页去广告 +^https?:\/\/haojia\.m\.smzdm\.com\/detail_modul\/banner url reject-dict +# 首页去广告 +^https?:\/\/homepage-api\.smzdm\.com\/home url script-response-body https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/script/smzdm/backup/smzdm_remove_ads.js +# 好价去广告 +^https?:\/\/haojia-api\.smzdm\.com\/home\/list url script-response-body https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/script/smzdm/backup/smzdm_remove_ads.js +# 去浮动广告 +^https?:\/\/app-api\.smzdm\.com\/util\/update url script-response-body https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/script/smzdm/backup/smzdm_remove_ads.js +# 好文去广告 +^https?:\/\/article-api\.smzdm\.com\/article\/index_home_page url script-response-body https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/script/smzdm/backup/smzdm_remove_ads.js +# 搜索去广告 +^https?:\/\/s-api\.smzdm\.com\/sou\/list url script-response-body https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/script/smzdm/backup/smzdm_remove_ads.js +# 其他 +^https?:\/\/api\.smzdm\.com\/v\d\/util\/(banner|loading) url reject-dict +^https?:\/\/app-api\.smzdm\.com\/util\/loading url reject-dict + +hostname = homepage-api.smzdm.com,haojia-api.smzdm.com,article-api.smzdm.com,haojia.m.smzdm.com,app-api.smzdm.com,s-api.smzdm.com \ No newline at end of file diff --git a/script/smzdm/backup/smzdm_remove_ads.sgmodule b/script/smzdm/backup/smzdm_remove_ads.sgmodule new file mode 100644 index 000000000..99b6e1abf --- /dev/null +++ b/script/smzdm/backup/smzdm_remove_ads.sgmodule @@ -0,0 +1,18 @@ +#!name=什么值得买 +#!desc=什么值得买APP去广告 + +[URL Rewrite] +^https?:\/\/haojia\.m\.smzdm\.com\/detail_modul\/banner - reject +^https?:\/\/api\.smzdm\.com\/v\d\/util\/(banner|loading) - reject +^https?:\/\/app-api\.smzdm\.com\/util\/loading - reject + +[Script] +什么值得买_首页去广告 = type=http-response,requires-body=1,max-size=0,pattern=^https?:\/\/homepage-api\.smzdm\.com\/home,script-path=https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/script/smzdm/backup/smzdm_remove_ads.js +什么值得买_去浮动广告 = type=http-response,requires-body=1,max-size=0,pattern=^https?:\/\/app-api\.smzdm\.com\/util\/update,script-path=https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/script/smzdm/backup/smzdm_remove_ads.js +什么值得买_好价去广告 = type=http-response,requires-body=1,max-size=0,pattern=^https?:\/\/haojia-api\.smzdm\.com\/home\/list\?,script-path=https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/script/smzdm/backup/smzdm_remove_ads.js +什么值得买_好文去广告 = type=http-response,requires-body=1,max-size=0,pattern=^https?:\/\/article-api\.smzdm\.com\/article\/index_home_page,script-path=https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/script/smzdm/backup/smzdm_remove_ads.js +什么值得买_搜索去广告 = type=http-response,requires-body=1,max-size=0,pattern=^https?:\/\/s-api\.smzdm\.com\/sou\/list,script-path=https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/script/smzdm/backup/smzdm_remove_ads.js + + +[MITM] +hostname = %APPEND% homepage-api.smzdm.com,haojia-api.smzdm.com,article-api.smzdm.com,haojia.m.smzdm.com,app-api.smzdm.com,s-api.smzdm.com \ No newline at end of file diff --git a/script/smzdm/smzdm_remove_ads.js b/script/smzdm/smzdm_remove_ads.js index 7b937c55b..534e6903a 100644 --- a/script/smzdm/smzdm_remove_ads.js +++ b/script/smzdm/smzdm_remove_ads.js @@ -1,78 +1,154 @@ -let body = $response.body; -body=JSON.parse(body); +const scriptName = "什么值得买"; +let magicJS = MagicJS(scriptName, "INFO"); -let homepage_regex = /^https?:\/\/homepage-api.smzdm.com\/home/; -let haojia_regex = /^https?:\/\/haojia-api.smzdm.com\/home\/list/; -let article_regex = /^https?:\/\/article-api.smzdm.com\/article\/index_home_page/; -let util_regex = /^https?:\/\/app-api\.smzdm\.com\/util\/update/; -let sou_regex = /^https?:\/\/s-api\.smzdm\.com\/sou\/list/; +(() => { + let response = null; + if (magicJS.isResponse) { + switch (true) { + // 去除APP启动广告 + case /^https?:\/\/app-api\.smzdm\.com\/util\/loading/.test(magicJS.request.url): + try { + let obj = JSON.parse(magicJS.response.body); + obj.data.forEach((element) => { + element.start_date = "2030-12-24 00:00:00"; + element.end_date = "2030-12-24 23:59:59"; + element.unix_start_date = "1924272000"; + element.unix_end_date = "1924358399"; + element.is_show_ad = "0"; + }); + response = { body: JSON.stringify(obj) }; + } catch (err) { + magicJS.logError(`去除APP启动广告出现异常:${err}`); + } + break; + // 去除首页广告 + case /^https?:\/\/homepage-api\.smzdm\.com\/v3\/home/.test(magicJS.request.url): + try { + let obj = JSON.parse(magicJS.response.body); + let component = []; + obj.data.component.forEach((element) => { + if (element.zz_type === "banner") { + let bannerList = element.zz_content.filter((banner) => { + return banner.tag !== "广告"; + }); + element.zz_content = bannerList; + } + // 去除信息流中的广告 + else if (element.zz_type === "list") { + let contentList = element.zz_content.filter((content) => { + return content.zz_content.model_type !== "ads"; + }); + element.zz_content = contentList; + } + // 去除首页背景颜色 + else if (element.zz_type === "circular_banner") { + element.zz_content.circular_banner_option.background = "1"; + element.zz_content.circular_banner_option.color_card = "#ffffff"; + element.zz_content.circular_banner_option.img = ""; + } + // 最顶部的banner和红包不显示 + if (element.zz_type !== "top_banner" && element.zz_type !== "hongbao") { + component.push(element); + } + }); -// 去除首页推荐广告 -if (homepage_regex.test($request.url)){ - if (!!body){ - if (body['data'].hasOwnProperty('banner')){ - if (body['data']['banner'].hasOwnProperty('big_banner')){ - delete body['data']['banner']['big_banner']; - } - if (body['data']['banner'].hasOwnProperty('tonglan_banner')){ - delete body['data']['banner']['tonglan_banner']; - } + obj.data.component = component; + response = { body: JSON.stringify(obj) }; + } catch (err) { + magicJS.logError(`首页去广告出现异常:${err}`); + } + break; + // 去除好价广告 + case /^https?:\/\/haojia-api\.smzdm\.com\/home\/list/.test(magicJS.request.url): + try { + let obj = JSON.parse(magicJS.response.body); + let bigBanner = obj.data.banner.big_banner.filter((element) => { + return element.ad_banner_id == ""; + }); + obj.data.banner.big_banner = bigBanner; + let rows = obj.data.rows.filter((element) => { + return !element.hasOwnProperty("ad_banner_id"); + }); + // 红包相关 + obj.data.banner.hongbao_banner = []; + obj.data.banner.module_banner.hongbao = {}; + // 不显示皮肤 + // obj.data.banner.skin = {}; + obj.data.rows = rows; + response = { body: JSON.stringify(obj) }; + } catch (err) { + magicJS.logError(`好价去广告出现异常:${err}`); + } + break; + // 去除好价详情页广告 + case /^https?:\/\/haojia\.m\.smzdm\.com\/detail_modul\/article_releated_modul/.test(magicJS.request.url): + try { + let obj = JSON.parse(magicJS.response.body); + obj.data.lanmu_qikan = {}; + response = { body: JSON.stringify(obj) }; + } catch (err) { + magicJS.logError(`好价详情页去广告出现异常:${err}`); + } + break; + // 去除百科广告 + case /^https?:\/\/baike-api\.smzdm\.com\/home_v3\/list/.test(magicJS.request.url): + try { + let obj = JSON.parse(magicJS.response.body); + obj.data.rows = obj.data.rows.filter((element) => { + return !element.hasOwnProperty("ad_banner_id") || element.ad_banner_id == ""; + }); + response = { body: JSON.stringify(obj) }; + } catch (err) { + magicJS.logError(`百科去广告出现异常:${err}`); + } + break; + // 去除搜索标签广告 + case /^https?:\/\/s-api\.smzdm\.com\/sou\/filter\/tags\/hot_tags/.test(magicJS.request.url): + try { + let obj = JSON.parse(magicJS.response.body); + obj.data.hongbao = {}; + response = { body: JSON.stringify(obj) }; + } catch (err) { + magicJS.logError(`搜索标签去广告出现异常:${err}`); + } + break; + // 去除搜索结果广告 + case /^https?:\/\/s-api\.smzdm\.com\/sou\/list_v10/.test(magicJS.request.url): + try { + let obj = JSON.parse(magicJS.response.body); + obj.data.rows = obj.data.rows.filter((element) => { + return element.article_tag !== "广告"; + }); + response = { body: JSON.stringify(obj) }; + } catch (err) { + magicJS.logError(`搜索结果去广告出现异常:${err}`); + } + break; + // 去除值会员权益中心banner广告 + case /^https?:\/\/zhiyou\.m\.smzdm\.com\/user\/vip\/ajax_get_banner/.test(magicJS.request.url): + try { + let obj = JSON.parse(magicJS.response.body); + obj.data.big_banner = obj.data.big_banner.filter((element) => { + return element.logo_title !== "广告"; + }); + response = { body: JSON.stringify(obj) }; + } catch (err) { + magicJS.logError(`值会员权益中心banner去广告出现异常:${err}`); + } + break; + default: + magicJS.notify("触发意外的请求处理,请确认脚本或复写配置正常。"); + break; } - if (body.hasOwnProperty('data') && body['data'].hasOwnProperty('rows')){ - let rows = body['data']['rows'].filter((item) =>{ - return item['model_type'] != 'ads' && item['model_type'] != 'cluster'; - }) - body['data']['rows'] = rows; - } - delete body['data']['widget']; + } else { + magicJS.notify("触发意外的请求处理,请确认脚本或复写配置正常。"); } -} -// 好价去广告 -else if(haojia_regex.test($request.url)){ - if (body['data'].hasOwnProperty('banner')){ - if (body['data']['banner'].hasOwnProperty('two_banner')){ - delete body['data']['banner']['two_banner']; - } - if (body['data']['banner'].hasOwnProperty('big_banner')){ - delete body['data']['banner']['big_banner']; - } - if (body['data']['banner'].hasOwnProperty('calendar_banner')){ - delete body['data']['banner']['calendar_banner']; - } - if (body['data']['banner'].hasOwnProperty('hongbao_banner')){ - delete body['data']['banner']['hongbao_banner']; - } + if (response) { + magicJS.done(response); + } else { + magicJS.done(); } - let rows = body['data']['rows'].filter((item) =>{ - return item['tag'] != '广告'; - }) - body['data']['rows'] = rows; -} -// 社区好文去广告 -else if(article_regex.test($request.url)){ - if (body['data'].hasOwnProperty('big_banner')){ - delete body['data']['big_banner']; - } - if (body['data'].hasOwnProperty('notice')){ - delete body['data']['notice']; - } -} -// 去除浮动广告 -else if (util_regex.test($request.url)){ - delete body['data']['ad_filter']; - delete body['data']['operation_float_7_0']; - delete body['data']['operation_full']; - delete body['data']['operation_float_screen']; - delete body['data']['operation_float']; -} -// 去除搜索结果广告 -else if (sou_regex.test($request.url)){ - if (body.hasOwnProperty('data') && body['data'].hasOwnProperty('rows')){ - let rows = body['data']['rows'].filter((item) =>{ - return item['model_type'] != 'ads'; - }) - body['data']['rows'] = rows; - } -} -body=JSON.stringify(body); -$done({body}); +})(); + +// 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/smzdm/smzdm_remove_ads.lnplugin b/script/smzdm/smzdm_remove_ads.lnplugin index 272fc0091..b224575c8 100644 --- a/script/smzdm/smzdm_remove_ads.lnplugin +++ b/script/smzdm/smzdm_remove_ads.lnplugin @@ -1,16 +1,22 @@ # 什么值得买去广告 [URL Rewrite] -^https?:\/\/haojia\.m\.smzdm\.com\/detail_modul\/banner - reject -^https?:\/\/api\.smzdm\.com\/v\d\/util\/(banner|loading) - reject -^https?:\/\/app-api\.smzdm\.com\/util\/loading - reject +# 什么值得买_好价详情页去广告 +^https?:\/\/haojia\.m\.smzdm\.com\/detail_modul\/other_modul - reject +# 什么值得买_好价详情页红包小助手 +^https?:\/\/haojia\.m\.smzdm\.com\/detail_modul\/user_related_modul - reject +# 什么值得买_Wiki(618晒物活动推广,将来可能不是广告) +^https?:\/\/haojia\.m\.smzdm\.com\/detail_modul\/wiki_related_modul - reject [Script] -http-response ^https?:\/\/homepage-api\.smzdm\.com\/home script-path=https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/script/smzdm/smzdm_remove_ads.js, requires-body=true, timeout=10, tag=什么值得买_首页去广告 +http-response ^https?:\/\/app-api\.smzdm\.com\/util\/loading script-path=https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/script/smzdm/smzdm_remove_ads.js, requires-body=true, timeout=10, tag=什么值得买_开屏去广告 +http-response ^https?:\/\/homepage-api\.smzdm\.com\/v3\/home script-path=https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/script/smzdm/smzdm_remove_ads.js, requires-body=true, timeout=10, tag=什么值得买_首页去广告 http-response ^https?:\/\/haojia-api\.smzdm\.com\/home\/list script-path=https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/script/smzdm/smzdm_remove_ads.js, requires-body=true, timeout=10, tag=什么值得买_好价去广告 -http-response ^https?:\/\/app-api\.smzdm\.com\/util\/update script-path=https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/script/smzdm/smzdm_remove_ads.js, requires-body=true, timeout=10, tag=什么值得买_去浮动广告 -http-response ^https?:\/\/article-api\.smzdm\.com\/article\/index_home_page script-path=https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/script/smzdm/smzdm_remove_ads.js, requires-body=true, timeout=10, tag=什么值得买_首页去广告 -http-response ^https?:\/\/s-api\.smzdm\.com\/sou\/list script-path=https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/script/smzdm/smzdm_remove_ads.js, requires-body=true, timeout=10, tag=什么值得买_搜索去广告 +http-response ^https?:\/\/haojia\.m\.smzdm\.com\/detail_modul\/article_releated_modul script-path=https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/script/smzdm/smzdm_remove_ads.js, requires-body=true, timeout=10, tag=什么值得买_好价详情页去广告 +http-response ^https?:\/\/baike-api\.smzdm\.com\/home_v3\/list script-path=https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/script/smzdm/smzdm_remove_ads.js, requires-body=true, timeout=10, tag=什么值得买_百科去广告 +http-response ^https?:\/\/s-api\.smzdm\.com\/sou\/list_v10 script-path=https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/script/smzdm/smzdm_remove_ads.js, requires-body=true, timeout=10, tag=什么值得买_搜索结果去广告 +http-response ^https?:\/\/s-api\.smzdm\.com\/sou\/filter\/tags\/hot_tags script-path=https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/script/smzdm/smzdm_remove_ads.js, requires-body=true, timeout=10, tag=什么值得买_搜索标签去广告 +http-response ^https?:\/\/zhiyou\.m\.smzdm\.com\/user\/vip\/ajax_get_banner script-path=https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/script/smzdm/smzdm_remove_ads.js, requires-body=true, timeout=10, tag=什么值得买_值会员权益中心banner广告 [MITM] -hostname = homepage-api.smzdm.com,haojia-api.smzdm.com,article-api.smzdm.com,haojia.m.smzdm.com,app-api.smzdm.com,s-api.smzdm.com \ No newline at end of file +hostname = app-api.smzdm.com,homepage-api.smzdm.com,haojia-api.smzdm.com,haojia.m.smzdm.com,baike-api.smzdm.com,s-api.smzdm.com,zhiyou.m.smzdm.com \ No newline at end of file diff --git a/script/smzdm/smzdm_remove_ads.qxrewrite b/script/smzdm/smzdm_remove_ads.qxrewrite index 20408fc1e..dfa8ca672 100644 --- a/script/smzdm/smzdm_remove_ads.qxrewrite +++ b/script/smzdm/smzdm_remove_ads.qxrewrite @@ -1,19 +1,27 @@ # 什么值得买去广告 -# 详情页去广告 -^https?:\/\/haojia\.m\.smzdm\.com\/detail_modul\/banner url reject-dict +# 好价详情页去广告 +^https?:\/\/haojia\.m\.smzdm\.com\/detail_modul\/other_modul url reject +# 好价详情页红包小助手 +^https?:\/\/haojia\.m\.smzdm\.com\/detail_modul\/user_related_modul url reject +# Wiki(618晒物活动推广,将来可能不是广告) +^https?:\/\/haojia\.m\.smzdm\.com\/detail_modul\/wiki_related_modul url reject + +# 开屏去广告 +^https?:\/\/app-api\.smzdm\.com\/util\/loading url script-response-body https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/script/smzdm/smzdm_remove_ads.js # 首页去广告 -^https?:\/\/homepage-api\.smzdm\.com\/home url script-response-body https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/script/smzdm/smzdm_remove_ads.js +^https?:\/\/homepage-api\.smzdm\.com\/v3\/home url script-response-body https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/script/smzdm/smzdm_remove_ads.js # 好价去广告 ^https?:\/\/haojia-api\.smzdm\.com\/home\/list url script-response-body https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/script/smzdm/smzdm_remove_ads.js -# 去浮动广告 -^https?:\/\/app-api\.smzdm\.com\/util\/update url script-response-body https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/script/smzdm/smzdm_remove_ads.js -# 好文去广告 -^https?:\/\/article-api\.smzdm\.com\/article\/index_home_page url script-response-body https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/script/smzdm/smzdm_remove_ads.js -# 搜索去广告 -^https?:\/\/s-api\.smzdm\.com\/sou\/list url script-response-body https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/script/smzdm/smzdm_remove_ads.js -# 其他 -^https?:\/\/api\.smzdm\.com\/v\d\/util\/(banner|loading) url reject-dict -^https?:\/\/app-api\.smzdm\.com\/util\/loading url reject-dict +# 好价详情页去广告 +^https?:\/\/haojia\.m\.smzdm\.com\/detail_modul\/article_releated_modul url script-response-body https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/script/smzdm/smzdm_remove_ads.js +# 百科去广告 +^https?:\/\/baike-api\.smzdm\.com\/home_v3\/list url script-response-body https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/script/smzdm/smzdm_remove_ads.js +# 搜索结果去广告 +^https?:\/\/s-api\.smzdm\.com\/sou\/list_v10 url script-response-body https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/script/smzdm/smzdm_remove_ads.js +# 搜索标签去广告 +^https?:\/\/s-api\.smzdm\.com\/sou\/filter\/tags\/hot_tags url script-response-body https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/script/smzdm/smzdm_remove_ads.js +# 值会员权益中心banner广告 +^https?:\/\/zhiyou\.m\.smzdm\.com\/user\/vip\/ajax_get_banner url script-response-body https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/script/smzdm/smzdm_remove_ads.js -hostname = homepage-api.smzdm.com,haojia-api.smzdm.com,article-api.smzdm.com,haojia.m.smzdm.com,app-api.smzdm.com,s-api.smzdm.com \ No newline at end of file +hostname = app-api.smzdm.com,homepage-api.smzdm.com,haojia-api.smzdm.com,haojia.m.smzdm.com,baike-api.smzdm.com,s-api.smzdm.com,zhiyou.m.smzdm.com \ No newline at end of file diff --git a/script/smzdm/smzdm_remove_ads.sgmodule b/script/smzdm/smzdm_remove_ads.sgmodule index da55cd7a4..5e9813093 100644 --- a/script/smzdm/smzdm_remove_ads.sgmodule +++ b/script/smzdm/smzdm_remove_ads.sgmodule @@ -2,17 +2,23 @@ #!desc=什么值得买APP去广告 [URL Rewrite] -^https?:\/\/haojia\.m\.smzdm\.com\/detail_modul\/banner - reject -^https?:\/\/api\.smzdm\.com\/v\d\/util\/(banner|loading) - reject -^https?:\/\/app-api\.smzdm\.com\/util\/loading - reject +# 什么值得买_好价详情页去广告 +^https?:\/\/haojia\.m\.smzdm\.com\/detail_modul\/other_modul - reject +# 什么值得买_好价详情页红包小助手 +^https?:\/\/haojia\.m\.smzdm\.com\/detail_modul\/user_related_modul - reject +# 什么值得买_Wiki(618晒物活动推广,将来可能不是广告) +^https?:\/\/haojia\.m\.smzdm\.com\/detail_modul\/wiki_related_modul - reject [Script] -什么值得买_首页去广告 = type=http-response,requires-body=1,max-size=0,pattern=^https?:\/\/homepage-api\.smzdm\.com\/home,script-path=https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/script/smzdm/smzdm_remove_ads.js -什么值得买_去浮动广告 = type=http-response,requires-body=1,max-size=0,pattern=^https?:\/\/app-api\.smzdm\.com\/util\/update,script-path=https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/script/smzdm/smzdm_remove_ads.js -什么值得买_好价去广告 = type=http-response,requires-body=1,max-size=0,pattern=^https?:\/\/haojia-api\.smzdm\.com\/home\/list\?,script-path=https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/script/smzdm/smzdm_remove_ads.js -什么值得买_好文去广告 = type=http-response,requires-body=1,max-size=0,pattern=^https?:\/\/article-api\.smzdm\.com\/article\/index_home_page,script-path=https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/script/smzdm/smzdm_remove_ads.js -什么值得买_搜索去广告 = type=http-response,requires-body=1,max-size=0,pattern=^https?:\/\/s-api\.smzdm\.com\/sou\/list,script-path=https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/script/smzdm/smzdm_remove_ads.js +什么值得买_开屏去广告 = type=http-response,requires-body=1,max-size=0,pattern=^https?:\/\/app-api\.smzdm\.com\/util\/loading,script-path=https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/script/smzdm/smzdm_remove_ads.js +什么值得买_首页去广告 = type=http-response,requires-body=1,max-size=0,pattern=^https?:\/\/homepage-api\.smzdm\.com\/v3\/home,script-path=https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/script/smzdm/smzdm_remove_ads.js +什么值得买_好价去广告 = type=http-response,requires-body=1,max-size=0,pattern=^https?:\/\/haojia-api\.smzdm\.com\/home\/list,script-path=https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/script/smzdm/smzdm_remove_ads.js +什么值得买_好价详情页去广告 = type=http-response,requires-body=1,max-size=0,pattern=^https?:\/\/haojia\.m\.smzdm\.com\/detail_modul\/article_releated_modul,script-path=https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/script/smzdm/smzdm_remove_ads.js +什么值得买_百科去广告 = type=http-response,requires-body=1,max-size=0,pattern=^https?:\/\/baike-api\.smzdm\.com\/home_v3\/list,script-path=https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/script/smzdm/smzdm_remove_ads.js +什么值得买_搜索结果去广告 = type=http-response,requires-body=1,max-size=0,pattern=^https?:\/\/s-api\.smzdm\.com\/sou\/list_v10,script-path=https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/script/smzdm/smzdm_remove_ads.js +什么值得买_搜索标签去广告 = type=http-response,requires-body=1,max-size=0,pattern=^https?:\/\/s-api\.smzdm\.com\/sou\/filter\/tags\/hot_tags,script-path=https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/script/smzdm/smzdm_remove_ads.js +什么值得买_值会员权益中心banner去广告 = type=http-response,requires-body=1,max-size=0,pattern=^https?:\/\/zhiyou\.m\.smzdm\.com\/user\/vip\/ajax_get_banner,script-path=https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/script/smzdm/smzdm_remove_ads.js [MITM] -hostname = %APPEND% homepage-api.smzdm.com,haojia-api.smzdm.com,article-api.smzdm.com,haojia.m.smzdm.com,app-api.smzdm.com,s-api.smzdm.com \ No newline at end of file +hostname = %APPEND% app-api.smzdm.com,homepage-api.smzdm.com,haojia-api.smzdm.com,haojia.m.smzdm.com,baike-api.smzdm.com,s-api.smzdm.com,zhiyou.m.smzdm.com \ No newline at end of file