commit
b6eb3ef5fb
@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"manifest_version": 3,
|
"manifest_version": 3,
|
||||||
"name": "Cookie Dialog Monster",
|
"name": "Cookie Dialog Monster",
|
||||||
"version": "6.3.3",
|
"version": "6.3.4",
|
||||||
"default_locale": "en",
|
"default_locale": "en",
|
||||||
"description": "__MSG_appDesc__",
|
"description": "__MSG_appDesc__",
|
||||||
"icons": {
|
"icons": {
|
||||||
@ -24,6 +24,7 @@
|
|||||||
"*://*.googleapis.com/embed/*",
|
"*://*.googleapis.com/embed/*",
|
||||||
"*://*.sharepoint.com/*",
|
"*://*.sharepoint.com/*",
|
||||||
"*://*.youtube.com/embed/*",
|
"*://*.youtube.com/embed/*",
|
||||||
|
"*://*.youtube-nocookie.com/embed/*",
|
||||||
"https://www.cookie-dialog-monster.com/*"
|
"https://www.cookie-dialog-monster.com/*"
|
||||||
],
|
],
|
||||||
"js": ["scripts/content.js", "scripts/dialog.js"],
|
"js": ["scripts/content.js", "scripts/dialog.js"],
|
||||||
|
@ -48,7 +48,7 @@
|
|||||||
<span data-i18n="popup_helpOption"></span>
|
<span data-i18n="popup_helpOption"></span>
|
||||||
</popup-button>
|
</popup-button>
|
||||||
<popup-button
|
<popup-button
|
||||||
data-href="https://www.github.com/wanhose/cookie-dialog-monster"
|
data-href="https://github.com/wanhose/cookie-dialog-monster"
|
||||||
id="contribute-option"
|
id="contribute-option"
|
||||||
role="link"
|
role="link"
|
||||||
tabindex="0"
|
tabindex="0"
|
||||||
|
@ -56,27 +56,12 @@ function clean(elements, skipMatch) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @description Flat child nodes for a given element
|
|
||||||
* @param {HTMLElement} element
|
|
||||||
* @returns {number[]}
|
|
||||||
*/
|
|
||||||
|
|
||||||
function flatElement(element) {
|
|
||||||
return [...element.childNodes].flatMap((childNode) =>
|
|
||||||
childNode.nodeType === Node.TEXT_NODE
|
|
||||||
? [childNode.nodeType]
|
|
||||||
: [...[...childNode.childNodes].map((x) => x.nodeType)]
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @description Forces a DOM clean in the specific element
|
* @description Forces a DOM clean in the specific element
|
||||||
* @param {HTMLElement} element
|
* @param {HTMLElement} element
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function forceClean(element) {
|
function forceClean(element) {
|
||||||
if (data?.elements.length && state.enabled && !preview) {
|
|
||||||
const elements = [...element.querySelectorAll(data.elements)];
|
const elements = [...element.querySelectorAll(data.elements)];
|
||||||
|
|
||||||
if (elements.length) {
|
if (elements.length) {
|
||||||
@ -84,7 +69,6 @@ function forceClean(element) {
|
|||||||
clean(elements, true);
|
clean(elements, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @description Forces element to have these styles
|
* @description Forces element to have these styles
|
||||||
@ -132,10 +116,6 @@ function match(element, skipMatch) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (element.childNodes.length && flatElement(element).every((x) => x === Node.TEXT_NODE)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (element.hasAttributes()) {
|
if (element.hasAttributes()) {
|
||||||
return (
|
return (
|
||||||
// 2023-06-10: twitch.tv temporary fix
|
// 2023-06-10: twitch.tv temporary fix
|
||||||
@ -233,14 +213,12 @@ const observer = new MutationObserver((mutations) => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @description Fixes already existing element when page load issues
|
* @description Fixes still existing elements when page fully load
|
||||||
* @listens window#DOMContentLoaded
|
* @listens window#load
|
||||||
*/
|
*/
|
||||||
|
|
||||||
window.addEventListener('DOMContentLoaded', () => {
|
window.addEventListener('load', () => {
|
||||||
if (readingTime() < 4) {
|
window.dispatchEvent(new Event('run'));
|
||||||
forceClean(document.body);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -250,7 +228,23 @@ window.addEventListener('DOMContentLoaded', () => {
|
|||||||
|
|
||||||
window.addEventListener('pageshow', (event) => {
|
window.addEventListener('pageshow', (event) => {
|
||||||
if (event.persisted) {
|
if (event.persisted) {
|
||||||
|
window.dispatchEvent(new Event('run'));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description Forces a clean when this event is fired
|
||||||
|
* @listens window#run
|
||||||
|
*/
|
||||||
|
|
||||||
|
window.addEventListener('run', () => {
|
||||||
|
if (data?.elements.length && state.enabled && !preview) {
|
||||||
|
if (readingTime() < 4) {
|
||||||
forceClean(document.body);
|
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]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -265,6 +259,12 @@ window.addEventListener('pageshow', (event) => {
|
|||||||
|
|
||||||
if (state.enabled) {
|
if (state.enabled) {
|
||||||
data = await dispatch({ hostname, type: 'GET_DATA' });
|
data = await dispatch({ hostname, type: 'GET_DATA' });
|
||||||
|
|
||||||
|
// 2023-06-13: hack to force clean when data request takes too long and there are no changes later
|
||||||
|
if (document.readyState === 'complete') {
|
||||||
|
window.dispatchEvent(new Event('run'));
|
||||||
|
}
|
||||||
|
|
||||||
dispatch({ type: 'ENABLE_ICON' });
|
dispatch({ type: 'ENABLE_ICON' });
|
||||||
observer.observe(document.body ?? document.documentElement, options);
|
observer.observe(document.body ?? document.documentElement, options);
|
||||||
}
|
}
|
||||||
|
@ -100,7 +100,7 @@
|
|||||||
</a>
|
</a>
|
||||||
<a
|
<a
|
||||||
class="contents"
|
class="contents"
|
||||||
href="https://www.github.com/wanhose/cookie-dialog-monster"
|
href="https://github.com/wanhose/cookie-dialog-monster"
|
||||||
target="_blank"
|
target="_blank"
|
||||||
title="GitHub"
|
title="GitHub"
|
||||||
>
|
>
|
||||||
@ -313,7 +313,7 @@
|
|||||||
<h3 class="font-medium mt-4 text-lg text-secondary">Open source</h3>
|
<h3 class="font-medium mt-4 text-lg text-secondary">Open source</h3>
|
||||||
<p class="mt-2 text-gray-500">
|
<p class="mt-2 text-gray-500">
|
||||||
Feel free to contribute to our
|
Feel free to contribute to our
|
||||||
<a href="https://www.github.com/wanhose/cookie-dialog-monster/pulls" target="_blank">
|
<a href="https://github.com/wanhose/cookie-dialog-monster/pulls" target="_blank">
|
||||||
GitHub repository
|
GitHub repository
|
||||||
</a>
|
</a>
|
||||||
</p>
|
</p>
|
||||||
@ -442,9 +442,7 @@
|
|||||||
<div class="max-w-5xl mx-auto">
|
<div class="max-w-5xl mx-auto">
|
||||||
<p class="text-center text-white text-sm">
|
<p class="text-center text-white text-sm">
|
||||||
An open source project built by you and
|
An open source project built by you and
|
||||||
<a class="hover:underline" href="https://www.github.com/wanhose" target="_blank">
|
<a class="hover:underline" href="https://github.com/wanhose" target="_blank"> wanhose</a>
|
||||||
wanhose
|
|
||||||
</a>
|
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</footer>
|
</footer>
|
||||||
|
Loading…
Reference in New Issue
Block a user