YouTube Anti-AdBlock Bypass via YouTube Enhancer

A simple method of bypassing YouTube's AdBlock Detection using Enhancer for YouTube's "Remove Ads" button. Does not require the use of any external website like similar tools do :)

当前为 2023-10-22 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name YouTube Anti-AdBlock Bypass via YouTube Enhancer
  3. // @namespace https://e-z.bio/yaw
  4. // @icon https://www.gstatic.com/youtube/img/branding/favicon/favicon_192x192.png
  5. // @version 1.4
  6. // @description A simple method of bypassing YouTube's AdBlock Detection using Enhancer for YouTube's "Remove Ads" button. Does not require the use of any external website like similar tools do :)
  7. // @author Yaw
  8. // @match https://www.youtube.com/*
  9. // @license MIT
  10. // @grant GM_getValue
  11. // @grant GM_setValue
  12. // ==/UserScript==
  13.  
  14. (function() {
  15. 'use strict';
  16.  
  17. var searchInterval = GM_getValue('searchInterval', 800);
  18. var failCounter = 0;
  19. var masterSwitch = true;
  20.  
  21. function createSettingsMenu() {
  22. const settingsButton = document.createElement('button');
  23. settingsButton.textContent = 'Bypasser Settings';
  24. settingsButton.style.position = 'fixed';
  25. settingsButton.style.top = '50px';
  26. settingsButton.style.left = '60px';
  27. settingsButton.style.background = '#555';
  28. settingsButton.style.color = '#fff';
  29. settingsButton.style.border = '1px solid #FE2020';
  30. settingsButton.style.borderRadius = '5px';
  31. settingsButton.style.padding = '5px 10px';
  32. settingsButton.style.cursor = 'pointer';
  33. settingsButton.style.zIndex = '9999';
  34. document.body.appendChild(settingsButton);
  35.  
  36. const settingsMenuHTML = `
  37. <div id="yt-settings-menu" style="display: none; position: fixed; top: 50px; left: 55px; background: #333; color: #fff; border: 1px solid #FE2020; border-radius: 10px; padding: 10px; z-index: 10000;"> <!-- Higher z-index to be on top -->
  38. <h2 style="text-align: center;">Bypasser Settings</h2>
  39. <br>
  40. <div style="text-align: center; margin-top: 5px; margin-bottom: 0px;">
  41. <label for="search-interval" style="display: inline-block; width: 100px; vertical-align: middle;">Search Interval:</label>
  42. <input type="range" id="search-interval" min="100" max="5000" style="display: inline-block; vertical-align: middle;">
  43. <span id="search-interval-value" style="display: inline-block; vertical-align: middle;">800</span>
  44. </div>
  45. <div style="text-align: center; margin-top: 10px;">
  46. <button id="save-settings" style="background: #555; color: #fff; border: none; border-radius: 5px; padding: 5px 10px; cursor: pointer;">Save Settings</button>
  47. <p style="color: #aaa; display: inline-block; margin-left: 10px;">(Page will refresh)</p>
  48. </div>
  49. <p style="text-align: center; color: #aaa; margin-top: 10px;">Made by github.com/AWeirDKiD (Yaw)</p>
  50. </div>
  51. `;
  52.  
  53. const settingsMenu = document.createElement('div');
  54. settingsMenu.innerHTML = settingsMenuHTML;
  55. settingsMenu.style.zIndex = '10000';
  56. document.body.appendChild(settingsMenu);
  57.  
  58. settingsButton.addEventListener('click', () => {
  59. document.getElementById('yt-settings-menu').style.display = 'block';
  60. document.getElementById('search-interval').value = searchInterval;
  61. document.getElementById('search-interval-value').textContent = searchInterval;
  62. });
  63.  
  64. document.getElementById('search-interval').addEventListener('input', () => {
  65. searchInterval = parseInt(document.getElementById('search-interval').value);
  66. document.getElementById('search-interval-value').textContent = searchInterval;
  67. });
  68.  
  69. document.getElementById('save-settings').addEventListener('click', () => {
  70. GM_setValue('searchInterval', searchInterval);
  71. location.reload()
  72. document.getElementById('yt-settings-menu').style.display = 'none';
  73. });
  74. }
  75.  
  76. function removeAds() {
  77. console.log("test")
  78. const currentURL = window.location.href;
  79. if (masterSwitch) {
  80. if (/https:\/\/www\.youtube\.com\/watch\?.*/.test(currentURL)) {
  81. const button = document.getElementById("efyt-not-interested");
  82. const adShowing = [...document.querySelectorAll('.ad-showing')][0];
  83. if (adShowing) {
  84. if (button) {
  85. button.click();
  86. console.log("Button found and clicked.")
  87. failCounter = 0;
  88. }
  89. else {
  90. console.log("Failed to find button. Retrying in ", searchInterval, " ms");
  91. failCounter = failCounter + 1;
  92. }
  93. if (failCounter > 10) {
  94. var buttonNotFound = window.confirm("Failed to find the button more than 10 times. Please make sure that Enhancer for YouTube is installed.\n\nPress 'OK' to redirect to the installation page.\nPress 'Cancel' to disable the Bypasser for this session.");
  95. if (buttonNotFound) {
  96. window.open("https://chrome.google.com/webstore/detail/enhancer-for-youtube/ponfpcnoihfmfllpaingbgckeeldkhle");
  97. failCounter = 0;
  98. } else {
  99. masterSwitch = false;
  100. }
  101. }
  102. }
  103. }
  104. }
  105. }
  106. createSettingsMenu();
  107. setInterval(removeAds, searchInterval);
  108. })();