Skip to content

Instantly share code, notes, and snippets.

@Nullcaller
Last active May 11, 2024 08:36
Show Gist options
  • Save Nullcaller/aae72d791e0e277777a6bc721d942ceb to your computer and use it in GitHub Desktop.
Save Nullcaller/aae72d791e0e277777a6bc721d942ceb to your computer and use it in GitHub Desktop.
(defunct) An *AdGuard* Adblocker filter to remove all distractions from YouTube. Home page is emptied, recommendations, subscriptions, likes and dislikes are removed. As to why, see below. The latest version of this filter is always available at https://gist.github.com/Nullcaller/aae72d791e0e277777a6bc721d942ceb/raw
! Title: YouTube Distractions Removal
! Mobile YouTube
m.youtube.com###header-bar > header.mobile-topbar-header.cbox > button.mobile-topbar-header-endpoint:first-child
m.youtube.com##ytm-watch-next-secondary-results-renderer.ytm-watch-flexy.style-scope
m.youtube.com##a.ytm-suggestion-set.ytm-videowall-still
m.youtube.com##ytm-browse[page-subtype=home]
m.youtube.com###app > div.page-container:nth-child(2) > ytm-watch > ytm-single-column-watch-next-results-renderer.watch-content.big-thumbnail-experiment:last-child > ytm-item-section-renderer.scwnr-content:last-child > lazy-list
m.youtube.com###app > ytm-pivot-bar-renderer.pivot-bar-slide-in:nth-child(2) > ytm-pivot-bar-item-renderer:nth-child(3)
m.youtube.com###app > ytm-pivot-bar-renderer.pivot-bar-slide-in:nth-child(2) > ytm-pivot-bar-item-renderer:nth-child(3) > div.pivot-bar-item-tab.pivot-subs
m.youtube.com###app > ytm-pivot-bar-renderer:nth-child(2) > ytm-pivot-bar-item-renderer:nth-child(3) > div.pivot-bar-item-tab.pivot-subs
m.youtube.com###app > ytm-pivot-bar-renderer:nth-child(2) > ytm-pivot-bar-item-renderer:nth-child(3)
m.youtube.com###app > ytm-pivot-bar-renderer:nth-child(2) > ytm-pivot-bar-item-renderer:nth-child(2) > div.pivot-bar-item-tab.pivot-trending
m.youtube.com###app > ytm-pivot-bar-renderer:nth-child(2) > ytm-pivot-bar-item-renderer:nth-child(2)
m.youtube.com###app > ytm-pivot-bar-renderer:nth-child(2) > ytm-pivot-bar-item-renderer:nth-child(2)
m.youtube.com###app > div.page-container:nth-child(3) > ytm-browse > ytm-single-column-browse-results-renderer > div > div > ytm-rich-grid-renderer > div.rich-grid-renderer-contents:last-child
m.youtube.com###filter-chip-bar > div.chip-bar-contents
m.youtube.com###app > ytm-pivot-bar-renderer:nth-child(2) > ytm-pivot-bar-item-renderer:first-child > div.pivot-bar-item-tab.pivot-w2w
m.youtube.com###app > ytm-pivot-bar-renderer:nth-child(2) > ytm-pivot-bar-item-renderer:first-child
m.youtube.com###app > ytm-pivot-bar-renderer:nth-child(2) > ytm-pivot-bar-item-renderer:first-child
m.youtube.com###app > div.page-container:nth-child(2) > ytm-watch > ytm-single-column-watch-next-results-renderer.watch-content.big-thumbnail-experiment:last-child > ytm-item-section-renderer.scwnr-content:nth-child(2) > lazy-list > ytm-slim-video-metadata-renderer.item > div.slim-video-metadata-actions:nth-child(3) > c3-material-button.button-renderer.compact:first-child
m.youtube.com###app > div.page-container:nth-child(2) > ytm-watch > ytm-single-column-watch-next-results-renderer.watch-content.big-thumbnail-experiment:last-child > ytm-item-section-renderer.scwnr-content:nth-child(2) > lazy-list > ytm-slim-video-metadata-renderer.item > div.slim-video-metadata-actions:nth-child(3) > c3-material-button.button-renderer.compact:nth-child(2)
m.youtube.com###menu > div.menu-content:first-child > ytm-toggle-menu-service-item-renderer:nth-child(2)
m.youtube.com###menu > div.menu-content:first-child > ytm-toggle-menu-service-item-renderer:nth-child(3)
! Fix Mobile YouTube bugging into "Stream/preview has ended" with a mutation observer
m.youtube.com#%#var observer = new MutationObserver(function (mutations) { mutations.forEach(function (mutation) { console.log("[YTDR] Player mutation detected."); if (mutation.attributeName == "playable" && mutation.target.getAttribute("playable") == "false") setTimeout(function() { document.getElementById("player").setAttribute("playable", "true"); document.getElementById("player-container-id").setAttribute("playable", "true"); document.getElementById("player-control-container").setAttribute("playable", "true"); console.log("[YTDR] Player reset to playable."); }, 100); }); }); observer.observe(document.getElementById("player"), { attributes: true }); observer.observe(document.getElementById("player-container-id"), { attributes: true }); console.log("[YTDR] Player resetter activated successfully.");
! Desktop YouTube
youtube.com###primary > ytd-rich-grid-renderer.style-scope.ytd-two-column-browse-results-renderer
youtube.com###items > ytd-guide-entry-renderer.style-scope.ytd-guide-section-renderer:nth-child(5)
youtube.com###items > ytd-guide-entry-renderer.style-scope.ytd-guide-section-renderer:first-child
youtube.com###items > ytd-guide-entry-renderer.style-scope.ytd-guide-section-renderer:nth-child(2)
youtube.com###items > ytd-guide-entry-renderer.style-scope.ytd-guide-section-renderer:nth-child(3)
youtube.com###sections > ytd-guide-section-renderer.style-scope.ytd-guide-renderer:nth-child(2)
youtube.com###sections > ytd-guide-section-renderer.style-scope.ytd-guide-renderer:nth-child(3)
youtube.com###buttons > ytd-notification-topbar-button-renderer.style-scope.ytd-masthead.notification-button-style-type-default:nth-child(3)
youtube.com###buttons > ytd-topbar-menu-button-renderer.style-scope.ytd-masthead.style-default:nth-child(2)
youtube.com###items > ytd-mini-guide-entry-renderer.style-scope.ytd-mini-guide-renderer:first-child
youtube.com###items > ytd-mini-guide-entry-renderer.style-scope.ytd-mini-guide-renderer:nth-child(2)
youtube.com###items > ytd-mini-guide-entry-renderer.style-scope.ytd-mini-guide-renderer:nth-child(3)
youtube.com###items > ytd-mini-guide-entry-renderer.style-scope.ytd-mini-guide-renderer:nth-child(5)
youtube.com###logo
youtube.com###related
@Nullcaller
Copy link
Author

Nullcaller commented Jun 1, 2021

Well, I tried to add a JS rule in order to fix YouTube mobile going into "Premiere/stream ended days ago". I've found out two things. First is that this filter does indeed require to be checked as trusted. Second is that the trusted checkbox is obviously broken at the moment, as the rule just wouldn't work anyways, even though it does work when copied into user rules manually. So if you want to fix that, please copy the rule to your user rules:

m.youtube.com#%#var observer = new MutationObserver(function (mutations) { mutations.forEach(function (mutation) { console.log("[YTDR] Player mutation detected."); if (mutation.attributeName == "playable" && mutation.target.getAttribute("playable") == "false") setTimeout(function() { document.getElementById("player").setAttribute("playable", "true"); document.getElementById("player-container-id").setAttribute("playable", "true"); document.getElementById("player-control-container").setAttribute("playable", "true"); console.log("[YTDR] Player reset to playable."); }, 100); }); }); observer.observe(document.getElementById("player"), { attributes: true }); observer.observe(document.getElementById("player-container-id"), { attributes: true }); console.log("[YTDR] Player resetter activated successfully.");

@Nullcaller
Copy link
Author

Currently defunct. Use ReVanced.

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