From e50e68963fe3b4739a6a7b7aadc2cb21053c2f42 Mon Sep 17 00:00:00 2001 From: woni <320753691@qq.com> Date: Wed, 8 Nov 2023 20:18:45 +0800 Subject: [PATCH] fix some bugs --- crx/adblock-cs.js | 22 ++++++++++++++++++---- crx/manifest.json | 4 ++-- 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/crx/adblock-cs.js b/crx/adblock-cs.js index 1e05ee3..7613f1d 100644 --- a/crx/adblock-cs.js +++ b/crx/adblock-cs.js @@ -1,3 +1,5 @@ +let currentUrl = window.location.href; + function getElementByXpath(path) { return document.evaluate(path, document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue; } @@ -11,10 +13,22 @@ function removeElementByXpath(path) { } } -const ele_list = ['//*/div[@class="y-guide"]', '//*/div[@class="auxo-modal-root"]', '//*/div[contains(@class, "index_DragControlle")]'] +const host_xpath_mapping = { + '^https://.*\\.jinritemai\\.com/.*$': + ['//*/div[@class="y-guide"]', '//*/div[@class="auxo-modal-root"]', '//*/div[contains(@class, "index_DragControlle")]'] +} + +var xpaths = []; + +for (let pattern in host_xpath_mapping) { + // console.log(pattern); + if (new RegExp(pattern).test(currentUrl)) { + xpaths = host_xpath_mapping[pattern]; + } +} setInterval(function () { - for (let ele of ele_list) { - removeElementByXpath(ele); + for (let xpath of xpaths) { + removeElementByXpath(xpath); } -}, 500); // 300 毫秒 +}, 300); diff --git a/crx/manifest.json b/crx/manifest.json index ae2993e..f78bd62 100644 --- a/crx/manifest.json +++ b/crx/manifest.json @@ -1,6 +1,6 @@ { "name": "BotExt", - "version": "0.1.9", + "version": "0.1.10", "manifest_version": 3, "background": { "service_worker": "sw.js" @@ -17,7 +17,7 @@ }, { "matches": [ - "" + "https://www.kdocs.cn/*" ], "js": [ "wps.js"