移除 YouTube Shorts

移除 YouTube 上的 Shorts 标签、Dismissible 元素、Shorts 链接和 Reel Shelf

目前为 2024-12-30 提交的版本。查看 最新版本

  1. // ==UserScript==
  2. // @name Remove YouTube Shorts
  3. // @name:zh-CN 移除 YouTube Shorts
  4. // @name:zh-TW 移除 YouTube Shorts
  5. // @name:ja YouTube の Shorts を削除
  6. // @name:ko YouTube Shorts 제거
  7. // @name:es Eliminar YouTube Shorts
  8. // @name:pt-BR Remover YouTube Shorts
  9. // @name:ru Удалить YouTube Shorts
  10. // @name:id Hapus YouTube Shorts
  11. // @name:hi YouTube Shorts हटाएँ
  12. // @namespace https://github.com/strangeZombies
  13. // @version 2024-12-30.4
  14. // @description Remove YouTube Shorts tags, dismissible elements, Shorts links, and Reel Shelf
  15. // @description:zh-CN 移除 YouTube 上的 Shorts 标签、Dismissible 元素、Shorts 链接和 Reel Shelf
  16. // @description:zh-TW 移除 YouTube 上的 Shorts 标签、Dismissible 元素、Shorts 链接和 Reel Shelf
  17. // @description:ja YouTube 上の Shorts タグ、ディスミッシブル要素、Shorts リンク、および Reel Shelf を削除
  18. // @description:ko YouTube의 Shorts 태그, 해제 가능한 요소, Shorts 링크 및 Reel 선반 제거
  19. // @description:es Eliminar etiquetas de Shorts de YouTube, elementos desechables, enlaces de Shorts y estante de carretes
  20. // @description:pt-BR Remover tags de Shorts do YouTube, elementos descartáveis, links de Shorts e prateleira de rolos
  21. // @description:ru Удалите теги YouTube Shorts, элементы, которые можно отклонить, ссылки на Shorts и полку с катушками
  22. // @description:id Hapus tag Shorts YouTube, elemen yang dapat dihapus, tautan Shorts, dan Rak Reel
  23. // @description:hi YouTube Shorts टैग, खारिज करने योग्य तत्व, Shorts लिंक और Reel Shelf निकालें
  24. // @author StrangeZombies
  25. // @icon https://www.google.com/s2/favicons?sz=64&domain=youtube.com
  26. // @match https://www.youtube.com/*
  27. // @grant none
  28. // ==/UserScript==
  29.  
  30. (function () {
  31. 'use strict';
  32.  
  33. const selectors = [
  34. 'ytd-mini-guide-entry-renderer[aria-label="Shorts"]',
  35. 'div#dismissible.style-scope.ytd-rich-shelf-renderer',
  36. 'a#endpoint[title="Shorts"]',
  37. 'ytd-reel-shelf-renderer.style-scope.ytd-item-section-renderer',
  38. ];
  39.  
  40. function removeElements() {
  41. selectors.forEach((selector) => {
  42. document.querySelectorAll(selector).forEach((element) => element.remove());
  43. });
  44. }
  45.  
  46. let debounceTimeout;
  47. function debouncedRemoveElements() {
  48. clearTimeout(debounceTimeout);
  49. debounceTimeout = setTimeout(removeElements, 200);
  50. }
  51.  
  52. window.addEventListener('load', removeElements);
  53.  
  54. const observer = new MutationObserver(debouncedRemoveElements);
  55. observer.observe(document.body, { childList: true, subtree: true });
  56. })();