Remove Youtube's popup

Script to remove the popup that randomly shows when watching videos in their site

目前为 2022-10-02 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Remove Youtube's popup
  3. // @version 0.3
  4. // @description Script to remove the popup that randomly shows when watching videos in their site
  5. // @author Vingyard
  6. // @include /youtube.com/
  7. // @grant none
  8. // @namespace https://greasyfork.org/users/150647
  9. // ==/UserScript==
  10.  
  11. (function() {
  12. 'use strict';
  13. let interval
  14.  
  15. function getAdsChecker() {
  16. return setInterval(() => {
  17. const elements = document.getElementsByClassName("style-scope yt-button-renderer style-blue-text size-default")
  18. if (elements.length > 2) {
  19. elements[elements.length-1].click();
  20. }
  21. }, 1000);
  22. }
  23.  
  24. document.addEventListener("yt-navigate-finish", function(...params) {
  25. if (!interval) clearInterval(interval)
  26. interval = getAdsChecker()
  27. })
  28. })();