commit d7ed922b18223610c436b336064c80c8b13a9320 Author: pschwarzer20 Date: Sun May 19 23:45:44 2024 +0200 Initial commit diff --git a/Content.js b/Content.js new file mode 100644 index 0000000..beb0893 --- /dev/null +++ b/Content.js @@ -0,0 +1,38 @@ + +function removeShortButtons(){ + const shortsButtons = document.querySelectorAll('a[title="Shorts"]'); + + shortsButtons.forEach(button => { + button.remove(); + }); +} + +function removeShortSections(){ + const sections = document.querySelectorAll("span#title.style-scope.ytd-rich-shelf-renderer"); + sections.forEach(title => { + if (title.textContent.trim() === "Shorts") { + var section = title; + for (let i = 1; i < 7; i++) { + section = section.parentElement; + if (!section){ + return; + } + } + + if (section.className == "style-scope ytd-rich-shelf-renderer") { + section.style.display = "none"; + } + } + }); +} + +document.addEventListener("DOMContentLoaded", function () { + removeShortButtons(); + removeShortSections(); +}); + +const observer = new MutationObserver(function (mutations) { + removeShortButtons(); + removeShortSections(); +}); +observer.observe(document.body, { childList: true, subtree: true }); \ No newline at end of file diff --git a/icon128.png b/icon128.png new file mode 100644 index 0000000..518ba19 Binary files /dev/null and b/icon128.png differ diff --git a/icon16.png b/icon16.png new file mode 100644 index 0000000..dbbe537 Binary files /dev/null and b/icon16.png differ diff --git a/icon32.png b/icon32.png new file mode 100644 index 0000000..0d683ed Binary files /dev/null and b/icon32.png differ diff --git a/icon48.png b/icon48.png new file mode 100644 index 0000000..9b78e4f Binary files /dev/null and b/icon48.png differ diff --git a/manifest.json b/manifest.json new file mode 100644 index 0000000..6936e47 --- /dev/null +++ b/manifest.json @@ -0,0 +1,18 @@ +{ + "manifest_version": 3, + "name": "Block Youtube Shorts", + "description": "Blocks the Youtube Short buttons and sections on the main page.", + "version": "1.0", + "icons": { + "16": "icon16.png", + "32": "icon32.png", + "48": "icon48.png", + "128": "icon128.png" + }, + "content_scripts": [ + { + "matches": ["https://www.youtube.com/*"], + "js": ["Content.js"] + } + ] +} \ No newline at end of file