Is there any ad-block module for Electron?


#1

Hi,
I’m making a beautifully browser which users browser the site on a webview tag. I want to add a adblock module which block ads on that webview tag based on a .txt file. I have read this topic and try Jense5’s module, when I install, I got this error. I currently using the pure NodeJS that installed from their website.
Can somebody help me?
Thanks


#2

Hello

I am working in a browser-like environment too and I added an adblock to it a couple of months ago. I started using Jense5’s adblock, however, as it was designed to be used with electron’s windows instead of webviews and because it uses brave’s ad-block, I ended using its Jense5’s code as a base to develop my own system to be used in webview tags, using brave’s adblock directly.

First of all I should point out that Jense5 uses Brave’s adblock is a native module, and npm compiles it to the node version you installed, and it should be compiled in the electron’s version of node. Jense5 explains it in his tutorial. However, modules like electron-builder simplify the compilation of native modules without that tutorial.

Now, when reading the error you got, I can’t help but notice that it seems to be related with brave adblock’s bloom-filter-cpp, hashset-cpp. Both files have been giving trouble lately, seems that they changed the code, and now some node’s can’t compile them (and that includes electron’s version). Furthermore, even if you force your project to use a certain old version of those files, inside of the package they force the system to use the newest version, so basically, after that update, most people using electron can’t use brave’s adblock anymore. I realized that when one day, out of the blue, brave’s adblock stop working in my project.

In order quick to solve the project’s problem, I did a fork of brave’s adblock, reverted to an early version - bloom-filter and hashset weren’t the only files that prevented it for being compiled - and forced its package.json to install the old version of those modules, so I could guarantee that I had a functional version. I also started an issue to brave, and, as for today, I think is not fixed yet.

I hope this helps you.

note: knowing that you are working with adblock, you might find yourself with the same problem I have right now if you want to do the adblock at webview level in the future (that is, to disable or enable them to each separate webview), so tell me if you do, because I haven’t been able to figure out a solution for that.


#3

Thank you so much because I abandoned my project for 1 month and forget to read.