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.2
// @grant    	    none
// @match    	    https://www.youtube.com/*
// @exclude 	    https://www.youtube.com/shorts/*
// @license         MIT
// @namespace       Remove YouTube Shorts automatically
// ==/UserScript==
if (!localStorage.getItem("dSButtonSettings")) {
	localStorage.setItem("dSButtonSettings", "red");
}

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++;
      }
    }
  }
}

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 (button.style.background == 'red' || button.style.background == 'red none repeat scroll 0% 0%') {
  	button.style.background = 'green';
    localStorage.setItem("dSButtonSettings", "green");
    delShortsInterval = setInterval(delShorts, 1000);
  } else if (button.style.background == 'green' || button.style.background == 'green none repeat scroll 0% 0%') {
  	button.style.background = 'red';
    localStorage.setItem("dSButtonSettings", "red");
    clearInterval(delShortsInterval);
  }
});

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