Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide helpers to download and build engines from lists #280

Merged
merged 1 commit into from
Aug 16, 2019

Conversation

remusao
Copy link
Collaborator

@remusao remusao commented Aug 16, 2019

This change allows to start blocking ads with very little logic in Webextension, Electron and Puppeteer platforms! To achieve this, blockers abstraction now provide static methods to fetch pre-built engines from Cliqz's CDN or build them from scratch using lists of URLs to subscriptions. Here is how it looks like:

Webextension:

import { WebExtensionBlocker } from '@cliqz/adblocker-webextension';

WebExtensionBlocker.fromPrebuiltAdsAndTracking(fetch).then((blocker) => {
  blocker.enableBlockingInBrowser();
});

Electron:

import { session } from 'electron';
import fetch from 'cross-fetch'; // or 'node-fetch'

import { ElectronBlocker } from '@cliqz/adblocker-electron';

ElectronBlocker.fromPrebuiltAdsAndTracking(fetch).then((blocker) => {
  blocker.enableBlockingInSession(session.defaultSession);
});

Puppeteer:

import puppeteer from 'puppeteer';
import fetch from 'cross-fetch'; // or 'node-fetch'

import { PuppeteerBlocker } from '@cliqz/adblocker-puppeteer';

const browser = await puppeteer.launch();
const page = await browser.newPage();

PuppeteerBlocker.fromPrebuiltAdsAndTracking(fetch).then((blocker) => {
  blocker.enableBlockingInPage(page);
});

Fixes #216

@remusao remusao force-pushed the engine-download-utils branch from 192836b to 2c7dc68 Compare August 16, 2019 12:36
@remusao remusao merged commit 38a2bb4 into ghostery:master Aug 16, 2019
@remusao remusao mentioned this pull request Aug 16, 2019
@remusao remusao deleted the engine-download-utils branch September 5, 2019 11:39
@remusao remusao changed the title provide helpers to download and build engines from lists Provide helpers to download and build engines from lists Feb 12, 2020
@remusao remusao added the PR: New Feature 🚀 Increment minor version when merged label Feb 12, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
PR: New Feature 🚀 Increment minor version when merged
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Provide helpers to download filters/engines and update
1 participant