自动跳过 YouTube 广告

几乎立即自动跳过 YouTube 广告。非常轻量且高效。

目前为 2024-06-30 提交的版本。查看 最新版本

  1. // ==UserScript==
  2. // @name Auto Skip YouTube Ads
  3. // @name:vi Tự Động Bỏ Qua Quảng Cáo YouTube
  4. // @name:zh-CN 自动跳过 YouTube 广告
  5. // @name:es Saltar automáticamente anuncios de YouTube
  6. // @name:ru Автоматический пропуск рекламы на YouTube
  7. // @name:id Lewati Otomatis Iklan YouTube
  8. // @name:hi YouTube विज्ञापन स्वचालित रूप से छोड़ें
  9. // @namespace https://github.com/tientq64/userscripts
  10. // @version 3.0.3
  11. // @description Auto skip YouTube ads almost instantly. Very lightweight and efficient.
  12. // @description:vi Tự động bỏ qua quảng cáo YouTube gần như ngay lập tức. Rất nhẹ và hiệu quả.
  13. // @description:zh-CN 几乎立即自动跳过 YouTube 广告。非常轻量且高效。
  14. // @description:es Salta automáticamente los anuncios de YouTube casi al instante. Muy ligero y eficiente.
  15. // @description:ru Автоматический пропуск рекламы на YouTube почти мгновенно. Очень легкий и эффективный.
  16. // @description:id Lewati otomatis iklan YouTube hampir seketika. Sangat ringan dan efisien.
  17. // @description:hi YouTube विज्ञापनों को लगभग तुरंत ही ऑटो स्किप कर दें। बहुत हल्का और कुशल।
  18. // @author https://github.com/tientq64
  19. // @icon https://cdn-icons-png.flaticon.com/64/9639/9639954.png
  20. // @match https://www.youtube.com
  21. // @match https://www.youtube.com/*
  22. // @grant none
  23. // @license MIT
  24. // @noframes
  25. // @homepage https://github.com/tientq64/userscripts/tree/main/scripts/auto-skip-youtube-ads
  26. // ==/UserScript==
  27.  
  28. function skipAd() {
  29. const adPlayer = document.querySelector('.html5-video-player.ad-showing')
  30. if (adPlayer) {
  31. const skipButton = document.querySelector(
  32. '.ytp-skip-ad-button, .ytp-ad-skip-button, .ytp-ad-skip-button-modern'
  33. )
  34. if (skipButton) {
  35. skipButton.click()
  36. } else {
  37. const video = adPlayer.querySelector('video')
  38. video.currentTime = video.duration
  39. }
  40. }
  41. const dismissButton = document.querySelector('tp-yt-paper-dialog #dismiss-button')
  42. if (dismissButton) {
  43. dismissButton.click()
  44. const dialog = dismissButton.closest('tp-yt-paper-dialog')
  45. dialog.remove()
  46. }
  47. }
  48. setInterval(skipAd, 1000)
  49. skipAd()
  50. const style = document.createElement('style')
  51. style.textContent = `
  52. #player-ads,
  53. #masthead-ad,
  54. #panels:has(ytd-ads-engagement-panel-content-renderer),
  55. ytd-rich-item-renderer:has(.ytd-ad-slot-renderer),
  56. ytd-reel-video-renderer:has(.ytd-ad-slot-renderer),
  57. tp-yt-paper-dialog:has(#dismiss-button) {
  58. display: none !important;
  59. }`
  60. document.head.appendChild(style)

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址