FriedChickenButt / youtube-webos

Youtube App without ADs
GNU General Public License v3.0
195 stars 69 forks source link

Still has ads #7

Closed t0stiman closed 3 years ago

t0stiman commented 3 years ago

I still get an ad before the actual video is started. Happens both in the emulator and on the TV. Does it still work for you?

FriedChickenButt commented 3 years ago

TLDR: Youtube ADs are also hosted on youtube's own domain, blocking of which would cause the app to break. Therefore, user can encounter a few ADs.

Youtube receives ADs through multiple domains, most of which can be caught using the regex defined in this code.

But, youtube also uses a few of its own domains (which are used for the actual videos) to get the ADs. Therefore, blocking these domains would break the ability of youtube app to play many videos.

I haven't tried to dive deep into youtube.com/tv logic to accurately determine how the ADs are downloaded, which I plan to take up at a later date, but the regex linked earlier blocks most of the ADs.

However, I highly encourage to raise a PR/Issue if anyone has more information on how to make the AD blocking better.

t0stiman commented 3 years ago

ah, okay. this app doesn't really add anything for me then, I think, because I already block ad domains with a network-wide ad-blocker (pi-hole).

As for ways to improve the ad-blocking: maybe its possible to integrate Ublock Origin somehow? It's 100% effective against YT ads, open source en written in JS.

FriedChickenButt commented 3 years ago

Is it possible to have Ublock as a tampermonkey script? If yes, integrating would be very simple. If not, I would need to wrap a lot of chrome extension APIs to make it work as a userscript. I haven't had a look at how Ublock works, but I'm going to take this up soon.

Informatic commented 3 years ago

I think it'd be best to just find the actual ublock rules that implement youtube adblocking and reimplement them (or make a minimal viable implementation of said rules parser / interpreter). That shouldn't be very hard.

Informatic commented 3 years ago

Also - is ublock origin also effective against youtube.com/tv ads?

Informatic commented 3 years ago

effectively youtube.com/tv adblocking by ublock origin is handled by the following rule from https://raw.githubusercontent.com/uBlockOrigin/uAssets/master/filters/filters.txt

youtube.com,youtube-nocookie.com##+js(json-prune, [].playerResponse.adPlacements [].playerResponse.playerAds playerResponse.adPlacements playerResponse.playerAds adPlacements playerAds)

This in practice calls the following snippet with all the arguments: https://github.com/gorhill/uBlock/blob/bfdc81e9e400f7b78b2abc97576c3d7bf3a11a0b/assets/resources/scriptlets.js#L365-L470

After preliminary research, following patch ran manually via developer console seems to remove ads in my firefox browser with user-agent spoofed as webOS:

p = JSON.parse; window.JSON.parse = function() { const r = p.apply(this, arguments); if (r.adPlacements) {console.info('patching', r); r.adPlacements=[];} return r; }
FriedChickenButt commented 3 years ago

Thank you @Informatic for doing the research, I will most probably implement it in the current weekend.

Informatic commented 3 years ago

This will be closed in #8 / #9 - also a fork will liekly be pulled into homebrew channel repo soon: https://github.com/webosbrew/apps-repo/pull/7

Informatic commented 3 years ago

This has been fixed in c6f4180516d9d43d092ca6db4355b33ef529346a merged already.

t0stiman commented 3 years ago

ok