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