Skip to content

Instantly share code, notes, and snippets.

@DreadBoy
Last active July 21, 2023 05:19
Show Gist options
  • Save DreadBoy/ff51b4c405a8e77e4619229f3b9e4c23 to your computer and use it in GitHub Desktop.
Save DreadBoy/ff51b4c405a8e77e4619229f3b9e4c23 to your computer and use it in GitHub Desktop.
userscripts
// ==UserScript==
// @name Youtube Filters
// @namespace https://www.youtube.com/
// @version 0.6
// @description Allows you to hide watched videos and stories in subscription feed
// @match https://www.youtube.com/*
// @match https://www.youtube.com/*
// @copyright 2013+, Matic Kravina Leva
// @grant GM_addStyle
// ==/UserScript==
(function() {
if(location.pathname == '/feed/subscriptions') {
const unwatched = document.createElement("button");
unwatched.id = "hide_watched";
unwatched.textContent = "Hide watched";
unwatched.addEventListener("click", () => {
const watched = [...document.querySelectorAll(".ytd-thumbnail-overlay-resume-playback-renderer")].filter(e => typeof e.style.width === "string" && e.style.width.includes("%") && +e.style.width.replace("%", "") > 90);
watched.map(el => el.closest("ytd-rich-item-renderer")).forEach(el => el.classList.add("GM_hidden"));
});
document.body.appendChild(unwatched);
const hideStories = document.createElement("button");
hideStories.id = "hide_stories";
hideStories.textContent = "Hide stories";
hideStories.addEventListener("click", () => {
const stories = [...document.querySelectorAll('[overlay-style="SHORTS"]')];
stories.map(el => el.closest("ytd-rich-item-renderer")).forEach(el => el.classList.add("GM_hidden"));
const storiesSection = document.querySelector("ytd-rich-shelf-renderer[is-shorts]");
if(storiesSection) {
storiesSection.closest("ytd-rich-section-renderer").classList.add("GM_hidden");
}
});
document.body.appendChild(hideStories);
GM_addStyle('#hide_watched { position: fixed; top: 80px; left: 400px } #hide_stories {position: fixed; top: 80px; left: 505px} .GM_hidden {display: none !important}');
}
})()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment