您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Bypass YouTube's ad-blocker detection by dynamically replacing the video player with an iframe.
"YouTube iFrame Bypass" is an ingenious userscript that helps persistent YouTube viewers bypass the frustrating "Ad blockers are not allowed on YouTube" message. It employs a clever technique of dynamically inserting an iframe
player to replace the standard YouTube player. This method effectively circumvents YouTube's ad-blocker detection, allowing for an uninterrupted, ad-free viewing experience even after YouTube's standard measures have been triggered. Ideal for those who have been directly targeted by the anti-adblocker prompt and do not wish to disable their ad blockers or subscribe to YouTube Premium.
When YouTube detects an ad blocker, it sometimes displays a message enforcing ad viewing. This script counters that by employing the following strategy:
Detection:
It continuously monitors the YouTube page for any changes that indicate the presence of an enforcement message (triggered by ad-blocker detection). This is done using a web API called MutationObserver
, which can detect when specific elements are added to the webpage.
iFrame Replacement:
Upon detecting the enforcement message, the script dynamically creates an iframe
element configured to embed the currently viewed YouTube video. The iframe
uses a URL that includes the video ID (extracted from the current page's URL) and an autoplay parameter.
Autoplay Handling:
The script incorporates an autoplay feature, allowing users to automatically move to the next video after the current one ends. This is managed through a custom control within the iframe
and the browser's local storage, which remembers if the user has the feature enabled.
End of Video Detection: To facilitate autoplay, the script also monitors for the end of a video, waiting for the UI changes that signal this event. If autoplay is active, it then initiates the next video.
Please note that this approach is a workaround and relies on current YouTube's page structure and behavior, which may change, potentially breaking the script's functionality.
Before you begin, ensure you have met the following requirements:
To install the YouTube iFrame AdBlocker, follow these steps:
.user.js
file, then click 'Import'.Alternatively, you can create a new script in your userscript manager and copy-paste the code.
After installation, the script should work automatically when you navigate to YouTube, specifically when the "Ad blockers are not allowed on YouTube" message has been displayed. Videos should load in an embedded iFrame, preventing YouTube's anti-adblock system from detecting the adblocker.
Please note that this script won't remove ads shown by the video content creators themselves and is intended to work after YouTube's anti-adblock message has been encountered.
If you want to contact me, you can reach me on Discord as jordanro2.
This project uses the MIT License. See LICENSE for details.
This script is created for educational purposes and personal use only. Circumventing ad display can violate YouTube's terms of service. Please be aware of the potential consequences, including account suspension or legal action, before using the script. The author does not accept any responsibility for any repercussions that occur from using this script.
QingJ © 2025
镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址