YouTube Ad Skipper and Detection Bypass (Enhanced for Mobile)

Bypass YouTube's ad blocker detection, skip ads seamlessly on both desktop and mobile, and notify users about updates or issues.

  1. // ==UserScript==
  2. // @name YouTube Ad Skipper and Detection Bypass (Enhanced for Mobile)
  3. // @namespace http://tampermonkey.net/
  4. // @version 2.3
  5. // @description Bypass YouTube's ad blocker detection, skip ads seamlessly on both desktop and mobile, and notify users about updates or issues.
  6. // @author ImprovedScript
  7. // @match *://*.youtube.com/*
  8. // @grant none
  9. // ==/UserScript==
  10.  
  11. (function () {
  12. 'use strict';
  13.  
  14. /** Utility to log actions */
  15. const logAction = (action) => console.log(`[Ad Skipper] ${action}`);
  16.  
  17. /** Notification System */
  18. const showNotification = (message, type = "info") => {
  19. const notification = document.createElement("div");
  20. Object.assign(notification.style, {
  21. position: "fixed",
  22. bottom: "10px",
  23. right: "10px",
  24. zIndex: "9999",
  25. backgroundColor: type === "error" ? "#ff4c4c" : "#4caf50",
  26. color: "#fff",
  27. padding: "10px",
  28. borderRadius: "4px",
  29. fontFamily: "Arial, sans-serif",
  30. fontSize: "12px",
  31. width: "calc(100% - 20px)", // Mobile-friendly width
  32. maxWidth: "300px", // Limit to desktop-friendly width
  33. textAlign: "center",
  34. });
  35.  
  36. notification.textContent = message;
  37.  
  38. document.body.appendChild(notification);
  39. setTimeout(() => notification.remove(), 5000);
  40. };
  41.  
  42. /** Check for Updates and Health of Script */
  43. const checkScriptHealth = async () => {
  44. try {
  45. const adElements = document.querySelectorAll(".ytp-ad-skip-button, .ytp-ad-overlay-close-button");
  46. if (adElements.length === 0) {
  47. logAction("No ads found to skip.");
  48. }
  49.  
  50. // Simulate a version check
  51. const response = await fetch("https://update.greasyfork.org/scripts/519893/version-check");
  52. if (response.ok) {
  53. const data = await response.json();
  54. if (data.latestVersion && data.latestVersion !== "2.3") {
  55. showNotification("A new version of the script is available. Please update!", "error");
  56. logAction("Script update available notification displayed.");
  57. }
  58. } else {
  59. throw new Error("Failed to fetch update information.");
  60. }
  61. } catch (error) {
  62. console.error("[Ad Skipper] Error during health check:", error);
  63. showNotification("Error during script health check. Consider checking for updates.", "error");
  64. }
  65. };
  66.  
  67. /** Skip Ads on YouTube */
  68. const skipAds = () => {
  69. const adSelectors = [
  70. ".ytp-ad-skip-button",
  71. ".ytp-ad-overlay-close-button",
  72. ".ytp-ad-player-overlay",
  73. "div.ytp-ad-module",
  74. ];
  75. adSelectors.forEach((selector) => {
  76. document.querySelectorAll(selector).forEach((el) => {
  77. el.click();
  78. el.remove();
  79. logAction(`Skipped ad using selector: ${selector}`);
  80. });
  81. });
  82. };
  83.  
  84. /** Bypass Ad Blocker Detection */
  85. const bypassAdBlocker = () => {
  86. const observer = new MutationObserver((mutations) => {
  87. mutations.forEach((mutation) => {
  88. mutation.addedNodes.forEach((node) => {
  89. if (
  90. node.nodeType === 1 &&
  91. node.tagName === "YTD-POPUP-CONTAINER" &&
  92. node.textContent.includes("ad blocker")
  93. ) {
  94. node.remove();
  95. logAction("Removed ad blocker detection popup.");
  96. }
  97. });
  98. });
  99. });
  100.  
  101. observer.observe(document.body, { childList: true, subtree: true });
  102. logAction("Ad blocker detection bypass activated.");
  103. };
  104.  
  105. /** Adjust for Mobile Specific Layouts */
  106. const adaptToMobile = () => {
  107. // Ensure notifications and actions are adjusted for touch-friendly interfaces
  108. const metaViewport = document.querySelector('meta[name="viewport"]');
  109. if (!metaViewport) {
  110. const viewport = document.createElement("meta");
  111. viewport.name = "viewport";
  112. viewport.content = "width=device-width, initial-scale=1";
  113. document.head.appendChild(viewport);
  114. logAction("Viewport meta tag added for mobile compatibility.");
  115. }
  116. };
  117.  
  118. /** Initialize the Script */
  119. const init = () => {
  120. logAction("Initializing Ad Skipper...");
  121. showNotification("Ad Skipper script initialized!", "info");
  122.  
  123. adaptToMobile();
  124. bypassAdBlocker();
  125. const observer = new MutationObserver(skipAds);
  126. observer.observe(document.body, { childList: true, subtree: true });
  127.  
  128. // Periodic health check
  129. setInterval(checkScriptHealth, 60000);
  130. };
  131.  
  132. // Start the script
  133. init();
  134. })();