Greasy Fork is available in English.
隐藏所有图片元素,可以用来看网页小说和视频,脚本菜单启用脚本
当前为
// ==UserScript==
// @name 图片样式屏蔽器
// @version 1.0
// @description 隐藏所有图片元素,可以用来看网页小说和视频,脚本菜单启用脚本
// @author ChatGPT
// @match *://*/*
// @grant GM_registerMenuCommand
// @grant GM_setValue
// @grant GM_getValue
// @run-at document-end
// @namespace http://greasyfork.icu/users/452911
// ==/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 {display: none !important;}`;
document.head.appendChild(style);
}
function removeImageStyleBlocker() {
let style = document.querySelector('style');
if (style) {
style.parentNode.removeChild(style);
}
}
})();