Merge pull request #35 from wanhose/5.4.5

5.4.5
This commit is contained in:
wanhose 2022-01-09 12:12:40 +01:00 committed by GitHub
commit 3b6fa84cc4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 21 additions and 44 deletions

View File

@ -1,7 +1,7 @@
{ {
"manifest_version": 2, "manifest_version": 2,
"name": "Cookie Dialog Monster", "name": "Cookie Dialog Monster",
"version": "5.4.4", "version": "5.4.5",
"default_locale": "en", "default_locale": "en",
"description": "__MSG_appDesc__", "description": "__MSG_appDesc__",
"icons": { "icons": {
@ -19,7 +19,6 @@
}, },
"content_scripts": [ "content_scripts": [
{ {
"all_frames": true,
"exclude_matches": [ "exclude_matches": [
"*://*.gfycat.com/*", "*://*.gfycat.com/*",
"*://*.gmx.com/*", "*://*.gmx.com/*",

View File

@ -68,13 +68,8 @@ const check = (node) =>
const clean = () => { const clean = () => {
if (selectors.length) { if (selectors.length) {
const nodes = document.querySelectorAll(selectors); const nodes = Array.from(document.querySelectorAll(selectors));
nodes.filter(check).forEach((node) => (node.outerHTML = ""));
nodes.forEach((node) => {
const valid = check(node);
if (valid) node.outerHTML = "";
});
} }
}; };
@ -84,20 +79,14 @@ const clean = () => {
const fix = () => { const fix = () => {
const body = document.body; const body = document.body;
const frame = !(window === window.parent || window.opener);
const html = document.documentElement; const html = document.documentElement;
if (body && html) { body?.classList.remove(...classes);
body.classList.remove(...classes); body?.style.setProperty("position", "initial", "important");
html.classList.remove(...classes); body?.style.setProperty("overflow-y", "initial", "important");
html?.classList.remove(...classes);
if (!frame) { html?.style.setProperty("position", "initial", "important");
body.style.setProperty("position", "initial", "important"); html?.style.setProperty("overflow-y", "initial", "important");
body.style.setProperty("overflow-y", "initial", "important");
html.style.setProperty("position", "initial", "important");
html.style.setProperty("overflow-y", "initial", "important");
}
}
fixes.forEach((fix) => { fixes.forEach((fix) => {
const [match, selector, action, property] = fix.split("##"); const [match, selector, action, property] = fix.split("##");
@ -106,26 +95,17 @@ const fix = () => {
switch (action) { switch (action) {
case "click": case "click":
const submit = document.querySelector(selector); const submit = document.querySelector(selector);
submit?.click?.();
if (submit && submit instanceof HTMLElement) {
submit.click();
}
break; break;
case "reset": case "reset":
const node = document.querySelector(selector); const node = document.querySelector(selector);
node?.style?.setProperty?.(property, "initial", "important");
if (node && node instanceof HTMLElement) {
node.style.setProperty(property, "initial", "important");
}
break; break;
case "resetAll": case "resetAll":
const nodes = document.querySelectorAll(selector); const nodes = document.querySelectorAll(selector);
nodes.forEach((node) =>
nodes.forEach((node) => { node?.style?.setProperty?.(property, "initial", "important")
if (node instanceof HTMLElement) { );
node.style.setProperty(property, "initial", "important");
}
});
break; break;
default: default:
break; break;
@ -211,15 +191,13 @@ dispatch({ hostname, type: "GET_CACHE" }, null, async ({ enabled }) => {
dispatch({ type: "ENABLE_POPUP" }); dispatch({ type: "ENABLE_POPUP" });
if (enabled) { if (enabled) {
dispatch({ type: "ENABLE_ICON" }); const promises = [queryClasses(), queryFixes(), querySelectors()];
const results = await Promise.all([ const results = await Promise.all(promises);
queryClasses(),
queryFixes(), classes = results[0]?.classes ?? [];
querySelectors(), fixes = results[1]?.fixes ?? [];
]); selectors = results[2]?.selectors ?? [];
classes = results[0].classes;
fixes = results[1].fixes;
selectors = results[2].selectors;
observer.observe(target, options); observer.observe(target, options);
dispatch({ type: "ENABLE_ICON" });
} }
}); });