Hide Elements

Hide specific elements on a webpage

当前为 2024-02-22 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Hide Elements
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.1
  5. // @description Hide specific elements on a webpage
  6. // @author Mike
  7. // @match *://*/*
  8. // @grant none
  9. // ==/UserScript==
  10.  
  11. (function() {
  12. 'use strict';
  13.  
  14. // Function to hide elements
  15. function hideElements() {
  16. // Define the CSS selectors for the elements you want to hide
  17. var selectors = [
  18. // add DOM elements here.
  19. ''
  20. ];
  21.  
  22. // Loop through the selectors
  23. selectors.forEach(function(selector) {
  24. // Find the element
  25. var element = document.querySelector(selector);
  26.  
  27. // If the element exists, hide it
  28. if (element) {
  29. element.style.display = 'none';
  30. }
  31. });
  32. }
  33. // Call hideElements function when the DOM content is loaded or modified
  34. document.addEventListener('DOMContentLoaded', hideElements);
  35. document.addEventListener('DOMNodeInserted', hideElements);
  36. })();