// ==UserScript== // @name 图片样式屏蔽器 // @version 1.2 // @description 隐藏所有图片元素,可以用来看网页小说和视频,脚本菜单启用脚本 // @author ChatGPT // @match *://*/* // @grant GM_registerMenuCommand // @grant GM_setValue // @grant GM_getValue // @run-at document-end // @namespace https://greasyfork.org/users/452911 // @downloadURL none // ==/UserScript== (function() { 'use strict'; // 添加设置菜单 GM_registerMenuCommand("启用图片样式屏蔽器", ()=>{ const currentHostname = window.location.hostname; GM_setValue(`use_image_style_blocker_${currentHostname}`, true); applyImageStyleBlocker(); }); GM_registerMenuCommand("禁用图片样式屏蔽器", ()=>{ const currentHostname = window.location.hostname; GM_setValue(`use_image_style_blocker_${currentHostname}`, false); removeImageStyleBlocker(); }); // 获取设置 const currentHostname = window.location.hostname; const useImageStyleBlocker = GM_getValue(`use_image_style_blocker_${currentHostname}`, false); // 根据设置应用或移除图片样式屏蔽 if (useImageStyleBlocker) { applyImageStyleBlocker(); } function applyImageStyleBlocker() { let style = document.createElement('style'); style.innerHTML = `img,[style*='height:'][style*='px'] {display: none !important;visibility: hidden; opacity: 0; z-index: -999; width: 0; height: 0; pointer-events: none; position: absolute; left: -9999px; top: -9999px;}`; document.head.appendChild(style); } function removeImageStyleBlocker() { let style = document.querySelector('style'); if (style) { style.parentNode.removeChild(style); } } })();