Merge pull request #741 from wanhose/v7.1.1

7.1.1
This commit is contained in:
wanhose 2024-08-04 14:33:42 +02:00 committed by GitHub
commit 7ef71c0d5c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 154 additions and 27 deletions

View File

@ -20,6 +20,7 @@
"database",
"docs",
"packages",
"rules",
"web"
]
]

View File

@ -1,7 +1,7 @@
{
"manifest_version": 3,
"name": "Cookie Dialog Monster",
"version": "7.1.0",
"version": "7.1.1",
"default_locale": "en",
"description": "__MSG_appDesc__",
"icons": {

View File

@ -6,8 +6,130 @@
"type": "block"
},
"condition": {
"urlFilter": "||cmp.inmobi.com^",
"resourceTypes": ["script"]
"resourceTypes": [
"font",
"image",
"media",
"object",
"script",
"stylesheet",
"xmlhttprequest"
],
"urlFilter": "||app.usercentrics.eu^"
}
},
{
"id": 2,
"priority": 1,
"action": {
"type": "block"
},
"condition": {
"resourceTypes": [
"font",
"image",
"media",
"object",
"script",
"stylesheet",
"xmlhttprequest"
],
"urlFilter": "||c.evidon.com^"
}
},
{
"id": 3,
"priority": 1,
"action": {
"type": "block"
},
"condition": {
"resourceTypes": [
"font",
"image",
"media",
"object",
"script",
"stylesheet",
"xmlhttprequest"
],
"urlFilter": "||cdn.cookielaw.org^"
}
},
{
"id": 4,
"priority": 1,
"action": {
"type": "block"
},
"condition": {
"resourceTypes": [
"font",
"image",
"media",
"object",
"script",
"stylesheet",
"xmlhttprequest"
],
"urlFilter": "||cmp.inmobi.com^"
}
},
{
"id": 5,
"priority": 1,
"action": {
"type": "block"
},
"condition": {
"resourceTypes": [
"font",
"image",
"media",
"object",
"script",
"stylesheet",
"xmlhttprequest"
],
"urlFilter": "||consent.trustarc.com^"
}
},
{
"id": 6,
"priority": 1,
"action": {
"type": "block"
},
"condition": {
"resourceTypes": [
"font",
"image",
"media",
"object",
"script",
"stylesheet",
"xmlhttprequest"
],
"urlFilter": "||optanon.blob.core.windows.net^"
}
},
{
"id": 7,
"priority": 1,
"action": {
"type": "block"
},
"condition": {
"resourceTypes": [
"font",
"image",
"media",
"object",
"script",
"stylesheet",
"xmlhttprequest"
],
"urlFilter": "||wcpstatic.microsoft.com^"
}
}
]

View File

@ -66,7 +66,10 @@ const options = { childList: true, subtree: true };
/**
* @description Is consent preview page?
*/
const preview = hostname.startsWith('consent.') || hostname.startsWith('myprivacy.');
const preview =
(hostname.startsWith('consent.') &&
!(hostname.startsWith('consent.google') || hostname.startsWith('consent.youtube'))) ||
hostname.startsWith('myprivacy.');
/**
* @description Elements that were already matched and are removable
@ -191,13 +194,16 @@ function getHostname() {
* @returns {boolean}
*/
function isInViewport(element) {
const styles = window.getComputedStyle(element);
const height = window.innerHeight || document.documentElement.clientHeight;
const position = element.getBoundingClientRect();
const scroll = window.scrollY;
const transitioning = styles.transitionDuration !== '0s';
return (
position.bottom === position.top ||
(scroll + position.top <= scroll + height && scroll + position.bottom >= scroll)
(scroll + position.top <= scroll + height && scroll + position.bottom >= scroll) ||
transitioning
);
}
@ -235,7 +241,9 @@ function match(element, skipMatch) {
return false;
}
if (element.hasAttributes()) {
const hasAttributes = !!element.getAttributeNames().filter((x) => x !== 'data-nosnippet').length;
if (hasAttributes) {
// 2023-06-10: fix #113 temporarily
if (element.classList.contains('chat-line__message')) {
return false;
@ -268,7 +276,11 @@ function match(element, skipMatch) {
* @returns {void}
*/
function fix() {
const backdrops = document.getElementsByClassName('modal-backdrop');
const backdrops = document.querySelectorAll([
'.modal-backdrop',
'.offcanvas-backdrop',
'.overlay',
]);
const domains = (skips?.domains ?? []).map((x) => (x.split('.').length < 3 ? `*${x}` : x));
for (const backdrop of backdrops) {
@ -320,19 +332,6 @@ function fix() {
}
}
/**
* @description Calculate reading time for the current page to avoid lags in large pages
* @returns {number}
*/
function readingTime() {
const text = document.body.innerText;
const wpm = 225;
const words = text.trim().split(/\s+/).length;
const time = Math.ceil(words / wpm);
return time;
}
/**
* @description Restore DOM to its previous state
* @returns {void}
@ -468,12 +467,18 @@ window.addEventListener(triggerEventName, (event) => {
if (event.detail?.elements) {
clean(event.detail.elements, event.detail.skipMatch);
} else {
if (readingTime() < 4) {
forceClean(document.body);
} else {
// 2023-06-13: look into the first level of the document body, there are dialogs there very often
clean([...document.body.children]);
}
// 2024-08-03: look into the first level of important nodes, there are dialogs there very often
clean([
...document.body.children,
...Array.from(document.getElementsByClassName('container')[0]?.children ?? []),
...Array.from(document.getElementsByClassName('layout')[0]?.children ?? []),
...Array.from(document.getElementsByClassName('page')[0]?.children ?? []),
...Array.from(document.getElementsByClassName('wrapper')[0]?.children ?? []),
...Array.from(document.getElementById('__next')?.children ?? []),
...Array.from(document.getElementById('app')?.children ?? []),
...Array.from(document.getElementById('main')?.children ?? []),
...Array.from(document.getElementById('root')?.children ?? []),
]);
}
}
});
@ -488,6 +493,5 @@ window.addEventListener('visibilitychange', async () => {
if (document.visibilityState === 'visible' && !initiallyVisible) {
initiallyVisible = true;
await run();
window.dispatchEvent(new CustomEvent(triggerEventName));
}
});