Skip to content

Instantly share code, notes, and snippets.

@gidoBOSSftw5731
Last active June 10, 2024 18:23
Show Gist options
  • Save gidoBOSSftw5731/15721a09a8be4191baeb4c5606d1a199 to your computer and use it in GitHub Desktop.
Save gidoBOSSftw5731/15721a09a8be4191baeb4c5606d1a199 to your computer and use it in GitHub Desktop.
Block annoying Youtube elements with ublock origin/adblock plus compatible filters

These are fairly experimental and may affect performance or stop working at any time. Feel free to comment if you have any better implementations, I tried to be both as specific as possible and follow reccomendation from the documentation, though I am just a guy.

The files are (at time of writing) are .ubo files (for UBlock Origin) though I dont believe this is an official file name.

All these were testing using AdNauseum, a skin of UBlock Origin.

Instructions on how to use these located here: https://www.ghacks.net/2014/10/10/how-to-add-custom-filters-to-chrome-ad-blocking-extension-%C2%B5block/ (the particular tab may be called "your filters" or "my filters")

I am not directly affiliated with UBlock Origin, AdBlock Plus, Youtube, nor their developers.

! block all playlists being reccomended underneath a video (tag me if you want one just for youtube music)
www.youtube.com##ytd-compact-playlist-renderer:has(ytd-thumbnail-overlay-side-panel-renderer)
! simillar to the more from youtube section, this is in place of the subscription box on the left side for users who are not logged in.
www.youtube.com##ytd-guide-section-renderer.ytd-guide-renderer.style-scope:has-text(/best of youtube/i)
! tv and stuff listed as "free", usually stuff like movies and/or yt originals
www.youtube.com##ytd-rich-item-renderer:has(.ytd-badge-supported-renderer:has-text(Free))
! the overlays visible when you hover over a video for watch later and add to queue
www.youtube.com###hover-overlays
! The "more from youtube" section on the expanded sidebar at the bottom
www.youtube.com##ytd-guide-section-renderer.ytd-guide-renderer.style-scope:has-text(/more from youtube/i)
! the list of categories to filter by above the video reccomendations underneath/next to a video
www.youtube.com###chips
! the banner on the home page, usually related to politics, covid 19, or other current event
www.youtube.com##.ytd-rich-section-renderer
! the "experiencing interruptions" toast popup in the bottom corner when a video is bufferring (due to network congestion, underperforming hardware, or any other reason)
www.youtube.com###toast:has(#text-container:has-text(/experiencing interruptions/i))
! block things like the youtube "my mix" and the crappy autogenerated playlists.
www.youtube.com##ytd-compact-radio-renderer:has(ytd-thumbnail-overlay-bottom-panel-renderer)
www.youtube.com##ytd-rich-item-renderer:has(ytd-thumbnail-overlay-bottom-panel-renderer)
! this blocks them also in the window after you finish a video. This does leave black squares where they were but I'd argue that's better
www.youtube.com##a.ytp-suggestion-set.ytp-videowall-still:has(.ytp-videowall-still-listlabel-mix:not(:matches-css(display: none)))
! buttons linking to youtube music (one of the worst music streaming services) on the sidebar
www.youtube.com##ytd-guide-section-renderer.ytd-guide-renderer.style-scope:nth-of-type(1) [href="https://music.youtube.com/"]
www.youtube.com###endpoint.ytd-mini-guide-entry-renderer.style-scope.yt-simple-endpoint[href="https://music.youtube.com/"]
! blue bubble popups for "new" features
www.youtube.com##tp-yt-iron-dropdown.ytd-popup-container.style-scope
! buttons linking to youtube originals on the sidebar
www.youtube.com##ytd-guide-section-renderer.ytd-guide-renderer.style-scope:nth-of-type(1) [href="/channel/UCqVDpXKLmKeBU_yyt_QkItQ"]
www.youtube.com###endpoint.ytd-mini-guide-entry-renderer.style-scope.yt-simple-endpoint[href="/channel/UCqVDpXKLmKeBU_yyt_QkItQ"]
@BDubbB
Copy link

BDubbB commented May 14, 2024

Is there anything that blocks those tiny, annoying, merch ads that now popup in the player, and refuse to go away except for a short while when you click to close them? I'm not sure it will work, but I'm thinking that this might work (you might want to add it to your list here if it will):

##.ytp-featured-product-container
##.ytp-suggested-action-badge-with-controls.ytp-suggested-action-badge-expanded.ytp-featured-product.ytp-suggested-action-badge.ytp-button

@gidoBOSSftw5731
Copy link
Author

Is there anything that blocks those tiny, annoying, merch ads that now popup in the player, and refuse to go away except for a short while when you click to close them? I'm not sure it will work, but I'm thinking that this might work (you might want to add it to your list here if it will):

##.ytp-featured-product-container ##.ytp-suggested-action-badge-with-controls.ytp-suggested-action-badge-expanded.ytp-featured-product.ytp-suggested-action-badge.ytp-button

I'm not 100% sure what you're talking about (not a huge youtube in the browser user anymore,) could you send a screenshot and/or link an example of it happening?

@BDubbB
Copy link

BDubbB commented May 16, 2024

I'm not 100% sure what you're talking about (not a huge youtube in the browser user anymore,) could you send a screenshot and/or link an example of it happening?

Here is a Reddit thread where somebody else is describing the same issue with an image of it:

https://www.reddit.com/r/youtube/comments/187xt0w/popup_merch_ads/

So far, since I messaged you, I haven't seen those ads anymore. I think that it may have worked.

@BDubbB
Copy link

BDubbB commented Jun 10, 2024

I'm not 100% sure what you're talking about (not a huge youtube in the browser user anymore,) could you send a screenshot and/or link an example of it happening?

P.S.

What I did worked, except that I had one more bit I had to block. The working code to block what is happening in that Reddit thread I linked to is:

www.youtube.com##.ytp-featured-product-container
www.youtube.com##.ytp-suggested-action-badge-with-controls.ytp-suggested-action-badge-expanded.ytp-featured-product.ytp-suggested-action-badge.ytp-button
www.youtube.com##.ytp-suggested-action-badge-expanded.ytp-featured-product.ytp-suggested-action-badge.ytp-button

Here is the link to the Reddit thread again, so that you can see the issue this solves (i.e., merch. ads):

https://www.reddit.com/r/youtube/comments/187xt0w/popup_merch_ads/

So far, the code I pasted is working beautifully.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment