twitchAdSkip

Bezos is already too rich;i didn't make this

  1. // ==UserScript==
  2. // @name twitchAdSkip
  3. // @namespace https://www.twitch.tv/
  4. // @version 1.0
  5. // @description Bezos is already too rich;i didn't make this
  6. // @author SimpleHacker
  7. // @match https://www.twitch.tv/*
  8. // @grant none
  9. // ==/UserScript==
  10.  
  11. (function() {
  12. 'use strict';
  13.  
  14. window.onload = function() {
  15.  
  16. const dblclick = new MouseEvent('dblclick', {
  17. bubbles: true,
  18. cancelable: true,
  19. view: window
  20. });
  21.  
  22. let options = {
  23. childList: true,
  24. subtree: true
  25. };
  26.  
  27. const observer = new MutationObserver(function(mutations) {
  28. mutations.forEach((mutation) => {
  29. mutation.addedNodes.forEach((node) => {
  30. let ad = node.querySelector('[data-test-selector="ad-banner-default-text"]');
  31. if (ad) {
  32. let resetButton = document.querySelector('[data-a-target="ffz-player-reset-button"]');
  33.  
  34. if (resetButton) {
  35. resetButton.dispatchEvent(dblclick);
  36. } else {
  37. window.location.reload();
  38. }
  39. }
  40. });
  41. });
  42. });
  43.  
  44. const target = document.querySelector('[data-a-target="video-player"]');
  45.  
  46. observer.observe(target, options);
  47. }
  48.  
  49. })();