智云学堂插件

自动解除 textarea 上的复制、粘贴、拖拽和文本选择限制

目前为 2024-12-20 提交的版本,查看 最新版本

// ==UserScript==
// @name         智云学堂插件
// @namespace    http://tampermonkey.net/
// @version      0.0.2
// @description  自动解除 textarea 上的复制、粘贴、拖拽和文本选择限制
// @author       You
// @match        https://www.e100soft.com/aikc/kcxxmain.asp
// @icon         https://www.google.com/s2/favicons?sz=64&domain=e100soft.com
// @grant        none
// @license      MIT
// @run-at       document-idle
// ==/UserScript==

(function() {
    'use strict';

    function removeEventRestrictions() {
        const testID = document.getElementById('testNr');
        if (testID) {
            const newTestID = testID.cloneNode(true);
            testID.parentNode.replaceChild(newTestID, testID);
            console.log('已成功解除对 textarea 的所有限制');

            // 添加监听内容变化的功能
            addContentChangeListener(newTestID);

            observer.disconnect();
        }
    }

    // 新增:监听 textarea 内容变化并更新 time9
    function addContentChangeListener(textarea) {
        textarea.addEventListener('input', function() {
            const textLength = textarea.value.length;
            window.time9 = textLength;
            console.log(`time9 已更新为: ${window.time9}`);
        });
    }

    const observer = new MutationObserver((mutations, obs) => {
        removeEventRestrictions();
    });

    observer.observe(document.body, { childList: true, subtree: true });

    removeEventRestrictions();

    console.log('脚本运行中...');

})();