feat(content): add support for onetrust

This commit is contained in:
wanhose 2020-04-24 19:42:06 +02:00 committed by wanhose
parent f3cf94afa7
commit 74120d382a

View File

@ -1,38 +1,43 @@
if (typeof chrome.app.isInstalled !== 'undefined') { if (typeof chrome.app.isInstalled !== 'undefined') {
// Observer // Observer
const observer = new MutationObserver((mutations, observer) => { const observer = new MutationObserver((mutations, observer) => {
for (let mutation of mutations) { for (let mutation of mutations) {
if (mutation.type === 'childList') { if (mutation.type === 'childList') {
observer.disconnect(); observer.disconnect();
doMagic(); doMagic();
observe(); observe();
}
} }
}
});
// Inject buttons
const doMagic = () => {
// Quantcast
const notRemovableElements = Array.from(document.getElementsByClassName("qc-cmp-ui-showing"));
notRemovableElements.forEach(element => {
element.classList.remove("qc-cmp-ui-showing");
}); });
// Inject buttons const removableElements = Array.from(document.getElementsByClassName("qc-cmp-ui-container"));
const doMagic = () => { removableElements.forEach(element => {
const notRemovableElements = Array.from(document.getElementsByClassName("qc-cmp-ui-showing")); element.remove();
notRemovableElements.forEach(element => { });
element.classList.remove("qc-cmp-ui-showing");
});
const removableElements = Array.from(document.getElementsByClassName("qc-cmp-ui-container")); // OneTrust
removableElements.forEach(element => { const removableElement = document.getElementById("onetrust-consent-sdk");
element.remove(); if (!!removableElement) removableElement.remove();
}); };
};
// Observer starts observe when call this function // Observer starts observe when call this function
const observe = () => { const observe = () => {
observer.observe(document.body, { observer.observe(document.body, {
childList: true, childList: true,
subtree: true, subtree: true,
//... //...
}); });
}; };
// Then... // Then...
doMagic(); doMagic();
observe(); observe();
} }