YouTube - Remove YouTube shorts and noise from the main page
当前为
// ==UserScript==
// @name YouTube - Remove YouTube shorts and noise from main page
// @namespace Violentmonkey Scripts
// @match *://www.youtube.com/*
// @version 2.2
// @author jez9999
// @description YouTube - Remove YouTube shorts and noise from the main page
// @require https://code.jquery.com/jquery-3.6.0.min.js
// @run-at document-start
// @grant none
// @license MIT
// ==/UserScript==
(function() {
'use strict';
// ********************
// Reminder: set the following in Violentmonkey advanced settings for Editor:
// "tabSize": 4,
// "indentUnit": 4,
// "autoCloseBrackets": false,
//
// Also, bear in mind there appears to be a bug in Violentmonkey where after a while, MutationObserver's
// stop being debuggable and the whole browser needs restarting before it'll work again.
// ********************
var utils = {};
utils.jq = jQuery.noConflict( true );
utils.isUnspecified = function(input) {
return ((typeof input === "undefined") || (input === null));
}
utils.isSpecified = function(input) {
return ((typeof input !== "undefined") && (input !== null));
}
// Add 'hidden renderer' class
var sheet = document.createElement('style');
sheet.innerHTML = `
ytd-rich-shelf-renderer[is-shorts] { display: none !important; }
`;
// ^ If we ever want to hide the parent ytd-rich-section-renderer instead of the ytd-rich-shelf-renderer in future, we can use the :has pseudo-class thus:
// sheet.innerHTML = `
// ytd-rich-section-renderer:has(ytd-rich-shelf-renderer[is-shorts]) { display: none !important; }
// `;
sheet.innerHTML = sheet.innerHTML + `
ytd-statement-banner-renderer { display: none !important; }
.ytd-video-masthead-ad-v3-renderer { display: none !important; }
#masthead-ad { display: none !important; }
`;
document.head.appendChild(sheet);
})();