How to use the @cliqz/adblocker-electron.ElectronBlocker.fromLists function in @cliqz/adblocker-electron

To help you get started, we’ve selected a few @cliqz/adblocker-electron examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github oscartbeaumont / ElectronPlayer / src / main.js View on Github external
});

  // Connect Adblocker To Window if Enabled
  if (store.get('options.adblock')) {
    let engineCachePath = path.join(
      app.getPath('userData'),
      'adblock-engine-cache.txt'
    );

    if (fs.existsSync(engineCachePath)) {
      console.log('Adblock engine cache found. Loading it into app.');
      var engine = await ElectronBlocker.deserialize(
        fs.readFileSync(engineCachePath)
      );
    } else {
      var engine = await ElectronBlocker.fromLists(fetch, fullLists);
    }
    engine.enableBlockingInSession(session.defaultSession);

    // Backup Engine Cache to Disk
    fs.writeFile(engineCachePath, engine.serialize(), err => {
      if (err) throw err;
      console.log('Adblock Engine file cache has been updated!');
    });
  }

  // Reset The Windows Size and Location
  let windowDetails = store.get('options.windowDetails');
  let relaunchWindowDetails = store.get('relaunch.windowDetails');
  if (relaunchWindowDetails) {
    mainWindow.setSize(
      relaunchWindowDetails.size[0],
github cliqz-oss / adblocker / packages / adblocker-electron-example / index.ts View on Github external
async function createWindow() {
  mainWindow = new BrowserWindow({
    height: 600,
    width: 800,
  });

  if (session.defaultSession === undefined) {
    throw new Error('defaultSession is undefined');
  }

  const blocker = await ElectronBlocker.fromLists(fetch, fullLists, {
    enableCompression: true,
  });
  blocker.enableBlockingInSession(session.defaultSession);

  blocker.on('request-blocked', (request: Request) => {
    console.log('blocked', request.tabId, request.url);
  });

  blocker.on('request-redirected', (request: Request) => {
    console.log('redirected', request.tabId, request.url);
  });

  blocker.on('request-whitelisted', (request: Request) => {
    console.log('whitelisted', request.tabId, request.url);
  });

@cliqz/adblocker-electron

Ghostery adblocker Electron wrapper

MPL-2.0
Latest version published 1 month ago

Package Health Score

51 / 100
Full package analysis

Similar packages