您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Hides "YouTube Shorts" videos from showing in Trending, Search and Recommended on the YouTube website.
当前为
// ==UserScript== // @name Hide YouTube Shorts // @namespace https://www.taylrr.co.uk/ // @version 0.1 // @description Hides "YouTube Shorts" videos from showing in Trending, Search and Recommended on the YouTube website. // @author taylor8294 // @include https://www.youtube.com/feed/trending* // @include https://www.youtube.com/results* // @include https://www.youtube.com/watch* // @include https://www.youtube.com/shorts* // @icon https://i.ytimg.com/an/r0deIusKuMOsUobj89aPZA/featured_channel.jpg?v=60f4dc70 // @grant none // @license GPLv3 // ==/UserScript== (function() { 'use strict'; if(window.location.pathname.toLowerCase().startsWith('/shorts/')){ window.location.href = window.location.origin+'/watch?v='+window.location.pathname.replace(/^\/shorts\//g,'')+window.location.search.replace(/^\?/g,'&') } else { let removeShorts = function(){ // Trending Array.from(document.querySelectorAll('a.ytd-thumbnail[href^="/shorts"]')).forEach(a => a.closest('ytd-video-renderer').remove() ) Array.from(document.querySelectorAll('#video-title.ytd-video-renderer')).forEach(a => /\#shorts?/.test(a.innerText.toLowerCase()) ? a.closest('ytd-video-renderer').remove() : null) Array.from(document.querySelectorAll('#description-text.ytd-video-renderer')).forEach(yfs => /\#shorts?/.test(yfs.innerText.toLowerCase()) ? yfs.closest('ytd-video-renderer').remove() : null ) // Search Array.from(document.querySelectorAll('.title-and-badge.ytd-video-renderer')).forEach(h3 => /\#shorts?/.test(h3.innerText.toLowerCase()) ? h3.closest('ytd-video-renderer').remove() : null) Array.from(document.querySelectorAll('.metadata-snippet-container.ytd-video-renderer')).forEach(div => /\#shorts?/.test(div.innerText.toLowerCase()) ? div.closest('ytd-video-renderer').remove() : null) // Recommended Array.from(document.querySelectorAll('#video-title.ytd-compact-video-renderer')).forEach(span => /\#shorts?/.test(span.innerText.toLowerCase()) ? span.closest('ytd-compact-video-renderer').remove() : null) } const observer = new MutationObserver(list => { let newVideosAdded = false, i = list.length, j = 0 while(i>0){ j = list[i-1].addedNodes.length while(j>0){ if(list[i-1].addedNodes[j-1].tagName && ['ytd-video-renderer','ytd-compact-video-renderer'].includes(list[i-1].addedNodes[j-1].tagName.toLowerCase())){ newVideosAdded = true; break; } j -= 1; } if(newVideosAdded) break; i -= 1; } if(newVideosAdded) removeShorts() }); observer.observe(document.body, {attributes: false, childList: true, subtree: true}); removeShorts() } })();