feat(scripts): bypass google and yahoo preview pages
This commit is contained in:
parent
49bc4ab22d
commit
7f968a57f0
@ -12,6 +12,12 @@ let classes = [];
|
|||||||
|
|
||||||
const dispatch = chrome.runtime.sendMessage;
|
const dispatch = chrome.runtime.sendMessage;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description Is consent preview page?
|
||||||
|
*/
|
||||||
|
|
||||||
|
const isConsentPreview = document.location.host.startsWith("consent.");
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @description Options provided to observer
|
* @description Options provided to observer
|
||||||
*/
|
*/
|
||||||
@ -50,7 +56,9 @@ const clean = () => {
|
|||||||
const fix = () => {
|
const fix = () => {
|
||||||
const body = document.body;
|
const body = document.body;
|
||||||
const facebook = document.getElementsByClassName("_31e")[0];
|
const facebook = document.getElementsByClassName("_31e")[0];
|
||||||
|
const google = document.querySelector('form[action*="consent.google"]');
|
||||||
const html = document.documentElement;
|
const html = document.documentElement;
|
||||||
|
const yahoo = document.querySelector("#consent-page");
|
||||||
|
|
||||||
if (body) {
|
if (body) {
|
||||||
if (classes.length) body.classList.remove(...classes);
|
if (classes.length) body.classList.remove(...classes);
|
||||||
@ -62,30 +70,40 @@ const fix = () => {
|
|||||||
facebook.style.setProperty("position", "initial", "important");
|
facebook.style.setProperty("position", "initial", "important");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (google) {
|
||||||
|
google.querySelector("button").click();
|
||||||
|
}
|
||||||
|
|
||||||
if (html) {
|
if (html) {
|
||||||
if (classes.length) html.classList.remove(...classes);
|
if (classes.length) html.classList.remove(...classes);
|
||||||
html.style.setProperty("position", "initial", "important");
|
html.style.setProperty("position", "initial", "important");
|
||||||
html.style.setProperty("overflow-y", "initial", "important");
|
html.style.setProperty("overflow-y", "initial", "important");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (yahoo) {
|
||||||
|
yahoo.querySelector('button[type="submit"]').click();
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const observer = new MutationObserver((mutations, instance) => {
|
const observer = new MutationObserver((mutations, instance) => {
|
||||||
instance.disconnect();
|
instance.disconnect();
|
||||||
fix();
|
fix();
|
||||||
|
|
||||||
for (let i = mutations.length; i--; ) {
|
if (!isConsentPreview) {
|
||||||
const mutation = mutations[i];
|
for (let i = mutations.length; i--; ) {
|
||||||
|
const mutation = mutations[i];
|
||||||
|
|
||||||
for (let j = mutation.addedNodes.length; j--; ) {
|
for (let j = mutation.addedNodes.length; j--; ) {
|
||||||
const node = mutation.addedNodes[j];
|
const node = mutation.addedNodes[j];
|
||||||
const valid =
|
const valid =
|
||||||
node instanceof HTMLElement &&
|
node instanceof HTMLElement &&
|
||||||
node.parentElement &&
|
node.parentElement &&
|
||||||
!["BODY", "HTML"].includes(node.tagName);
|
!["BODY", "HTML"].includes(node.tagName);
|
||||||
|
|
||||||
if (!valid) continue;
|
if (!valid) continue;
|
||||||
|
|
||||||
if (node.matches(selectors)) node.outerHTML = "";
|
if (node.matches(selectors)) node.outerHTML = "";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -118,8 +136,12 @@ const setupSelectors = () =>
|
|||||||
|
|
||||||
document.addEventListener("readystatechange", () => {
|
document.addEventListener("readystatechange", () => {
|
||||||
if (document.readyState === "complete") {
|
if (document.readyState === "complete") {
|
||||||
clean();
|
fix();
|
||||||
setTimeout(clean, 2000);
|
|
||||||
|
if (!isConsentPreview) {
|
||||||
|
clean();
|
||||||
|
setTimeout(clean, 2000);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user