From 02c5fdd00d769b481220156710cb91783fa9d8eb Mon Sep 17 00:00:00 2001 From: wanhose Date: Tue, 30 Mar 2021 14:45:37 +0200 Subject: [PATCH] feat: improve performance --- src/filters/index.txt | 7 ++++++- src/scripts/content.js | 38 +++++++++++++++++++------------------- 2 files changed, 25 insertions(+), 20 deletions(-) diff --git a/src/filters/index.txt b/src/filters/index.txt index db375f4..e5b6e9c 100644 --- a/src/filters/index.txt +++ b/src/filters/index.txt @@ -12526,6 +12526,7 @@ amedia-privacybox #sprd-consent #sd-cmp #cl-consent +.cl-consent script[src="//clickio.mgr.consensu.org/t/consent_216889.js"] #didomi-host #didomi-popup @@ -12565,4 +12566,8 @@ div[data-testid="cookie-policy-banner"] #cookie-compliant-fondo #cmpbox div[data-component="global/PopUpFromCookie"] -div[data-testid="cookie-policy-dialog"] \ No newline at end of file +div[data-testid="cookie-policy-dialog"] +div[aria-labelledby="cookie_banner_title"] +.popover-cover zIndex--fixed +#_evidon-background +.evidon-background \ No newline at end of file diff --git a/src/scripts/content.js b/src/scripts/content.js index 9498679..224768d 100644 --- a/src/scripts/content.js +++ b/src/scripts/content.js @@ -32,23 +32,6 @@ const observe = () => { }); }; -const removeFromCache = () => { - chrome.storage.local.get([document.location.hostname], (value) => { - const matches = value[document.location.hostname]; - - if (matches && !!matches.length) { - for (let i = 0; i < matches.length; i++) { - const element = retrieveElement(matches[i]); - const tagName = element ? element.tagName.toUpperCase() : ""; - - if (element && !["BODY", "HTML"].includes(tagName)) { - element.remove(); - } - } - } - }); -}; - const updateCache = (value) => { chrome.storage.local.get([document.location.hostname], (store) => { const matches = store[document.location.hostname]; @@ -61,16 +44,33 @@ const updateCache = (value) => { }); }; +const removeFromCache = () => { + chrome.storage.local.get([document.location.hostname], (value) => { + const matches = value[document.location.hostname]; + + if (matches && !!matches.length) { + for (let i = matches.length; i--; ) { + const element = retrieveElement(matches[i]); + const tagName = element ? element.tagName.toUpperCase() : ""; + + if (element && !["BODY", "HTML"].includes(tagName)) { + element.remove(); + } + } + } + }); +}; + const removeFromFilters = () => { if (attempts < 5) { - for (let i = 0; i < filters.length; i++) { + for (let i = filters.length; i--; ) { const match = filters[i]; const element = retrieveElement(match); const tagName = element ? element.tagName.toUpperCase() : ""; if (element && !["BODY", "HTML"].includes(tagName)) { + element.innerHTML = ""; updateCache(match); - element.remove(); } } }