YouTube - Ad Skip

Skips and removes ads on YouTube automatically

  1. // ==UserScript==
  2. // @name YouTube - Ad Skip
  3. // @version 1.0
  4. // @description Skips and removes ads on YouTube automatically
  5. // @author Bobocato
  6. // @match https://www.youtube.com/*
  7. // @grant none
  8. // @namespace https://gf.qytechs.cn/users/167089
  9. // ==/UserScript==
  10.  
  11. const equalText1 = "Skip Ads";
  12. const equalText2 = "Skip Ad";
  13.  
  14. function addNewStyle(newStyle) {
  15. var styleElement = document.getElementById('styles_js');
  16. if (!styleElement) {
  17. styleElement = document.createElement('style');
  18. styleElement.type = 'text/css';
  19. styleElement.id = 'styles_js';
  20. document.getElementsByTagName('head')[0].appendChild(styleElement);
  21. }
  22. styleElement.appendChild(document.createTextNode(newStyle));
  23. }
  24.  
  25. function skipAd(){
  26. console.log("Tried to skip a ad");
  27. if(document.getElementsByClassName("ytp-ad-skip-button").length > 0){
  28. if(document.getElementsByClassName("ytp-ad-skip-button")[0].childNodes[0].textContent === equalText1 || document.getElementsByClassName("ytp-ad-skip-button")[0].childNodes[0].textContent === equalText2){
  29. document.getElementsByClassName("ytp-ad-skip-button")[0].click();
  30. } else {
  31. setTimeout(skipAd(), 1000);
  32. }
  33. }
  34. }
  35.  
  36. (function() {
  37. 'use strict';
  38. addNewStyle('.ytp-ad-overlay-slot {display:none !important;}');
  39. setInterval(function (){
  40. if(window.location.href.substring(0,30) == "https://www.youtube.com/watch?"){
  41. skipAd();
  42. }
  43. }, 2500);
  44. })();

QingJ © 2025

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