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

View File

@ -26,6 +26,12 @@ const options = { childList: true, subtree: true };
*/
const preview = hostname.startsWith('consent.') || hostname.startsWith('myprivacy.');
/**
* @description Elements that were already seen
* @type {HTMLElement[]}
*/
const seen = [];
/**
* @description Extension state
* @type {{ enabled: boolean }}
@ -117,16 +123,29 @@ function match(element, skipMatch) {
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;
}
if (seen.includes(element)) {
return false;
}
seen.push(element);
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 (
// 2023-06-10: twitch.tv temporary fix
!element.classList.contains('chat-line__message') &&
// ...
isInViewport(element) &&
(isDialog || isFakeDialog || isInViewport(element)) &&
(skipMatch || element.matches(data?.elements ?? []))
);
} else {
@ -226,7 +245,7 @@ async function runSetup(skipReadyStateHack) {
* @type {MutationObserver}
*/
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();
if (data?.elements.length && !preview) clean(elements);