YT Subscription Feed Cleaner
| *.zip |
+21
| MIT License | ||
| Copyright (c) 2026 Nat Valentine | ||
| Permission is hereby granted, free of charge, to any person obtaining a copy | ||
| of this software and associated documentation files (the "Software"), to deal | ||
| in the Software without restriction, including without limitation the rights | ||
| to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
| copies of the Software, and to permit persons to whom the Software is | ||
| furnished to do so, subject to the following conditions: | ||
| The above copyright notice and this permission notice shall be included in all | ||
| copies or substantial portions of the Software. | ||
| THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
| IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
| FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
| AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
| LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
| OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
| SOFTWARE. |
+49
-4
@@ -5,2 +5,3 @@ const defaultSettings = { | ||
| blacklist: [], | ||
| whitelist: [], | ||
| }; | ||
@@ -28,3 +29,9 @@ | ||
| filterVideos(); // Blacklist filtering | ||
| if (settings.whitelist.length > 0) { | ||
| filterByWhitelist(); | ||
| } | ||
| if (settings.blacklist.length > 0) { | ||
| filterByBlacklist(); | ||
| } | ||
| } | ||
@@ -49,6 +56,40 @@ | ||
| async function filterVideos() { | ||
| function filterByWhitelist() { | ||
| const videos = document.querySelectorAll("ytd-rich-item-renderer"); | ||
| videos.forEach((video) => { | ||
| const titleEl = video.querySelector("h3[title]"); | ||
| const channelEl = video.querySelector( | ||
| "yt-content-metadata-view-model div span span a", // holy shit yt use ids like the rest of us | ||
| ); | ||
| console.log("Title element:", titleEl); | ||
| console.log("Channel element:", channelEl); | ||
| if (!titleEl || !channelEl) return; | ||
| const titleText = titleEl.getAttribute("title").toLowerCase(); | ||
| const channelName = channelEl.textContent.trim().toLowerCase(); | ||
| console.log("Checking video:", titleText, "from channel:", channelName); | ||
| const rulesForChannel = settings.whitelist.filter((rule) => | ||
| channelName.includes(rule.channel), | ||
| ); | ||
| if (rulesForChannel.length === 0) return; | ||
| console.log("Whitelist rules for channel:", rulesForChannel); | ||
| const matchesWhitelist = rulesForChannel.some((rule) => | ||
| rule.include.some((keyword) => titleText.includes(keyword)), | ||
| ); | ||
| if (!matchesWhitelist) { | ||
| video.remove(); | ||
| } | ||
| }); | ||
| } | ||
| async function filterByBlacklist() { | ||
| const videos = document.querySelectorAll("ytd-rich-item-renderer"); | ||
| videos.forEach((video) => { | ||
| const title = video.querySelector("h3[title]"); | ||
@@ -88,3 +129,3 @@ | ||
| settings.blacklist = changes.blacklist.newValue; | ||
| filterVideos(); | ||
| filterByBlacklist(); | ||
| } | ||
@@ -105,3 +146,3 @@ | ||
| Featured section selector: | ||
| Featured section selector: oof | ||
| <ytd-rich-shelf-renderer class="style-scope ytd-rich-section-renderer" elements-per-row="3" show-bottom-divider="" style="--ytd-rich-grid-items-per-row: 3; --ytd-rich-grid-item-margin: 16px; --ytd-rich-shelf-items-count: 12;" restrict-contents-overflow="" has-expansion-button=""><!--css-build:shady--><!--css_build_scope:ytd-rich-shelf-renderer--><!--css_build_styles:video.youtube.src.web.polymer.shared.ui.styles.yt_base_styles.yt.base.styles.css.js--><div id="dismissible" class="style-scope ytd-rich-shelf-renderer"> | ||
@@ -112,2 +153,6 @@ <div id="rich-shelf-header-container" class="style-scope ytd-rich-shelf-renderer"> | ||
| Channel selector: | ||
| yt-content-metadata-view-model -> div -> span -> span -> a | ||
| */ |
+1
-1
| { | ||
| "manifest_version": 2, | ||
| "name": "YT Subscription Feed Cleaner", | ||
| "version": "1.0", | ||
| "version": "2.0", | ||
| "description": "Hide Shorts, featured sections and filter videos by keywords.", | ||
@@ -6,0 +6,0 @@ "permissions": [ |
+9
-1
@@ -20,6 +20,14 @@ body { | ||
| width: 100%; | ||
| margin-top: 5px; | ||
| margin: 5px 0; | ||
| box-sizing: border-box; | ||
| } | ||
| textarea { | ||
| display: block; | ||
| width: 100%; | ||
| height: 60px; | ||
| margin: 5px 0; | ||
| box-sizing: border-box; | ||
| } | ||
| .toggle { | ||
@@ -26,0 +34,0 @@ display: flex; |
+9
-3
@@ -7,3 +7,3 @@ <!doctype html> | ||
| <body> | ||
| <label class="toggle"> | ||
| <label for="shorts" class="toggle"> | ||
| <input type="checkbox" id="shorts" /> | ||
@@ -14,3 +14,3 @@ Hide Shorts | ||
| <label class="toggle"> | ||
| <label for="featured" class="toggle"> | ||
| <input type="checkbox" id="featured" /> | ||
@@ -22,7 +22,13 @@ Hide Featured | ||
| <label>Blacklist (comma-separated): </label> | ||
| <label for="blacklist">Blacklist (comma-separated): </label> | ||
| <input type="text" id="blacklist" placeholder="spoiler, drama" /> | ||
| <label for="whitelist" | ||
| >Whitelist by channel (One channel per line: <br /> | ||
| ex: channel: keyword, keyword): | ||
| </label> | ||
| <textarea id="whitelist" placeholder="The WAN Show: WAN Show"></textarea> | ||
| <script src="popup.js"></script> | ||
| </body> | ||
| </html> |
+28
-0
| const shortsEl = document.getElementById("shorts"); | ||
| const featuredEl = document.getElementById("featured"); | ||
| const blacklistEl = document.getElementById("blacklist"); | ||
| const whitelistEl = document.getElementById("whitelist"); | ||
@@ -9,2 +10,3 @@ const defaultSettings = { | ||
| blacklist: [], | ||
| whitelist: [], | ||
| }; | ||
@@ -17,2 +19,5 @@ | ||
| blacklistEl.value = data.blacklist.join(", "); | ||
| whitelistEl.value = (data.whitelist || []) | ||
| .map((rule) => `${rule.channel}: ${rule.include.join(", ")}`) | ||
| .join("\n"); | ||
| }); | ||
@@ -27,2 +32,4 @@ } | ||
| const whitelist = parseWhitelist(whitelistEl.value); | ||
| browser.storage.sync.set({ | ||
@@ -32,9 +39,30 @@ hideShorts: shortsEl.checked, | ||
| blacklist, | ||
| whitelist, | ||
| }); | ||
| } | ||
| function parseWhitelist(value) { | ||
| return value | ||
| .split("\n") | ||
| .map((line) => { | ||
| const [channel, keywords] = line.split(":"); | ||
| if (!channel || !keywords) return null; | ||
| return { | ||
| channel: channel.trim().toLowerCase(), | ||
| include: keywords | ||
| .split(",") | ||
| .map((k) => k.trim().toLowerCase()) | ||
| .filter(Boolean), | ||
| }; | ||
| }) | ||
| .filter(Boolean); | ||
| } | ||
| shortsEl.addEventListener("change", saveSettings); | ||
| featuredEl.addEventListener("change", saveSettings); | ||
| blacklistEl.addEventListener("input", saveSettings); | ||
| whitelistEl.addEventListener("input", saveSettings); | ||
| loadSettings(); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet