Remove CNFans Modal

Automatically removes the "keywords-modal" on cnfans.com pages

  1. // ==UserScript==
  2. // @name Remove CNFans Modal
  3. // @namespace http://tampermonkey.net/
  4. // @version 1.0
  5. // @description Automatically removes the "keywords-modal" on cnfans.com pages
  6. // @author Your Name
  7. // @match *://*cnfans.com/*
  8. // @grant none
  9. // ==/UserScript==
  10.  
  11. (function() {
  12. 'use strict';
  13.  
  14. // Function to remove the modal element
  15. function removeModal() {
  16. var modal = document.getElementById('keywords-modal');
  17. if (modal) {
  18. modal.remove();
  19. console.log('CNFans modal removed');
  20. }
  21. }
  22.  
  23. // Run the function on page load
  24. window.addEventListener('load', removeModal);
  25.  
  26. // Optional: If the modal is loaded dynamically, use MutationObserver to catch it
  27. var observer = new MutationObserver(function(mutations) {
  28. mutations.forEach(function(mutation) {
  29. if (mutation.addedNodes.length > 0) {
  30. removeModal();
  31. }
  32. });
  33. });
  34.  
  35. // Start observing the document for added nodes
  36. observer.observe(document.body, { childList: true, subtree: true });
  37. })();