一键无图模式

为页面右下角添加一个按钮,点击后切换无图模式,再次点击切回。

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         一键无图模式
// @namespace    http://tampermonkey.net/
// @version      1.0
// @description  为页面右下角添加一个按钮,点击后切换无图模式,再次点击切回。
// @author       yjy
// @match        http://*/*
// @match        https://*/*
// @grant        none
// @license      CC
// ==/UserScript==

(function() {
    'use strict';

    // Create a button to toggle visibility
    const toggleButton = document.createElement('button');
    toggleButton.innerText = '无图';
    toggleButton.style.fontSize = '12px';
    toggleButton.style.position = 'fixed';
    toggleButton.style.bottom = '20px';
    toggleButton.style.right = '40px';
    toggleButton.style.zIndex = '9999';
    document.body.appendChild(toggleButton);


    var noImageMode = false;

    // Function to toggle image and video visibility
    function toggleNoImageMode() {
        noImageMode = !noImageMode;
        var displayValue = noImageMode ? 'none' : '';

        document.querySelectorAll('img, video').forEach(function(element) {
            element.style.display = displayValue;
        });
    }

    // Add click event listener to the button
    toggleButton.addEventListener('click', toggleNoImageMode);
})();