YouTube - Ad Skip

Skips and removes ads on YouTube automatically

目前為 2018-04-03 提交的版本,檢視 最新版本

  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 equalText = "Überspringen";
  12.  
  13. function addNewStyle(newStyle) {
  14. var styleElement = document.getElementById('styles_js');
  15. if (!styleElement) {
  16. styleElement = document.createElement('style');
  17. styleElement.type = 'text/css';
  18. styleElement.id = 'styles_js';
  19. document.getElementsByTagName('head')[0].appendChild(styleElement);
  20. }
  21. styleElement.appendChild(document.createTextNode(newStyle));
  22. }
  23.  
  24. function skipAd(){
  25. console.log("Tried to skip a ad");
  26. if(document.getElementsByClassName("videoAdUiSkipButton").length > 0){
  27. if(document.getElementsByClassName("videoAdUiSkipButton")[0].childNodes[0].textContent === equalText){
  28. document.getElementsByClassName("videoAdUiSkipButton")[0].click();
  29. } else {
  30. setTimeout(skipAd(), 1000);
  31. }
  32. }
  33. }
  34.  
  35. (function() {
  36. 'use strict';
  37. addNewStyle('.controls {display:none !important;}');
  38. setInterval(function (){
  39. if(window.location.href.substring(0,30) == "https://www.youtube.com/watch?"){
  40. skipAd();
  41. }
  42. }, 2500);
  43. })();

QingJ © 2025

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