YouTube 广告惩罚者 – 绕过反广告拦截
YouTube Ad Punisher – Auto-reloads YouTube pages when an ad plays

原始链接: https://github.com/antonpictures/youtube-punisher

YouTube Ad Punisher 是一个浏览器扩展,可检测 YouTube 广告并重新加载页面,通过时间戳保留播放位置。它通常在 1–2 次重新加载后清除广告;三次重新加载失败后,会短暂切换到辅助标签页,必要时重定向到无广告镜像。它通过 DOM 类、跳过按钮和覆盖层检测广告,捕获 currentTime,使用 &t=Xs 重新加载并恢复播放。它在本地记录广告主、时长、跳过文本、视频和时间戳,并支持 JSON/CSV 导出和弹窗查看器。功能包括直播支持、防止循环的冷却机制和最小权限。可通过 Chrome 未打包方式、Safari 变通方案或发布 zip 安装。它补充广告拦截器,捕获漏网之鱼并记录它们。每次重新加载都是对广告中断的被动抗议。

Hacker News 上的一篇帖子讨论了“YouTube Ad Punisher”,这是一种绕过 YouTube 反广告拦截措施的工具。评论者争论它是否必要:许多 Firefox 用户表示,uBlock Origin 加上 SponsorBlock 已经能消除或跳过大多数广告和赞助内容。其他人指出限制,特别是在 Chromebook 上,YouTube 可能无法与广告拦截器正常工作。一些人提到,拦截广告偶尔会导致播放质量下降或“中断”。建议的替代方案包括 uBlock Origin、SponsorBlock、移动端的 Morphe 和 Brave。一位评论者建议每次 YouTube 播放广告时,就向 PeerTube、yt-dlp 和 Invidious 等替代方案捐款。另一位评论者质疑 YouTube 大约每 60 秒播放一次广告的说法。总体上,该帖子关注广告拦截效果、平台限制以及对 YouTube 广告做法的可能回应。
相关文章

原文

Auto-reloads YouTube pages when an ad plays — preserving your playback position. Punish the ads.

License: MIT Chrome Extension Manifest V3


YouTube serves an ad roughly every 60 seconds. You can't watch one minute of content without being interrupted by a commercial. Traditional ad blockers get detected by YouTube's anti-adblock system ("Ad blockers are not allowed here"). Skip buttons take 5 seconds to appear. You sit there, hostage.

Reload the page. That's it. Two reloads and the ad is gone. Every time.

