隱藏youtube片尾畫面

自動隱藏 YouTube 影片結尾

安裝腳本?
作者推薦腳本

您可能也會喜歡 按鍵與滑鼠滾輪翻頁器

安裝腳本
  1. // ==UserScript==
  2. // @name 隱藏youtube片尾畫面
  3. // @name:ja YouTubeの終了畫面を非表示にする。
  4. // @name:en Hide end-screens of YouTube.
  5. // @namespace https://github.com/Max46656
  6. // @version 1.0
  7. // @description 自動隱藏 YouTube 影片結尾
  8. // @description:en Automatically hide end-screens at the end of YouTube videos.
  9. // @description:ja YouTube動畫の最後にある終了畫面を自動的に非表示にします。
  10. // @author Max
  11. // @license MIT
  12. // @match https://www.youtube.com/
  13. // @match https://www.youtube.com/watch?v=*
  14. // @icon https://www.google.com/s2/favicons?sz=64&domain=youtube.com
  15. // @grant none
  16. // ==/UserScript==
  17.  
  18. class youTubeRecommendationHider {
  19. constructor(recommendedVideosClass,maxRecommend,maxCheckCount,videoSrc = null,recommendedVideosCount=0) {
  20. this.recommendedVideosClass = recommendedVideosClass;
  21. this.maxRecommend = maxRecommend;
  22. this.maxCheckCount = maxCheckCount;
  23. this.maxCheckCountReseter=maxCheckCount;
  24. this.videoSrc = videoSrc;
  25. this.recommendedVideosCount = recommendedVideosCount;
  26. this.videoPlayer = document.querySelector('video');
  27. }
  28.  
  29. hideRecommendVideos() {
  30. let allRecommendedViedo = document.querySelectorAll(this.recommendedVideosClass);
  31. allRecommendedViedo.forEach(element => {
  32. console.log('刪除' + element.querySelector('a').href);
  33. element.remove();
  34. this.recommendedVideosCount++;
  35. console.log('刪除推薦影片數' + this.recommendedVideosCount);
  36. });
  37. if (this.recommendedVideosCount < this.maxRecommend && this.maxCheckCount > 0) {
  38. this.maxCheckCount--;
  39. console.log('剩餘檢查次數' + this.maxCheckCount);
  40. setTimeout(() => this.hideRecommendVideos(), 1000);
  41. }
  42. }
  43.  
  44. resetVariables() {
  45. console.log('重置變數');
  46. this.recommendedVideosCount = 0;
  47. this.maxCheckCount = this.maxCheckCountReseter;
  48. this.hideRecommendVideos();
  49. }
  50.  
  51. newTab() {
  52. if (this.videoSrc == null) {
  53. console.log('新YouTube分頁');
  54. this.hideRecommendVideos();
  55. }
  56. }
  57.  
  58. sameTab() {
  59. if (this.videoPlayer) {
  60. this.videoSrc = this.videoPlayer.src;
  61. console.log('影片偵測<video>' + this.videoSrc);
  62. const observer = new MutationObserver(mutations => {
  63. mutations.forEach(mutation => {
  64. if (mutation.attributeName === 'src' && this.videoPlayer.src !== this.videoSrc) {
  65. console.log('新影片偵測' + this.videoPlayer.src);
  66. this.videoSrc = this.videoPlayer.src;
  67. this.resetVariables();
  68. }
  69. });
  70. });
  71. observer.observe(this.videoPlayer, { attributes: true });
  72. }
  73. }
  74. }
  75.  
  76. const johnTheCleaner=new youTubeRecommendationHider('.ytp-ce-element',4,3);
  77. johnTheCleaner.newTab();
  78. johnTheCleaner.sameTab();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址