top | item 38327017

Show HN: YouTube banned adblockers so I built an extension to skip their ads

713 points| rKarpinski | 2 years ago

Hi HN!

Since Youtube no longer allows AdBlockers, I built my own extension to get around their video ads. If there is an ad it temporarily manipulates the video; Mutes the volume, sets speed to 10x, and skips it if there is a button.

Chrome Webstore link: https://chromewebstore.google.com/detail/ad-accelerator/gpbo...

Code: https://github.com/rkk3/ad-accelerator

710 comments

order
[+] extheat|2 years ago|reply
Cool! I recently wrote my own user script to do the same thing. It's going to be very hard to patch or detect this, as updating video element props don't trigger DOM updates. They would have to either do lots of JS prototype trickery or check for playback rate when doing adblock detection. One thing to keep in mind here though since you're doing DOM lookups every time anything on the page changes, is that there could be some small overhead in page render time, and also that using fixed CSS classes means any small change to page code could break the checks. In case it's a problem in the future, checking .innerText is a hacky way to workaround it.
[+] zamadatix|2 years ago|reply
One can simply "videoElement.addEventListener('ratechange', callback);" to be notified the ad was sped up.

I mean the client can then undo this, as it can any JS the page offers, but there's nothing harder about detecting playbackRate changes vs something which causes a DOM update.

[+] rjh29|2 years ago|reply
They could refuse to deliver the main video content until the minimum ad time has passed?
[+] zeven7|2 years ago|reply
They could just patch Chrome to make "updating video element props trigger DOM updates".
[+] _dark_matter_|2 years ago|reply
Add this to addons.mozilla.org, so we can use it on Firefox & Firefox for Android!
[+] matricaria|2 years ago|reply
On Firefox I recommend uBlock Origin oder AdGuard, both block ads completely.
[+] kspacewalk2|2 years ago|reply
Been watching YouTube on Firefox (Android and MacOS) with uBlock Origin with zero ads ever. What am I missing?
[+] timenova|2 years ago|reply
For those who are on Safari (macOS and iOS), I highly recommend using Vinegar [0].

But that being said, recently even Vinegar is struggling a lot when I open a YouTube video (although the developer is promptly fixing issues). The video starts playing in the background, but I can't see it, then it pauses for a few seconds and restarts.

It's crazy how terrible YouTube is making the experience on their site!

[0] https://apps.apple.com/in/app/vinegar-tube-cleaner/id1591303...

[+] j45|2 years ago|reply
It seems a lot of work to do this and worth it.

As a surprised customer of YouTube premium having all ads gone across videos and music across all devices really might not be a bad deal for anyone on the fence for a family plan and all your devices.

In terms of working around ads.. There are some neat solutions that seem to work ok for YouTube on tv.. but so far the family plan seems ok.

Was anyone able tog eat off the premium plan and have no ads on their phones, computers, tvs and smart speakers?

[+] TriNetra|2 years ago|reply
I also have an extension [0] in which I have couple of shortcuts to skip ads:

- alt+2 to click on Skip Ads button

- ctrl + shift + end to set video's 'seek position' at 100% (useful to skip ads when 'Skip Ads' button isn't available. This makes Youtube believe that the ad is finished playing)

0: https://github.com/varunkho/ramaplayer

[+] Zak|2 years ago|reply
That's definitely a technique to keep in reserve if they get better at detection, but uBlock Origin currently works very well on Youtube as long as its filters are up to date.
[+] ajsnigrutin|2 years ago|reply
If i'm logged in it fails constantly when i'm logged in (a few videos daily seem to work ok, after that it refuses to load a video, even though a "anti adblock" popup is still blocked)

...but it seems to work ok in incognito tabs, so youtube gets even less data on me now.

[+] Joel_Mckay|2 years ago|reply
Ultimately the conversion rate of spam continuously proves one of the worst advertising methods. They are ripping off companies they lie to about the conflated stats, and irritating the 80% of users that will never buy anything for various reasons.

It is going to be an interesting waste of resources. =)

[+] Obscurity4340|2 years ago|reply
Did you mean conflated or inflated, I feel vaguely like it could go either way here
[+] indianmouse|2 years ago|reply
Looks like YouTube is already detecting this or has some logic to detect that the ads were played at a different speed.

Try moving through a video when this extension is active and you can see that the advertisement is getting active for almost every possible forward / reverse time selection on the video timeline.

It is just too many blank screens and though it saves a couple of seconds in the actual advertisement watching space, it does provide an unpleasant experience of watching the black screen for a few seconds.

I can live with that (and most should be!), but wanted to record this observation so that it get's to the developer's attention for improvements (if possible!)

Hope it helps.

[+] rKarpinski|2 years ago|reply
Thanks for trying it out!

