Youtube Hide Recomended (English)

Automatically switches YouTube's recommendation column to either "From the series", "from (channel name)", or "Related"

当前为 2025-05-09 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Youtube Hide Recomended (English)
  3. // @name:ja YouTubeのリコメンド自動切換・非表示
  4. // @version 2024-11-24
  5. // @description Automatically switches YouTube's recommendation column to either "From the series", "from (channel name)", or "Related"
  6. // @description:ja YouTubeのリコメンド欄を自動でFrom the series、from (チャンネル名)、Relatedのどれかに切り替えます
  7. // @author hirhirbyrd
  8. // @match https://www.youtube.com/*
  9. // @license MIT
  10. // @namespace https://greasyfork.org/users/1467931
  11. // ==/UserScript==
  12.  
  13. (function() {
  14. 'use strict';
  15.  
  16.  
  17. const observer = new MutationObserver(() => {
  18.  
  19. const chname = document.querySelector('.complex-string.ytd-channel-name.style-scope')
  20. const lists = document.querySelector('div#secondary-inner.style-scope.ytd-watch-flexy');
  21.  
  22. const elementC = document.querySelector('div#related iron-selector#chips yt-chip-cloud-chip-renderer:has(#text[title="From the series"])');
  23. const elementA = document.querySelector('div#related iron-selector#chips yt-chip-cloud-chip-renderer:has(#text[title="From ' + chname.textContent + '"])');
  24. const elementB = document.querySelector('div#related iron-selector#chips yt-chip-cloud-chip-renderer:has(#text[title="Related"])');
  25.  
  26. if (elementC) {
  27. if (elementC.getAttribute('aria-selected') === 'false') {
  28. lists.hidden = false;
  29. elementC.click();
  30. }
  31. } else if (elementA) {
  32. if (elementA.getAttribute('aria-selected') === 'false') {
  33. lists.hidden = false;
  34. elementA.click();
  35. }
  36. } else if (elementB) {
  37. if (elementB.getAttribute('aria-selected') === 'false') {
  38. lists.hidden = false;
  39. elementB.click();
  40. }
  41. } else {
  42. lists.hidden = true;
  43. return;
  44. }
  45.  
  46. });
  47.  
  48. observer.observe(document, { childList: true, subtree: true });
  49. })();