YoutubeSkipAdsAuto

Youtube skip ads!

  1. // ==UserScript==
  2. // @name YoutubeSkipAdsAuto
  3. // @namespace M.Sadok
  4. // @version 0.1
  5. // @description Youtube skip ads!
  6. // @author You
  7. // @match https://www.youtube.com/*
  8. // @grant none
  9. // @require http://code.jquery.com/jquery-latest.js
  10. // ==/UserScript==
  11.  
  12. var currentUrl="";
  13. jQuery(function ($){
  14. currentUrl = window.location.href;
  15. setTimeout(skipAd, 4000);
  16. setInterval(checkPageChange,2000);
  17. });
  18.  
  19. function checkPageChange(){
  20. var oldUrl = currentUrl;
  21. var newUrl=window.location.href;
  22. //check if the url is changed
  23. if( newUrl !== oldUrl ){
  24. setTimeout(skipAd, 4000);
  25. setCurrentUrl(newUrl);
  26. }
  27. }
  28. function skipAd(){
  29. if ($(".videoAdUiSkipContainer ").css("display") === "none") {
  30. //--- Not found skip button"
  31. setTimeout(skipAd, 1000);
  32. }else{
  33. //"--- Skip button found :) -> click it");
  34. $('.videoAdUiSkipButton').click();
  35. }
  36. }
  37. function setCurrentUrl(url){
  38. currentUrl=url;
  39. }