@cliqz/autoconsent
Version:
This is a library of rules for navigating through common consent popups on the web. These rules can be run in a Firefox webextension, or in a puppeteer orchestrated headless browser. Using these rules, opt-in and opt-out options can be selected automatica
32 lines (31 loc) • 1.17 kB
JavaScript
import AutoConsentBase from "./base";
// Note: JS API is also available:
// https://help.consentmanager.net/books/cmp/page/javascript-api
export default class ConsentManager extends AutoConsentBase {
constructor() {
super("consentmanager.net");
this.prehideSelectors = ["#cmpbox,#cmpbox2"];
}
detectCmp(tab) {
return tab.elementExists("#cmpbox");
}
detectPopup(tab) {
return tab.elementsAreVisible("#cmpbox .cmpmore", "any");
}
async optOut(tab) {
if (await tab.elementExists(".cmpboxbtnno")) {
return tab.clickElement(".cmpboxbtnno");
}
if (await tab.elementExists(".cmpwelcomeprpsbtn")) {
await tab.clickElements(".cmpwelcomeprpsbtn > a[aria-checked=true]");
return await tab.clickElement(".cmpboxbtnsave");
}
await tab.clickElement(".cmpboxbtncustom");
await tab.waitForElement(".cmptblbox", 2000);
await tab.clickElements(".cmptdchoice > a[aria-checked=true]");
return tab.clickElement(".cmpboxbtnyescustomchoices");
}
async optIn(tab) {
return tab.clickElement(".cmpboxbtnyes");
}
}