Block Twitch Prime Popup

Block a specific iframe from loading on Twitch.tv

  1. // ==UserScript==
  2. // @name Block Twitch Prime Popup
  3. // @namespace https://greasyfork.org/en/users/1200587-trilla-g
  4. // @version 1.0
  5. // @description Block a specific iframe from loading on Twitch.tv
  6. // @author Trilla_G
  7. // @match *://*.twitch.tv/*
  8. // @grant none
  9. // @license MIT
  10. // ==/UserScript==
  11.  
  12. (function() {
  13. 'use strict';
  14.  
  15. // Function to remove the iframe with the specified src
  16. function removeIframe() {
  17. const iframes = document.querySelectorAll('iframe[src*="supervisor.ext-twitch.tv/supervisor/v1/index.html"]');
  18. iframes.forEach(iframe => {
  19. iframe.parentNode.removeChild(iframe);
  20. console.log('Blocked iframe: supervisor.ext-twitch.tv/supervisor/v1/index.html');
  21. });
  22. }
  23.  
  24. // Run the function immediately in case the iframe is already in the DOM
  25. removeIframe();
  26.  
  27. // Use a MutationObserver to detect and remove the iframe if it gets added dynamically
  28. const observer = new MutationObserver(mutations => {
  29. mutations.forEach(mutation => {
  30. mutation.addedNodes.forEach(node => {
  31. if (node.tagName === 'IFRAME' && node.src.includes('supervisor.ext-twitch.tv/supervisor/v1/index.html')) {
  32. node.parentNode.removeChild(node);
  33. console.log('Blocked dynamically added iframe: supervisor.ext-twitch.tv/supervisor/v1/index.html');
  34. }
  35. });
  36. });
  37. });
  38.  
  39. // Start observing the document for added nodes
  40. observer.observe(document.body, {
  41. childList: true,
  42. subtree: true
  43. });
  44. })();