Force Editable Mode on Any Google Doc (Aggressive)

Force any Google Docs page into editable mode, regardless of permissions

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         Force Editable Mode on Any Google Doc (Aggressive)
// @namespace    http://tampermonkey.net/
// @version      0.5
// @description  Force any Google Docs page into editable mode, regardless of permissions
// @author       You
// @match        https://docs.google.com/document/d/1Lv5lWrvXyUq_o26xyn-pNwGcVKhs8aQYbxdzKbBnk_A/edit?tab=t.0
// @grant        none
// @run-at       document-end
// @license      MIT
// ==/UserScript==

(function() {
    'use strict';

    // Function to enable contentEditable on Google Docs document
    function forceEditableMode() {
        // Check for the editor container and enable editing if available
        const editableDiv = document.querySelector('.kix-appview-editor');
        if (editableDiv) {
            editableDiv.contentEditable = true;
            editableDiv.style.pointerEvents = 'auto';

            // Force other elements to be editable
            const editableContent = document.querySelector('.kix-document');
            if (editableContent) {
                editableContent.setAttribute('contenteditable', 'true');
            }

            console.log('Google Docs is now editable!');
        }
    }

    // Aggressively remove any overlays or viewer blocks
    function removeViewerOverlay() {
        const viewerOverlay = document.querySelector('.kix-viewer-overlay');
        if (viewerOverlay) {
            viewerOverlay.remove();
            console.log('Removed viewer overlay.');
        }

        const disallowedMessage = document.querySelector('.docs-viewer-disallowed-message');
        if (disallowedMessage) {
            disallowedMessage.style.display = 'none';
            console.log('Removed disallowed message.');
        }
    }

    // Mutation Observer to monitor page changes
    const observer = new MutationObserver(function() {
        // Force the document to become editable every time something changes
        forceEditableMode();
        removeViewerOverlay();
    });

    // Start observing document body for changes
    observer.observe(document.body, {
        childList: true,
        subtree: true,
    });

    // Initial attempt to force editable mode
    forceEditableMode();
    removeViewerOverlay();
})();