Ad skipper yt

Play Youtube ads at 5x speed, and skip after 6 seconds undetected.

  1. // ==UserScript==
  2. // @name Ad skipper yt
  3. // @license MIT
  4. // @namespace http://tampermonkey.net/
  5. // @version 0.1
  6. // @description Play Youtube ads at 5x speed, and skip after 6 seconds undetected.
  7. // @author TTT
  8. // @match https://www.youtube.com/*
  9. // @grant none
  10. // ==/UserScript==
  11. const targetNode = document.body;
  12. const config = { attributes: false, childList: true, subtree: true };
  13. const callback = function(mutationsList, observer) {
  14. for (const mutation of mutationsList) {
  15. if (mutation.type === 'childList') {
  16. document.querySelectorAll('.ytp-ad-text').forEach(adText => {
  17. var player = document.querySelector('.video-stream.html5-main-video');
  18. if (player) {
  19. player.playbackRate = 5;
  20. if (player.currentTime > 29) {
  21. if (document.contains(document.getElementsByClassName("ytp-preview-ad")[0])) {
  22. document.getElementsByClassName("html5-video-container")[0].children[0].currentTime = 250;
  23. }
  24. if (document.contains(document.getElementsByClassName('ytp-skip-ad-button__text')[0])) {
  25. document.getElementsByClassName('ytp-skip-ad-button__text')[0].click();
  26. }
  27. }
  28. }
  29. });
  30. }
  31. }
  32. };
  33. const observer = new MutationObserver(callback);
  34. observer.observe(targetNode, config);