ghostery / adblocker

Efficient embeddable adblocker library
https://www.ghostery.com
Mozilla Public License 2.0
798 stars 100 forks source link

uBlock Origin with Electron AdBlocker? #1839

Closed ryankashi closed 3 years ago

ryankashi commented 3 years ago

Hi everyone! Sorry if this is a dumb question, but I am noticing some differences between the implementatin of uBlock Origin in my browser as well as with the Electron Implementation of the adblocker.

I initialize the adblocker via the following way:

var {ElectronBlocker} = require('@cliqz/adblocker-electron');
var {fetch} = require('cross-fetch');

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

However I notice that certain ads are blocked fully by uBlock origin, wheras others seem to fall through the cracks with Electron Adblocker. Is this due to the settings of my electron Adblocker instance, or something else?

How would I export the settings of my uBlock origin instance of my browser, and then import these settings into the Electron Adblocker? I do not see where to generate a filters list via uBlock origin for the code examples that I see in the example/front page.

Specifically, if I go to:

https://www.crunchyroll.com/jujutsu-kaisen/episode-3-girl-of-steel-797867

inside of my Electron app, I will see the little ad marks, at which point the browser will try to load the ads and fail, however it will cause buffering for 5-6 seconds which is far from ideal, wheras my Chrome browser just blocks the ad entirely without any interruption.

ryankashi commented 3 years ago

Update:

It appears that cliqz adblocker is no longer working for Crunchyroll ads at all, however both Adblock Plus as well as Ublock origin still work. Any updates on this?

remusao commented 3 years ago

Hey @ryankashi,

Sorry for not jumping in earlier. I think I know what is going on and will try to address the issue asap. I will update this issue once I do.

Best,

remusao commented 3 years ago

Hey,

So it seems like the cause of the issue I had in mind was not the actual cause. I looks like there might be some issue in the adblocker which makes it unable to block ads on this particular website. We would need to investigate to understand what's going on (I would suspect a scriptlet injection issue; but I need to test this hypothesis). I will try to find a bit of time in the coming days/weeks, but I have relatively little time lately. All help is appreciated :D

Best,

ryankashi commented 3 years ago

Oh darn, that's always the worst when the bug isn't what it's expected to be! Is there any way I can help with this issue? I would love to be able to help in any way that I can, although I am not the most familiar with how Ad blocks / Cliqz works

remusao commented 3 years ago

@ryankashi I have pushed an update yesterday which I think should address the issue you initially reported. At least from my local testing the ads were blocked in the videos on this website.

ryankashi commented 3 years ago

Awesome! I don't have computer access right now until June 3rd. I'll check it out then and let you know if it works on my end as well!

ryankashi commented 3 years ago

Sorry, haven't been able to test this yet, some roadblockers popped up at the beginning of this month. I'll get to it next week though. Just to confirm, I will have to test with Electron v13.0 or greater though, correct?

remusao commented 3 years ago

Sorry, haven't been able to test this yet, some roadblockers popped up at the beginning of this month. I'll get to it next week though. Just to confirm, I will have to test with Electron v13.0 or greater though, correct?

Yes I think it would be best to work with latest Electron at this point. That's also the version I tested most recently.

ryankashi commented 3 years ago

@remusao, I have some bad news :-(. I had various blockers come up which prevented me from being able to double check on my end.

I managed to test just now with Electron 13.1.6 and cliqz/adblocker 1.22.2, and I was unable to block the Crunchyroll ads inside of videos.

Specifically, by implementing cliqz/adblocker as described in the initial post, all Crunchyroll banner ads were removed however no video ads were removed. When I went to double check with YouTube, I could see that YouTube ads were removed correctly from their website, so I believe that I have implemented the adblocker correctly