Merge pull request #423 from wanhose/v6.4.8

6.4.8
This commit is contained in:
wanhose 2024-02-27 12:11:36 +01:00 committed by GitHub
commit 3bfcbba8be
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 27 additions and 7 deletions

View File

@ -1,7 +1,7 @@
{ {
"manifest_version": 3, "manifest_version": 3,
"name": "Cookie Dialog Monster", "name": "Cookie Dialog Monster",
"version": "6.4.7", "version": "6.4.8",
"default_locale": "en", "default_locale": "en",
"description": "__MSG_appDesc__", "description": "__MSG_appDesc__",
"icons": { "icons": {
@ -22,6 +22,7 @@
{ {
"all_frames": true, "all_frames": true,
"exclude_matches": [ "exclude_matches": [
"*://*.bauhaus.cz/*",
"*://*.codesandbox.io/*", "*://*.codesandbox.io/*",
"*://*.facebook.com/*", "*://*.facebook.com/*",
"*://*.googleapis.com/embed/*", "*://*.googleapis.com/embed/*",

View File

@ -26,6 +26,12 @@ const options = { childList: true, subtree: true };
*/ */
const preview = hostname.startsWith('consent.') || hostname.startsWith('myprivacy.'); const preview = hostname.startsWith('consent.') || hostname.startsWith('myprivacy.');
/**
* @description Elements that were already seen
* @type {HTMLElement[]}
*/
const seen = [];
/** /**
* @description Extension state * @description Extension state
* @type {{ enabled: boolean }} * @type {{ enabled: boolean }}
@ -117,16 +123,29 @@ function match(element, skipMatch) {
return false; return false;
} }
if (!data?.tags?.length || data.tags.includes(element.tagName?.toUpperCase?.())) { const tagName = element.tagName?.toUpperCase?.();
if (!data?.tags?.length || data.tags.includes(tagName)) {
return false; return false;
} }
if (seen.includes(element)) {
return false;
}
seen.push(element);
if (element.hasAttributes()) { if (element.hasAttributes()) {
// 2023-06-10: twitch.tv temporary fix
if (element.classList.contains('chat-line__message')) {
return false;
}
const isDialog = tagName === 'DIALOG' && element.getAttribute('open') === 'true';
const isFakeDialog = tagName === 'DIV' && element.className.includes('cmp');
return ( return (
// 2023-06-10: twitch.tv temporary fix (isDialog || isFakeDialog || isInViewport(element)) &&
!element.classList.contains('chat-line__message') &&
// ...
isInViewport(element) &&
(skipMatch || element.matches(data?.elements ?? [])) (skipMatch || element.matches(data?.elements ?? []))
); );
} else { } else {
@ -226,7 +245,7 @@ async function runSetup(skipReadyStateHack) {
* @type {MutationObserver} * @type {MutationObserver}
*/ */
const observer = new MutationObserver((mutations) => { const observer = new MutationObserver((mutations) => {
const elements = mutations.map((mutation) => Array.from(mutation.addedNodes)).flat(); const elements = mutations.map((mutation) => Array.from(mutation.addedNodes)).flat(1);
fix(); fix();
if (data?.elements.length && !preview) clean(elements); if (data?.elements.length && !preview) clean(elements);