Greasy Fork is available in English.

YouTube 広告を自動スキップ

YouTube 広告をほぼ瞬時に自動的にスキップします。非常に軽量で効率的です。

このスクリプトの質問や評価の投稿はこちら通報はこちらへお寄せください。
  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:zh-TW 自動跳過 YouTube 廣告
  6. // @name:ja YouTube 広告を自動スキップ
  7. // @name:ko YouTube 광고 자동 건너뛰기
  8. // @name:es Saltar Automáticamente Anuncios De YouTube
  9. // @name:ru Автоматический Пропуск Рекламы На YouTube
  10. // @name:id Lewati Otomatis Iklan YouTube
  11. // @name:hi YouTube विज्ञापन स्वचालित रूप से छोड़ें
  12. // @name:th ข้ามโฆษณา YouTube อัตโนมัติ
  13. // @namespace https://github.com/tientq64/userscripts
  14. // @version 4.1.2
  15. // @description Automatically skip YouTube ads almost instantly. Very lightweight and efficient.
  16. // @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ả.
  17. // @description:zh-CN 几乎立即自动跳过 YouTube 广告。非常轻量且高效。
  18. // @description:zh-TW 幾乎立即自動跳過 YouTube 廣告。非常輕巧且高效。
  19. // @description:ja YouTube 広告をほぼ瞬時に自動的にスキップします。非常に軽量で効率的です。
  20. // @description:ko YouTube 광고를 거의 즉시 자동으로 건너뜁니다. 매우 가볍고 효율적입니다.
  21. // @description:es Omita automáticamente los anuncios de YouTube casi al instante. Muy ligero y eficiente.
  22. // @description:ru Автоматически пропускайте рекламу на YouTube практически мгновенно. Очень легкий и эффективный.
  23. // @description:id Lewati iklan YouTube secara otomatis hampir seketika. Sangat ringan dan efisien.
  24. // @description:hi YouTube विज्ञापनों को लगभग तुरंत ही स्वचालित रूप से छोड़ दें। बहुत हल्का और कुशल।
  25. // @description:th ข้ามโฆษณา YouTube โดยอัตโนมัติเกือบจะในทันที น้ำหนักเบามากและมีประสิทธิภาพ
  26. // @author tientq64
  27. // @icon https://cdn-icons-png.flaticon.com/64/2504/2504965.png
  28. // @match https://www.youtube.com
  29. // @match https://www.youtube.com/*
  30. // @grant none
  31. // @license MIT
  32. // @compatible firefox
  33. // @compatible chrome
  34. // @compatible opera
  35. // @compatible safari
  36. // @compatible edge
  37. // @noframes
  38. // @homepage https://github.com/tientq64/userscripts/tree/main/scripts/auto-skip-youtube-ads
  39. // ==/UserScript==
  40.  
  41. function skipAd() {
  42. setTimeout(skipAd, document.hidden ? 1000 : 500)
  43. const video = getVideo()
  44. if (!video) return
  45. const adPlayer = document.querySelector('#movie_player.ad-showing')
  46. if (adPlayer) {
  47. const skipButton = document.querySelector(`
  48. .ytp-skip-ad-button,
  49. .ytp-ad-skip-button,
  50. .ytp-ad-skip-button-modern
  51. `)
  52. if (skipButton) {
  53. skipButton.click()
  54. log('Skip button clicked')
  55. } else {
  56. video.currentTime = 9999
  57. log('Unskippable ad video have been skipped')
  58. }
  59. }
  60. const adBlockerWarningDialog = document.querySelector('tp-yt-paper-dialog:has(#dismiss-button)')
  61. if (adBlockerWarningDialog) {
  62. adBlockerWarningDialog.remove()
  63. log('Removed the ad blocker warning dialog')
  64. fixVideoPausedAtFirst(video)
  65. }
  66. if (oldVideoSrc !== video.src) {
  67. oldVideoSrc = video.src
  68. fixVideoPausedAtFirst(video)
  69. }
  70. }
  71. function getVideo() {
  72. return document.querySelector('#movie_player video.html5-main-video')
  73. }
  74. function fixVideoPausedAtFirst(video) {
  75. const videoSrc = video.src
  76. setTimeout(() => {
  77. if (video.src === videoSrc) {
  78. if (video.paused) {
  79. video.play()
  80. log('Fixed video being paused due to using an ad blocker')
  81. }
  82. }
  83. }, 2000)
  84. }
  85. function log(text) {
  86. const date = new Date()
  87. console.log(
  88. `\x1B[41;97m Auto Skip YouTube Ads \x1B[m\x1B[47;30m ${date.toLocaleTimeString()} \x1B[m\n${text}`
  89. )
  90. }
  91. let oldVideoSrc = ''
  92. skipAd()
  93. const style = document.createElement('style')
  94. style.textContent = `
  95. #player-ads,
  96. #masthead-ad,
  97. #panels:has(ytd-ads-engagement-panel-content-renderer),
  98. ytd-ad-slot-renderer,
  99. ytd-rich-item-renderer:has(.ytd-ad-slot-renderer),
  100. ytd-reel-video-renderer:has(.ytd-ad-slot-renderer),
  101. tp-yt-paper-dialog:has(#dismiss-button) {
  102. display: none !important;
  103. }`
  104. document.head.appendChild(style)
  105. log(`Initialized`)