For longer videos Youtube will insert multiple ads during the content which you might be hitting if you search through. The extension should still trigger for those ads, but it's not as seamless an experience as the ad blockers. Is that what you're describing?

Open to feedback! Have my email in profile & listed with the extension

[+] Andrews54757|2 years ago|reply
There is a javascript library for interfacing with Youtube's API directly. It can also run on browsers. Using this, it's pretty easy to create a simple extension that replaces the default video player with your own. You can do a lot to improve your experience this way. I've made one which allows for higher quality streaming, pre-buffering video in the background, more subtitling options, etc... [2] [3].

[1] https://github.com/LuanRT/YouTube.js

[2] https://github.com/Andrews54757/FastStream

[3] Chrome (also available for Firefox): https://chromewebstore.google.com/u/1/detail/faststream-vide...

[+] eyegor|2 years ago|reply
Wow, faststream works great for normal web players. Doesn't seem to work on any youtube videos when using the ff extension in the store though. Gets stuck loading forever.

Edit: fixed, works well in every test case

[+] pvg|2 years ago|reply
Do you happen to know how well (or at all) the library supports subs/sub notifications and if people have built alternative UIs around that? The default youtube UI for that is a tremendous clunkfest.
[+] tobias2014|2 years ago|reply
This is nifty! It might be interesting to interface it with Sponsorblock in the future.
[+] cbozeman|2 years ago|reply
You're doing the Lord's work. Thank you.
[+] nirui|2 years ago|reply
Now with this bit of free free-time, the Lord might finally be able to convince YouTube to make their ads more bearable, so people don't have to install ad blockers to begin with.

I installed mine after YouTube starts to show 45 minute (yes, indeed) long ads to me, the entire pod cast session of it, AFTER I've watched the first ad but decided not to tap "Skip Ad".

If YouTube don't want to control the quality of what they are showing, then guess I'll just help them not showing it. And if doing so is a cause for a ban, then I guess just ban me :)

[+] titaniumtown|2 years ago|reply
ublock origin works fine on YouTube, if not, couldnt this just be a filter rule?
[+] chii|2 years ago|reply
It does. But i think youtube attempts to detect the adblock (which ublock origin continues to evade with new updates?).

This extension does not block, but instead just fast forward the ad (playback speed at 10x - tbh, it could'be been at 100x probably!) and mutes it. So from the youtube js perspective, the ad has played and wasn't blocked.

[+] tomashubelbauer|2 years ago|reply
FWIW as long as you manually update the Quick Fixes uBlock Origin filter list every day or so, you'll probably never see a YouTube ad. Every new Google measure gets cracked very fast IME.
[+] blacklight|2 years ago|reply
Just stop using the YouTube frontend.

I've been running my Piped instance for a while, and there are many public Piped instances available on the Web as well.

And, if you don't want the headache of running your own proxied instance or hopping between public instances, use Platypush - it wires together Piped as a backend, with yt-dlp as a local proxy/scaper, and a multitude of media plugins to allow you streaming directly the YouTube media files to any media device. Plus, thanks to yt-dlp, it doesn't only work only with YouTube, but with hundreds of other websites with closed media URLs (Facebook, TikTok, Twitter...). And then just use LibRedirect/UntrackMe to convert all of the YouTube URLs to Piped URLs - you won't send a single packet to that digital sewage, and you won't even notice any difference.

Just...stopping relying on YouTube's frontend. I've been chasing their API and FE changes for a while. I even set up a small Selenium suite to scrape video results directly from their UI. It's quite clear that they've decided to invest enough resources to embrace full war against anybody who's sick of their ads. They are in a terminal phase of enshittification - the one where they look so much after they bottom line that they don't care if they to turn their whole platform into a big billboard or shut down all of their APIs. Either I consume videos from anywhere else, or, when I have no alternatives, I use Piped. But avoid youtube.com at all costs: it's a walking digital cancer in its terminal phase.

Even paying a subscription to them to get rid of the ads wouldn't help. I'd rather direct my donations to open or non-enshittified services than supporting a dying business model.

[+] wolfendin|2 years ago|reply
If YouTube (and google) forces me to look at ads, I will simply start clicking on all of them, and they can deal with the lower conversion rate
[+] gigglesupstairs|2 years ago|reply
It might be fun in short term but not sustainable long term lol
[+] jshier|2 years ago|reply
StopTheMadness implemented something similar but YouTube eventually got wise and I had to stop using that one too.
[+] shrimp_emoji|2 years ago|reply
Shout out to yt-dlp, which allows you to download videos and watch them on your own terms. :D

Also, if anyone knows, if you open a YouTube URL with something like mpv, I assume it starts playing as an "embedded video" in your video player. Does YouTube serve adds in that case?

[+] kzrdude|2 years ago|reply
I think mpv specifically just uses youtube-dl or simliar (yt-dlp), so it should be very simliar to whatever you download.