🎯 YouTube Ad Punisher automates this: the moment an ad appears, it captures your exact playback timestamp, reloads the page, and YouTube auto-seeks back to where you were. No ads. No waiting. No skip button hunting.

  • Auto escape: after 3 reloads, the extension automatically switches to a helper tab for 4 seconds (George's discovery, now automated), then switches back. No manual tab switching needed.

  • Ads keep coming after reload? Switch to another tab for a few seconds, then switch back. Chrome throttles background tabs, which lets the ad state settle — George discovered this works every time.

  • Incognito: see the Incognito section above.

Ad detected → Capture timestamp → Reload page → Auto-seek to timestamp → Resume
                    ↓ (if 3 reloads fail)
              Redirect to yout-ube.com (ad-free mirror, no looping)
  1. Reload (primary) — reloads the page 1-3 times. YouTube re-evaluates ad serving on each reload; after 1-2 cycles the ad slot is empty and the video plays clean. Timestamp is preserved via &t=Xs URL param + JS seek.

  2. yout-ube.com redirect (fallback) — if reloads don't clear the ad after 3 attempts, redirects to yout-ube.com (an ad-free YouTube mirror). The URL includes &loop=0 to prevent the infinite replay issue that the mirror has by default.

  3. Detect — watches for .ad-showing class, skip buttons, and ad overlays (every 500ms + MutationObserver)

  4. Capture — grabs video.currentTime and saves it to sessionStorage

  5. Reload — location.replace() with &t=Xs in the URL

  6. Restore — YouTube auto-seeks to the timestamp; playback resumes

  7. Cooldown — 3-second guard prevents reload loops

  • ✅ Zero ads — reloads until the ad is gone (usually 1-2 cycles)
  • ✅ Timestamp preserved — never lose your place in the video
  • ✅ Live streams — plain reload (no timestamp to preserve)
  • ✅ Ad history database — every ad logged with advertiser, duration, skip text, video, and timestamp
  • ✅ Export — JSON or CSV download of all collected ad data
  • ✅ Popup viewer — click the extension icon to see stats, top advertisers, and full history
  • ✅ No permissions abuse — only storage and tabs, only on YouTube domains

Option A — Chrome / Brave / Edge / Opera (Load unpacked)

  1. Clone the repo:
    git clone https://github.com/antonpictures/youtube-punisher.git
  2. Open chrome://extensions
  3. Enable Developer mode (top right)
  4. Click Load unpacked → select the youtube-punisher folder
  5. Done — activates on all YouTube pages automatically. ✅ Tested

Option B — Safari (experimental: AppleScript workaround)

Safari blocks ad-hoc signed extensions from auto-injecting into YouTube. As a workaround, use the JS overlay + AppleScript watcher (yt-ad-watch.sh):

  1. In Safari, enable: Safari → Settings → Advanced → Show Develop menu in menu bar
  2. In Safari (on a YouTube page), run ./yt-ad-watch.sh in Terminal
  3. When an ad appears, the watcher detects it via MutationObserver (event-driven in the page), reloads with &t=Xs, and the MutationObserver re-detects on the next page load

Note: This is best-effort. Chrome is fully reliable; Safari works but may need manual testing.

Option C — Download zip

  1. Download the latest release from Releases
  2. Unzip and follow Option A steps 2–5

Every ad YouTube serves you is recorded:

Field What it captures
Timestamp When the ad was detected
Advertiser Company name from the ad overlay
Video Title of the video you were watching
Video time Your playback position before reload
Ad duration Length of the ad
Skip text "Skip Ad" button text (if available)
Action Reloaded or skipped

Export as JSON or CSV from the popup. Data stays local — nothing is sent anywhere.

Why Reloads Work (and Why Nobody Thought of This)

YouTube's ad system serves ads as part of the page load. When you reload, YouTube re-evaluates whether to serve an ad based on your session state. After 1-2 reloads, the ad slot is typically empty and the video plays directly. This is a client-side, zero-cost workaround — no filter lists, no network blocking, no detection by YouTube's anti-adblock system.

If millions of users did this, each reload = a full page load = server request. YouTube would see a spike in page loads but a drop in ad impressions. It's not a DDoS (no amplification, no botnet), but it's a passive protest: every reload is a vote that says "I will not watch your ad." The ad revenue model breaks when reloads are cheaper than ad views.

"Every reload is a vote: I will not watch your ad." — George Anton, creator

Comparison with Other Tools

Tool How it works Reloads? Collects data?
uBlock Origin Blocks ad network requests No No
SponsorBlock Skips sponsored segments in videos No No
Enhancer for YouTube Auto-clicks "Skip Ad" button No No
🎯 YouTube Ad Punisher Detects ad → reloads → seeks to timestamp Yes Yes
Popup blockers Block window.open() popups No No

Best combo: uBlock Origin (blocks most ads) + 🎯 YouTube Ad Punisher (catches the ones that slip through and logs them) + SponsorBlock (skips sponsor reads). They don't conflict.

  • YouTube changes DOM class names periodically — if ads aren't detected, check the console for [YT-AdReloader] logs
  • Some ads (mid-roll on live streams) can't preserve position — plain reload
  • YouTube's "Premium" upsell interstitials may need a second reload cycle (handled by cooldown)
File Purpose
manifest.json Chrome extension manifest v3
content.js Ad detection + reload + timestamp restore + history tracking
popup.html / popup.js Ad history viewer with export
background.js Minimal service worker

MIT — do whatever you want with it.


Built with Alice (SIFTA) for George Anton.

"If millions installed this, YouTube would feel every reload." 🐜

联系我们 contact @ memedata.com