YouTube Adblock warning Remover

Removes Adblock warning for a better viewing experience.

当前为 2024-02-26 提交的版本,查看 最新版本

  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. // Remove video advertisements
  17. function removeVideoAds() {
  18. const ads = document.querySelectorAll('.ad-showing');
  19. ads.forEach(ad => ad.remove());
  20. }
  21.  
  22. // Remove pop-ups
  23. function removePopups() {
  24. const popups = document.querySelectorAll('.style-scope ytd-enforcement-message-view-model');
  25. popups.forEach(popup => popup.remove());
  26. }
  27.  
  28. // Remove page advertisements
  29. function removePageAds() {
  30. const pageAds = document.querySelectorAll('.style-scope.ytd-display-ad-renderer');
  31. pageAds.forEach(ad => ad.remove());
  32. }
  33.  
  34. // Check if the page is YouTube
  35. if (window.location.hostname === 'www.youtube.com') {
  36. // Remove ads and pop-ups when the DOM is ready
  37. document.addEventListener('DOMContentLoaded', function() {
  38. removeVideoAds();
  39. removePopups();
  40. removePageAds();
  41. });
  42. }
  43. })();