🏠 Home 

Greasy Fork is available in English.

屏蔽网页上的图片

屏蔽网页上所有的图片,方便摸鱼


安装此脚本?
  1. // ==UserScript==
  2. // @name 屏蔽网页上的图片
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.3
  5. // @description 屏蔽网页上所有的图片,方便摸鱼
  6. // @match *://*/*
  7. // @grant none
  8. // @license MIT
  9. // ==/UserScript==
  10. (function() {
  11. 'use strict';
  12. // 创建一个 MutationObserver 实例
  13. const observer = new MutationObserver(function(mutations) {
  14. mutations.forEach(function(mutation) {
  15. // 获取到所有的 img 标签
  16. const images = mutation.target.getElementsByTagName('img');
  17. // 将所有的 img 标签隐藏
  18. for (let i = 0; i < images.length; i++) {
  19. images[i].style.display = 'none';
  20. }
  21. });
  22. });
  23. // 开始监听 body 节点,用于处理 js 新加载出来的图片
  24. observer.observe(document.body, { childList: true, subtree: true });
  25. })();