feat: improve performance

This commit is contained in:
wanhose 2021-03-30 14:45:37 +02:00
parent 7c88ce8260
commit 02c5fdd00d
2 changed files with 25 additions and 20 deletions

View File

@ -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"]
div[data-testid="cookie-policy-dialog"]
div[aria-labelledby="cookie_banner_title"]
.popover-cover zIndex--fixed
#_evidon-background
.evidon-background

View File

@ -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();
}
}
}