Toggle Red Outline for All Elements

Adds a 1px red outline to all elements on the page with a keyboard shortcut to toggle it on/off.

当前为 2025-01-08 提交的版本,查看 最新版本

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         Toggle Red Outline for All Elements
// @namespace    http://tampermonkey.net/
// @version      1.1
// @description  Adds a 1px red outline to all elements on the page with a keyboard shortcut to toggle it on/off.
// @author       Drewby123
// @match        *://*/*
// @grant        none
// @license      MIT
// ==/UserScript==

(function () {
    'use strict';

    let isOutlineEnabled = false; // Track the state of the outline
    const style = document.createElement('style');
    style.id = 'red-outline-style';
    style.innerHTML = `
        * {
            outline: 1px solid red !important;
        }
    `;

    // Function to toggle the outline
    const toggleOutline = () => {
        isOutlineEnabled = !isOutlineEnabled;
        if (isOutlineEnabled) {
            document.head.appendChild(style);
        } else {
            const existingStyle = document.getElementById('red-outline-style');
            if (existingStyle) {
                existingStyle.remove();
            }
        }
    };

    // Add a keyboard shortcut (Ctrl+Shift+O)
    document.addEventListener('keydown', (event) => {
        if (event.ctrlKey && event.key === 'i') {
            toggleOutline();
        }
    });
})();