Merge pull request #23 from wanhose/5.3.2

5.3.2
This commit is contained in:
wanhose 2021-11-06 20:14:33 +01:00 committed by GitHub
commit ef79120392
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 35 additions and 13 deletions

View File

@ -1,7 +1,7 @@
{
"manifest_version": 2,
"name": "Cookie Dialog Monster",
"version": "5.3.1",
"version": "5.3.2",
"default_locale": "en",
"description": "__MSG_appDesc__",
"icons": {

View File

@ -12,6 +12,12 @@ let classes = [];
const dispatch = chrome.runtime.sendMessage;
/**
* @description Is consent preview page?
*/
const isConsentPreview = document.location.host.startsWith("consent.");
/**
* @description Options provided to observer
*/
@ -50,7 +56,9 @@ const clean = () => {
const fix = () => {
const body = document.body;
const facebook = document.getElementsByClassName("_31e")[0];
const google = document.querySelector('form[action*="consent.google"]');
const html = document.documentElement;
const yahoo = document.querySelector("#consent-page");
if (body) {
if (classes.length) body.classList.remove(...classes);
@ -62,17 +70,26 @@ const fix = () => {
facebook.style.setProperty("position", "initial", "important");
}
if (google) {
google.querySelector("button").click();
}
if (html) {
if (classes.length) html.classList.remove(...classes);
html.style.setProperty("position", "initial", "important");
html.style.setProperty("overflow-y", "initial", "important");
}
if (yahoo) {
yahoo.querySelector('button[type="submit"]').click();
}
};
const observer = new MutationObserver((mutations, instance) => {
instance.disconnect();
fix();
if (!isConsentPreview) {
for (let i = mutations.length; i--; ) {
const mutation = mutations[i];
@ -88,6 +105,7 @@ const observer = new MutationObserver((mutations, instance) => {
if (node.matches(selectors)) node.outerHTML = "";
}
}
}
instance.observe(target, options);
});
@ -118,9 +136,13 @@ const setupSelectors = () =>
document.addEventListener("readystatechange", () => {
if (document.readyState === "complete") {
fix();
if (!isConsentPreview) {
clean();
setTimeout(clean, 2000);
}
}
});
/**