YouTube Adblock warning Remover

Removes Adblock warning for a better viewing experience.

当前为 2024-03-08 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name YouTube Adblock warning Remover
  3. // @namespace http://samuelaraujo.pt
  4. // @version 1.3
  5. // @description Removes Adblock warning for a better viewing experience.
  6. // @author Samuel Araújo
  7. // @match https://www.youtube.com/*
  8. // @grant none
  9. // @icon https://www.google.com/s2/favicons?sz=64&domain=youtube.com
  10. // ==/UserScript==
  11.  
  12. (function() {
  13. 'use strict';
  14.  
  15. function removeVideoAds() {
  16. const ads = document.querySelectorAll('.ad-showing');
  17. ads.forEach(ad => ad.remove());
  18. }
  19.  
  20. function removePopups() {
  21. const popups = document.querySelectorAll('.style-scope ytd-enforcement-message-view-model');
  22. popups.forEach(popup => popup.remove());
  23. }
  24.  
  25. function removePageAds() {
  26. const pageAds = document.querySelectorAll('.style-scope.ytd-display-ad-renderer');
  27. pageAds.forEach(ad => ad.remove());
  28. }
  29.  
  30. if (window.location.hostname === 'www.youtube.com') {
  31. // Remove ads and pop-ups when the DOM is ready
  32. document.addEventListener('DOMContentLoaded', function() {
  33. removeVideoAds();
  34. removePopups();
  35. removePageAds();
  36. });
  37. }
  38. })();