Electron Ad Blocker Save

Blocks advertisements in an electron browser window

Project README

Electron ad blocker

Blocks advertisements in an electron browser window.

Build from source

Because this module contains native modules, it should build from source for the correct version of node of your electron distribution (and not the default one on your machine). If you know how to do this, you can skip this. If not, I wrote a short tutorial for you.

Getting Started

$ yarn add electron-ad-blocker
const { BrowserWindow } = require('electron');
const { blockWindowAds, adBlocker } = require('electron-ad-blocker');

const options = {
  verbose: true,
  logger: console,
};

const mainWindow = new BrowserWindow({ width: 800, height: 600 });
blockWindowAds(mainWindow, options);

// You can also blacklist other websites, since adBlocker is the
// client instance of the contains-ads module.
adBlocker.parse('||blacklistwebsite.com')

Possible options

logger (console): A custom logger instance to use.
verbose (false): Whether or not the ad blocker should log when he blocks a request.
onRequest (undefined): Gets called like the original onRequest of a BrowserWindow instance.

blockWindowAds(browserWindow, {
  verbose: true,
  logger: console,
  onRequest: (details, callback, shouldBeBlocked) => {
    // Execute your own onRequest function here...
  },
});
Open Source Agenda is not affiliated with "Electron Ad Blocker" Project. README Source: Jense5/electron-ad-blocker
Stars
53
Open Issues
3
Last Commit
5 years ago

Open Source Agenda Badge

Open Source Agenda Rating