图片样式屏蔽器

隐藏所有图片元素,可以用来看网页小说和视频,脚本菜单启用脚本

目前為 2024-02-19 提交的版本,檢視 最新版本

// ==UserScript==
// @name         图片样式屏蔽器
// @version      1.2
// @description  隐藏所有图片元素,可以用来看网页小说和视频,脚本菜单启用脚本
// @author       ChatGPT
// @match        *://*/*
// @grant        GM_registerMenuCommand
// @grant        GM_setValue
// @grant        GM_getValue
// @run-at       document-end
// @namespace https://gf.qytechs.cn/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,[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);
        }
    }
})();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址