From 1a889fad7659dd3ceea579137f80ea0d2dfb03d0 Mon Sep 17 00:00:00 2001 From: toulanboy Date: Sun, 18 Sep 2022 08:32:49 +0800 Subject: [PATCH] update ithome, fix #18 --- bilibili_ad/bilibili_ad.js | 5 +++-- ithome_ad/ithome_ad.js | 17 +++++++++++++++++ ithome_ad/ithome_loon.plugin | 4 ++-- ithome_ad/ithome_quan.conf | 4 ++-- ithome_ad/ithome_surge.sgmodule | 4 ++-- 5 files changed, 26 insertions(+), 8 deletions(-) diff --git a/bilibili_ad/bilibili_ad.js b/bilibili_ad/bilibili_ad.js index 390e6e4..1c8ca0b 100644 --- a/bilibili_ad/bilibili_ad.js +++ b/bilibili_ad/bilibili_ad.js @@ -36,7 +36,8 @@ const url = $request.url; let body = JSON.parse($response.body); try { - if (url.indexOf('splash\/list') != -1) { + + if (url.indexOf('splash\/list') != -1) { //开屏广告优化 let i = body.data.list.length; while (i--) { if (body.data.list[i].is_ad == true) { @@ -48,7 +49,7 @@ try { body.data.show[i].stime = 0; body.data.show[i].etime = 1; } - } else if (url.indexOf('feed\/index') != -1) { + } else if (url.indexOf('feed\/index') != -1) { //信息流优化 let i = body.data.items.length; while (i--) { if (body.data.items[i].card_goto.indexOf("ad") != -1 || diff --git a/ithome_ad/ithome_ad.js b/ithome_ad/ithome_ad.js index d71aa07..4dced1c 100644 --- a/ithome_ad/ithome_ad.js +++ b/ithome_ad/ithome_ad.js @@ -46,6 +46,23 @@ if (url.indexOf("newslist") != -1 || url.indexOf("listpage") != -1) { body.splice(i, 1); } } +} else if (url.indexOf("napi") != -1) { + let listData = body.data.list; + let i = listData.length; + while (i--) { + if (listData[i].feedType == 10002) { + let j = listData[i].feedContent.focusNewsData.length; + while (j--) { + if (listData[i].feedContent.focusNewsData[j].isAd) { + listData[i].feedContent.focusNewsData.splice(j, 1); + } + } + } else if (listData[i].feedType == 10000) { + if (listData[i].feedContent.smallTags[0].text.indexOf("广告") != -1) { + listData.splice(i, 1) + } + } + } } body = JSON.stringify(body) $done({ diff --git a/ithome_ad/ithome_loon.plugin b/ithome_ad/ithome_loon.plugin index 90f7db0..50b790c 100644 --- a/ithome_ad/ithome_loon.plugin +++ b/ithome_ad/ithome_loon.plugin @@ -1,5 +1,5 @@ [Script] -http-response https?:\/\/api\.ithome\.com\/json\/(((newslist|listpage)\/news)|(slide\/index)) script-path=https://raw.githubusercontent.com/toulanboy/scripts/master/ithome_ad/ithome_ad.js,requires-body=true, tag=ithome_ad +http-response https?:\/\/(api\.ithome\.com\/json\/(((newslist|listpage)\/news)|(slide\/index)))|(napi\.ithome\.com\/api\/news\/index) script-path=https://raw.githubusercontent.com/toulanboy/scripts/master/ithome_ad/ithome_ad.js,requires-body=true, tag=ithome_ad [MITM] -hostname = api.ithome.com \ No newline at end of file +hostname = api.ithome.com,napi.ithome.com \ No newline at end of file diff --git a/ithome_ad/ithome_quan.conf b/ithome_ad/ithome_quan.conf index 4353c0e..e23a809 100644 --- a/ithome_ad/ithome_quan.conf +++ b/ithome_ad/ithome_quan.conf @@ -1,3 +1,3 @@ -hostname = api.ithome.com +hostname = api.ithome.com,napi.ithome.com -https?:\/\/api\.ithome\.com\/json\/(((newslist|listpage)\/news)|(slide\/index)) url script-response-body https://raw.githubusercontent.com/toulanboy/scripts/master/ithome_ad/ithome_ad.js +https?:\/\/(api\.ithome\.com\/json\/(((newslist|listpage)\/news)|(slide\/index)))|(napi\.ithome\.com\/api\/news\/index) url script-response-body https://raw.githubusercontent.com/toulanboy/scripts/master/ithome_ad/ithome_ad.js diff --git a/ithome_ad/ithome_surge.sgmodule b/ithome_ad/ithome_surge.sgmodule index 9a2c106..cf537c4 100644 --- a/ithome_ad/ithome_surge.sgmodule +++ b/ithome_ad/ithome_surge.sgmodule @@ -1,7 +1,7 @@ #!name=ithome_ad #!desc=ithome_ad [Script] -ithome_ad = type=http-response,pattern=https?:\/\/api\.ithome\.com\/json\/(((newslist|listpage)\/news)|(slide\/index)),script-path=https://raw.githubusercontent.com/toulanboy/scripts/master/ithome_ad/ithome_ad.js,requires-body=true +ithome_ad = type=http-response,pattern=https?:\/\/(api\.ithome\.com\/json\/(((newslist|listpage)\/news)|(slide\/index)))|(napi\.ithome\.com\/api\/news\/index),script-path=https://raw.githubusercontent.com/toulanboy/scripts/master/ithome_ad/ithome_ad.js,requires-body=true [MITM] -hostname = %APPEND% api.ithome.com \ No newline at end of file +hostname = %APPEND% api.ithome.com,napi.ithome.com \ No newline at end of file