Greasy Fork

来自缓存

Greasy Fork is available in English.

网页内容编辑开关(可隐藏)

在右下角添加一个按钮,点击可切换网页编辑模式,关闭时按钮可隐藏并通过点击热区重新显示

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         网页内容编辑开关(可隐藏)
// @namespace    https://t.me/Flymirai
// @version      2025-11-21
// @license      MIT
// @description  在右下角添加一个按钮,点击可切换网页编辑模式,关闭时按钮可隐藏并通过点击热区重新显示
// @author       TG@Flymirai
// @match        *://*/*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    // 创建按钮
    const btn = document.createElement('button');
    btn.innerText = '编辑模式: 关';
    btn.style.position = 'fixed';
    btn.style.bottom = '20px';
    btn.style.right = '20px';
    btn.style.zIndex = '9999';
    btn.style.padding = '8px 12px';
    btn.style.backgroundColor = '#0078d7';
    btn.style.color = '#fff';
    btn.style.border = 'none';
    btn.style.borderRadius = '5px';
    btn.style.cursor = 'pointer';
    btn.style.fontSize = '14px';
    btn.style.boxShadow = '0 2px 6px rgba(0,0,0,0.2)';
    document.body.appendChild(btn);

    // 创建热区(透明点击区域)
    const hotspot = document.createElement('div');
    hotspot.style.position = 'fixed';
    hotspot.style.bottom = '20px';
    hotspot.style.right = '20px';
    hotspot.style.width = '80px';
    hotspot.style.height = '40px';
    hotspot.style.zIndex = '9998';
    hotspot.style.cursor = 'pointer';
    hotspot.style.backgroundColor = 'transparent';
    document.body.appendChild(hotspot);

    // 初始状态
    let editing = false;

    // 点击按钮切换编辑模式
    btn.addEventListener('click', () => {
        editing = !editing;
        document.designMode = editing ? 'on' : 'off';
        btn.innerText = `编辑模式: ${editing ? '开' : '关'}`;
        btn.style.backgroundColor = editing ? '#28a745' : '#0078d7';

        // 如果关闭编辑模式 → 隐藏按钮
        if (!editing) {
            btn.style.display = 'none';
        }
    });

    // 点击热区重新显示按钮
    hotspot.addEventListener('click', () => {
        if (btn.style.display === 'none') {
            btn.style.display = 'block';
        }
    });
})();