🎉 欢迎访问GreasyFork.Org 镜像站!本镜像站由公众号【爱吃馍】搭建,用于分享脚本。联系邮箱📮

Greasy fork 爱吃馍镜像

Greasy Fork is available in English.

📂 缓存分发状态(共享加速已生效)
🕒 页面同步时间:2025/12/27 08:15:14
🔄 下次更新时间:2025/12/27 09:15:14
手动刷新缓存

editor html

try to take over the world!

Bu betiği kurabilmeniz için Tampermonkey, Greasemonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

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

Bu betiği kurabilmeniz için Tampermonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği kurabilmeniz için Tampermonkey ya da Userscripts gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği indirebilmeniz için ayrıca Tampermonkey gibi bir eklenti kurmanız gerekmektedir.

Bu komut dosyasını yüklemek için bir kullanıcı komut dosyası yöneticisi uzantısı yüklemeniz gerekecek.

(Zaten bir kullanıcı komut dosyası yöneticim var, kurmama izin verin!)

🚀 安装遇到问题?关注公众号获取帮助

公众号二维码

扫码关注【爱吃馍】

回复【脚本】获取最新教程和防失联地址

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(Zateb bir user-style yöneticim var, yükleyeyim!)

🚀 安装遇到问题?关注公众号获取帮助

公众号二维码

扫码关注【爱吃馍】

回复【脚本】获取最新教程和防失联地址

// ==UserScript==
// @name         editor html
// @namespace    http://tampermonkey.net/
// @version      1.1
// @description  try to take over the world!
// @author       Enoch
// @match        https://www.oppo.com/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=zhinan.tech
// @grant        none
// ==/UserScript==

(function() {
    'use strict';
    const textNodes = [];
    // 遍历 DOM 树,寻找只包含文本的节点
    function findTextNodes(node) {
        if (node.nodeType === Node.TEXT_NODE && node.textContent.trim().length > 0) {
            textNodes.push(node);
        } else {
            for (const childNode of node.childNodes) {
                findTextNodes(childNode);
            }
        }
    }
    // 查找只包含文本的节点
    findTextNodes(document.body);
    // 给满足条件的文本节点的父级元素添加背景颜色
    for (const textNode of textNodes) {
        const parentElement = textNode.parentElement;
        const {width,height} = parentElement.getBoundingClientRect();
        parentElement.style.backgroundColor = '#7ea864';
        parentElement.style.width = `${width}px`;
        parentElement.style.height = `${height}px`;

    }

    // 创建一个开关元素
    const switchElement = document.createElement('input');
    switchElement.type = 'checkbox';
    Object.assign(switchElement.style, {
        marginRight: '5px'
    });

    const labelElement = document.createElement('label');
    labelElement.textContent = '开启编辑模式';
    Object.assign(labelElement.style, {
        cursor: 'pointer',
        contentEditable: 'false'
    });

    const topBar = document.createElement('div');
    Object.assign(topBar.style, {
        position: 'fixed',
        top: '0',
        right: '0',
        backgroundColor: '#f7f7f7',
        padding: '10px',
        zIndex: '100'
    });
    labelElement.appendChild(switchElement);
    topBar.appendChild(labelElement);
    document.body.appendChild(topBar);

    // 处理开关按钮的点击事件
    switchElement.addEventListener('change', function() {
        const bodyEditable = switchElement.checked;
        if(bodyEditable){
          labelElement.textContent='关闭编辑模式';
        }else{
          labelElement.textContent='开启编辑模式';
        }
        document.body.contentEditable = bodyEditable;
    });
})();