fix(browser-extension): issue #910

This commit is contained in:
wanhose 2024-09-08 08:25:14 +02:00
parent 0fa2d371f0
commit 5890f81376
2 changed files with 16 additions and 8 deletions

View File

@ -6809,6 +6809,7 @@
"[class$=\"UpdatePanelCookie\"]",
"[cnn-cookie-policy]",
"[consent-skip-blocker][data-bg]",
"[consent-skip-blocker][data-bg] > dialog",
"[cookie-unique-name]",
"[css-main-site] #policy-div",
"[data-acris-cookie-consent=\"true\"]",
@ -13869,5 +13870,5 @@
"ytm-consent-bump-v2-renderer"
]
},
"version": "1725705123996"
"version": "1725776505494"
}

View File

@ -125,8 +125,12 @@ function clean(elements, skipMatch) {
if (match(element, skipMatch)) {
const observer = new MutationObserver(forceElementStyles);
if (element instanceof HTMLDialogElement) {
element.close();
} else {
element.setAttribute(dataAttributeName, 'true');
element.style.setProperty('display', 'none', 'important');
}
observer.observe(element, {
attributes: true,
@ -185,8 +189,6 @@ function forceElementStyles(mutations, observer) {
if (value === null) {
observer.disconnect();
element.removeAttribute(dataAttributeName);
element.style.removeProperty('display');
} else {
element.style.setProperty('display', 'none', 'important');
}
@ -289,6 +291,8 @@ function match(element, skipMatch) {
const hasAttributes = !!element.getAttributeNames().filter((x) => x !== 'data-nosnippet').length;
console.log(element);
if (!hasAttributes && !tagName.includes('-')) {
forceClean(element);
}
@ -404,10 +408,13 @@ function restoreDOM() {
}
}
const elements = getElements(`[${dataAttributeName}]`);
for (const element of elements) {
for (const element of removables) {
element.removeAttribute(dataAttributeName);
element.style.removeProperty('display');
if (element instanceof HTMLDialogElement) {
element.showModal();
}
}
for (const element of [document.body, document.documentElement]) {