Advertisement
Guest User

Untitled

a guest
Feb 25th, 2022
2,097
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // ==UserScript==
  2. // @name        YouTube Shorts Remover
  3. // @namespace   Deez Nutz
  4. // @match       https://*youtube.com/results*
  5. // @grant       none
  6. // @version     1.1
  7. // @author      -
  8. // @description Remove YT search results that are shorts
  9. // ==/UserScript==
  10.  
  11. (function() {
  12.   let observer = new MutationObserver(handler);
  13.  
  14.   function handler(mutations) {
  15.     for (let mutation of mutations) {
  16.       if (mutation.type === 'childList') {
  17.         let target = mutation.target;
  18.  
  19.         if(target.id == 'overlays' && target.className.includes('ytd-thumbnail')) {
  20.           target.childNodes.forEach(function(childNode) {
  21.             if(childNode.getAttribute('overlay-style') == 'SHORTS') {
  22.               target.closest('ytd-video-renderer').remove();
  23.             }
  24.           });
  25.         }
  26.       }
  27.     }
  28.   }
  29.  
  30.   observer.observe(
  31.     document.getElementsByTagName("body")[0],
  32.     { subtree: true, childList: true }
  33.   );
  34. })();
  35.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement