Remove YouTube Shorts

on each and every page except the Shorts page.

当前为 2022-03-30 提交的版本,查看 最新版本

// ==UserScript==
// @name     	    Remove YouTube Shorts
// @description	    on each and every page except the Shorts page.
// @version  	    1.1
// @grant    	    none
// @match    	    https://www.youtube.com/*
// @exclude 	    https://www.youtube.com/shorts/*
// @license         MIT
// @namespace       Remove YouTube Shorts automatically
// ==/UserScript==
var timeStatusOverlay = document.getElementsByTagName('ytd-thumbnail-overlay-time-status-renderer');
var i = 0;

function delShorts() {
    if (i < timeStatusOverlay.length) {
        i = 0;
        while (i < timeStatusOverlay.length) {
            if (timeStatusOverlay[i].getAttribute("overlay-style") == 'SHORTS') {
                timeStatusOverlay[i].parentElement.parentElement.parentElement.parentElement.parentElement.remove();
                continue;
            } else {
                i++;
            }
        }
    }
}

if (!localStorage.getItem("dSButtonSettings")) {
    localStorage.setItem("dSButtonSettings", "red");
}
var delShortsInterval;
if (localStorage.getItem("dSButtonSettings") == 'green') {
    delShortsInterval = setInterval(delShorts, 1000);
}

const div = document.createElement('DIV');
div.id = 'dSDiv';
div.style.position = 'absolute';
div.style.zIndex = '99999';

const button = document.createElement('BUTTON');
button.id = 'dSButton';
button.innerHTML = 'DEL Shorts';
button.style.border = 'none';
button.style.color = 'white';
button.style.fontSize = '1rem';
button.style.background = localStorage.getItem("dSButtonSettings");
button.addEventListener('click', function () {
	if (localStorage.getItem("dSButtonSettings") == 'red') {
  	    button.style.background = 'green';
        localStorage.setItem("dSButtonSettings", "green");
        delShortsInterval = setInterval(delShorts, 1000);
    } else if (localStorage.getItem("dSButtonSettings") == 'green') {
  	    button.style.background = 'red';
        localStorage.setItem("dSButtonSettings", "red");
        clearInterval(delShortsInterval);
    }
});

div.appendChild(button);
document.getElementById('center').appendChild(div);

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址