ad free youtube grid

hides the lame new format top level youtube ads

当前为 2020-07-18 提交的版本,查看 最新版本

  1. // ==UserScript==
  2.  
  3. // @name ad free youtube grid
  4. // @namespace youtube_grid_kboudy
  5. // @description hides the lame new format top level youtube ads
  6. // @version 1.4
  7. // @run-at document-start
  8. // @match https://www.youtube.com/*
  9. // @run-at document-start
  10. // @grant none
  11. // ==/UserScript==
  12.  
  13. let interval = null;
  14. let counter = 0;
  15.  
  16. const hideTopLevelAdContent = () => {
  17. const ads = document.getElementsByTagName("ytd-display-ad-renderer");
  18. counter++;
  19. if (ads && ads.length > 0)
  20. {
  21. clearInterval(interval);
  22. for (const a of ads)
  23. {
  24. a.parentElement.parentElement.style.display="none";
  25. }
  26. }
  27. else if (counter === 30)
  28. {
  29. clearInterval(interval);
  30. }
  31. }
  32.  
  33. hideTopLevelAdContent();
  34. interval = setInterval(function(){
  35. hideTopLevelAdContent();
  36. },100);