Specifically accept/reject cookie popup keeping ads
teammakdi opened this issue · 4 comments
I'm looking to specifically just accept/reject cookie popups without disabling ads and trackers. There is no function exposed to do the same, there's fromPrebuiltFull
but it disables ads and trackers as well.
I've created a demo script for the same.
import puppeteer from 'puppeteer';
import {
PuppeteerBlocker
} from '@cliqz/adblocker-puppeteer';
import fetch from 'cross-fetch';
const browser = await puppeteer.launch();
const page = await browser.newPage();
await page.setViewport({
width: 1080,
height: 1024
});
await PuppeteerBlocker.fromLists(fetch, [
"https://raw.githubusercontent.com/cliqz-oss/adblocker/master/packages/adblocker/assets/ublock-origin/annoyances.txt",
"https://raw.githubusercontent.com/cliqz-oss/adblocker/master/packages/adblocker/assets/easylist/easylist-cookie.txt",
], {
loadNetworkFilters: false
}).then((blocker) => {
blocker.enableBlockingInPage(page);
});
await page.goto('https://www.rightmove.co.uk/');
await page.screenshot({
path: 'screenshot.jpg'
});
await browser.close();
It works as expected by keeping ads and just blocking cookie popups.
Does the assets look enough to address cookie popups?
I'm not sure if ublock-origin/annoyances-others.txt
is to be included.
Possibly we can expose a function for the same.
Also by default it rejects the cookie popup, is there a functionality to accept the same?
Hi @teammakdi ,
To be clear, there's no functionality to accept or reject the cookie popup on the above lists. They tend to block the cookie popup by blocking the requests to CMPs (Consent Management Platform). Thus the role of those lists are to completely remove the interaction between the user and CMP. If you're looking for an automation script that actually takes an action to "reject" or "accept" the cookies, please check out the autoconsent project by duckduckgo.
I hope this made a progress on your question.
Thanks
Got it. Thanks.
![image](https://private-user-images.githubusercontent.com/125042792/350968152-14ab2887-ac02-4e20-9d85-9abb2dade555.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MzA0NzE2MTEsIm5iZiI6MTczMDQ3MTMxMSwicGF0aCI6Ii8xMjUwNDI3OTIvMzUwOTY4MTUyLTE0YWIyODg3LWFjMDItNGUyMC05ZDg1LTlhYmIyZGFkZTU1NS5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjQxMTAxJTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI0MTEwMVQxNDI4MzFaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT1mNTI4MDAyZjBkNjcxYjc1NzhjYTc5Mzc3M2ViZmZjYjIyNmFiMzM4NTYwYzNmYzQzNWZmYzk1NDJmYTc5ZWJlJlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCJ9.0A5GHddVeoMu_uPCI7vovvnvD0zNUaXXdzdbhIO3T7U)
So just to confirm the ghostery web extension uses https://github.com/duckduckgo/autoconsent to reject the cookies.
Also any idea how could I access the domain info
![image](https://private-user-images.githubusercontent.com/125042792/350968724-86c44124-27e0-4814-b466-98791083bbef.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MzA0NzE2MTEsIm5iZiI6MTczMDQ3MTMxMSwicGF0aCI6Ii8xMjUwNDI3OTIvMzUwOTY4NzI0LTg2YzQ0MTI0LTI3ZTAtNDgxNC1iNDY2LTk4NzkxMDgzYmJlZi5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjQxMTAxJTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI0MTEwMVQxNDI4MzFaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT05MjQxZTdkM2U1NjQ2OTA0OWY5MWY5ZGFlODU3MzI3MmY2NmNhNWJjZGQ2MTQ4ZGYxOGE5MGRkNzUxOTM1YjE0JlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCJ9.6AQENu_84P_uJLb6bSn1rvv3W03dGFL2tAA3xyXHHfU)
In puppeteer?
Hi @teammakdi ,
First, Ghostery Browser Extension mixes multiple filter lists of blocking cookies not only autoconsent to provide the maximum coverage.
Second, this repository only represents the core functionality of the request matching and cosmetic data formation. Thus we don't have a full functionality of Ghostery Browser Extension in this repository. How you implement things depends on your goal not the library. Those domain information is provided by our another project: TrackerDB.
Best