// ==UserScript== // @name Youtube short remover // @namespace http://tampermonkey.net/ // @version base.1.0 // @description Removes Youtube shorts from search results and watch page, but without a configuration menu. // @author Mr_Comand // @license MIT // @match https://www.youtube.com/* // @icon https://www.google.com/s2/favicons?sz=64&domain=youtube.com // @updateURL https://raw.githubusercontent.com/Mr-Comand/youtube-shorts-remover-tampermonkey/main/base.user.js // @downloadURL https://raw.githubusercontent.com/Mr-Comand/youtube-shorts-remover-tampermonkey/main/base.user.js // @grant none // ==/UserScript== (function() { 'use strict'; // Configuration variables with default values var config = { c_removeFormStartPage: true, c_removeFormSubscriptionFeed: true, c_removeFormAllFeeds: true, // except SubscriptionFeed c_removeFormFollowUp: true, c_removeFormChannel: true, c_removeSidebar: true, c_disableShortPage: true, c_disableShortPageScrolling: true, c_removeFormSearch : true, c_consoleColor: '#33bd52', }; log("Configuration:"); log("c_removeFormStartPage", config.c_removeFormStartPage); log("c_removeFormSubscriptionFeed", config.c_removeFormSubscriptionFeed); log("c_removeFormAllFeeds", config.c_removeFormAllFeeds); log("c_removeFormFollowUp", config.c_removeFormFollowUp); log("c_removeFormChannel", config.c_removeFormChannel); log("c_removeSidebar", config.c_removeSidebar); log("c_removeFormSearch", config.c_removeFormSearch); log("c_disableShortPage", config.c_disableShortPage); log("c_disableShortPageScrolling", config.c_disableShortPageScrolling); log("c_consoleColor", config.c_consoleColor); log("============================"); function log(...args) { const message = args.map(arg => String(arg)).join(' '); console.log('%c[ShortsRemover] '+message, 'color: ' + config.c_consoleColor); } // Define the regex pattern for the YouTube start page var youtubeStartPagePattern = /^https?:\/\/(www\.)?youtube\.com\/?$/; // Define the regex pattern for the all YouTube feed pages //https://www.youtube.com/feed/* var youtubeFeedPagePattern = /^https?:\/\/(www\.)?youtube\.com\/((feed)|(gaming))(?!\/subscriptions.*).*$/; // Define the regex pattern for the YouTube subscriptions feed page //https://www.youtube.com/feed/subscriptions var youtubeSubscriptionsPagePattern = /^https?:\/\/(www\.)?youtube\.com\/feed\/subscriptions\/?$/; // Define the regex pattern for the YouTube watch pages //https://www.youtube.com/watch?v=* var youtubeWatchPagePattern = /^https?:\/\/(www\.)?youtube\.com\/watch\/?.*$/; // Define the regex pattern for the YouTube shorts pages //https://www.youtube.com/shorts/* var youtubeShortPagePattern = /^https?:\/\/(www\.)?youtube\.com\/shorts.*$/; // Define the regex pattern for the YouTube search page //https://www.youtube.com/shorts/* var youtubeSearchPagePattern = /^https?:\/\/(www\.)?youtube\.com\/results.*$/; // Define the regex pattern for the YouTube channel pages //https://www.youtube.com/LinusTechTips or https://www.youtube.com/@LinusTechTips ... var youtubeChannelPagePattern = /^https?:\/\/(www\.)?youtube\.com\/(?!feed.*)(?!watch.*)(?!short.*)(?!playlist.*)(?!podcasts.*)(?!gaming.*)(?!results.*).+$/; if (config.c_disableShortPageScrolling){ // Function to handle the custom scroll event function handleScroll(event) { if (youtubeShortPagePattern.test(window.location.href)) { // Your custom scroll handling code goes here log("Scrolling is disabled."); sendToHome(); // Prevent the default scroll behavior to disable other scroll listeners event.preventDefault(); // Add a scroll listener to the window } } window.addEventListener('scroll', handleScroll); window.addEventListener('wheel', handleScroll); } function removeShorts(){ // Get the current URL var currentURL = window.location.href; if (config.c_removeSidebar){ removeSidebarElement(); } // Check if the current URL matches the YouTube short page URL pattern if (youtubeShortPagePattern.test(currentURL) && config.c_disableShortPage) { // URL & config matches sendToHome(); log("Shorts page detected."); } // Check if the current URL matches the YouTube start page URL pattern if (youtubeStartPagePattern.test(currentURL) && config.c_removeFormStartPage) { // URL & config matches removeFormVideoOverview(); log("Shorts removed from Startpage."); } // Check if the current URL matches the YouTube feed page URL pattern if (youtubeFeedPagePattern.test(currentURL) && config.c_removeFormAllFeeds) { // URL & config matches removeReelShelfRenderer(); removeFormVideoOverview(); log("Shorts removed from Feed."); } // Check if the current URL matches the YouTube subscriptions feed page URL pattern if (youtubeSubscriptionsPagePattern.test(currentURL) && config.c_removeFormSubscriptionFeed) { // URL & config matches removeFormVideoOverview(); log("Shorts removed from subscriptions."); } // Check if the current URL matches the YouTube watch page URL pattern if (youtubeWatchPagePattern.test(currentURL) && config.c_removeFormFollowUp) { // URL & config matches removeReelShelfRenderer(); } if (youtubeChannelPagePattern.test(currentURL)&& config.c_removeFormChannel) { // URL & config matches removeReelShelfRenderer(); removeFormVideoOverview(); // Select all elements with tab-title Shorts var elementsToRemove = document.querySelectorAll('[tab-title="Shorts"]'); // Loop through each selected element and remove it elementsToRemove.forEach(function (element) { element.parentNode.removeChild(element); }); log("Shorts removed from channel."); //