From fe8d02a21fefab7a81d993fe0e4e65fca9014f2d Mon Sep 17 00:00:00 2001 From: Sven Heidemann Date: Thu, 17 Jul 2025 13:07:51 +0200 Subject: [PATCH] =?UTF-8?q?yt-shorts-remover.js=20hinzugef=C3=BCgt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- yt-shorts-remover.js | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 yt-shorts-remover.js diff --git a/yt-shorts-remover.js b/yt-shorts-remover.js new file mode 100644 index 0000000..dd6a236 --- /dev/null +++ b/yt-shorts-remover.js @@ -0,0 +1,35 @@ +// ==UserScript== +// @name YouTube Shorts Blocker & Redirector +// @namespace http://tampermonkey.net/ +// @version 1.3 +// @description Entfernt Shorts von YouTube + Weiterleitung von /shorts/* zur Startseite +// @author Du +// @match https://www.youtube.com/* +// @grant none +// ==/UserScript== + +(function() { + 'use strict'; + + // 1. Weiterleitung, falls URL mit /shorts/ beginnt + if (location.pathname.startsWith('/shorts/')) { + window.location.replace('https://www.youtube.com/'); + return; + } + + // 2. Funktion zum Entfernen von Shorts-Elementen + function removeShorts() { + // Entferne alle + document.querySelectorAll('a[title="Shorts"]').forEach(el => el.remove()); + + // Entferne alle Elemente mit dem Attribut is-shorts + document.querySelectorAll('[is-shorts]').forEach(el => el.remove()); + } + + // 3. Beim Laden ausführen + window.addEventListener('load', removeShorts); + + // 4. Auch auf dynamischen Content achten + const observer = new MutationObserver(removeShorts); + observer.observe(document.body, { childList: true, subtree: true }); +})();