Youtube Anti Shorts

shorts is a shit, fuck you youtube

目前為 2023-01-09 提交的版本,檢視 最新版本

  1. // ==UserScript==
  2. // @name Youtube Anti Shorts
  3. // @name:zh Youtube Anti Shorts 反短片
  4. // @namespace Anong0u0
  5. // @version 0.3
  6. // @description shorts is a shit, fuck you youtube
  7. // @description:zh 短片就是坨屎,去你的youtube
  8. // @author Anong0u0
  9. // @match *://*.youtube.com/*
  10. // @icon https://www.google.com/s2/favicons?sz=64&domain=youtube.com
  11. // @grant none
  12. // @require https://cdn.jsdelivr.net/npm/arrive@2.4.1/minified/arrive.min.js
  13. // @license MIT
  14. // ==/UserScript==
  15.  
  16.  
  17. // ===================
  18. // If you don't like these feature, you can turn it off with replace true to false.
  19. // 如果你不喜歡這些功能,你可以把true改成false來關閉。
  20.  
  21. const Remove_Shorts_Renderer = true;
  22. const Hide_Shorts_Video = true;
  23. const Redirect_Shorts_URL = true;
  24. // ===================
  25.  
  26.  
  27. Node.prototype.getParentElement = function(times = 0){return (times > 0) ? this.parentElement.getParentElement(times-1):this;}
  28.  
  29. if(Remove_Shorts_Renderer)
  30. {
  31. const css = document.createElement("style");
  32. css.innerHTML = `
  33. ytd-reel-shelf-renderer.style-scope.ytd-item-section-renderer,
  34. ytd-mini-guide-entry-renderer[aria-label='Shorts'],
  35. ytd-rich-shelf-renderer[is-shorts],
  36. a.yt-simple-endpoint.style-scope.ytd-guide-entry-renderer[title='Shorts']
  37. {display:none !important}`;
  38. document.documentElement.append(css);
  39. }
  40.  
  41. if(Hide_Shorts_Video)
  42. {
  43. document.arrive('a[href^="/shorts"]', (e)=>
  44. {
  45. e.getParentElement(3).style.display = "none"
  46. });
  47. }
  48.  
  49. if(Redirect_Shorts_URL)
  50. {
  51. var oldHref = null;
  52. new MutationObserver(() => // onUrlChange
  53. {
  54. if (oldHref == window.location.href) return;
  55. oldHref = window.location.href;
  56.  
  57. if(window.location.pathname.indexOf("/shorts/")!=-1) window.location.replace(window.location.href.replace("/shorts/","/watch?v="));
  58.  
  59. }).observe(document.body, {childList: true, subtree: true});
  60. }
  61.