Auto Skip YouTube Ads

Auto skip ads on YouTube. Very lightweight and efficient.

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

  1. // ==UserScript==
  2. // @name Auto Skip YouTube Ads
  3. // @name:vi Tự Động Bỏ Qua Quảng Cáo YouTube
  4. // @namespace https://github.com/tientq64/userscripts
  5. // @version 2.0.1
  6. // @description Auto skip ads on YouTube. Very lightweight and efficient.
  7. // @description:vi Tự động bỏ qua quảng cáo trên YouTube. Rất nhẹ và hiệu quả.
  8. // @author https://github.com/tientq64
  9. // @icon https://cdn-icons-png.flaticon.com/64/9639/9639954.png
  10. // @match https://www.youtube.com/*
  11. // @grant none
  12. // @license MIT
  13. // @noframes
  14. // @homepage https://github.com/tientq64/userscripts/tree/main/scripts/auto-skip-youtube-ads
  15. // ==/UserScript==
  16.  
  17. function skipAd() {
  18. const hasAd = player.classList.contains('ad-showing')
  19. if (!hasAd) return
  20. const skipButton = document.querySelector('.ytp-skip-ad-button')
  21. if (skipButton) {
  22. skipButton.click()
  23. return
  24. }
  25. const video = player.querySelector('video')
  26. video.currentTime = video.duration
  27. }
  28. const player = document.querySelector('.html5-video-player')
  29. const observer = new MutationObserver(skipAd)
  30. observer.observe(player, { attributeFilter: ['class'] })
  31. skipAd()
  32. const style = document.createElement('style')
  33. style.textContent = `
  34. #player-ads {
  35. display: none !important;
  36. }
  37. `
  38. document.head.appendChild(style)

QingJ © 2025

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