Google Docs Viewer to Editable Mode

Allow editing in Google Docs viewer mode

当前为 2025-02-17 提交的版本,查看 最新版本

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         Google Docs Viewer to Editable Mode
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  Allow editing in Google Docs viewer mode
// @author       You
// @match        https://docs.google.com/document/d/*/view*
// @grant        none
// @license      MIT
// ==/UserScript==

(function() {
    'use strict';

    // Wait for the document content to load
    function waitForDocument() {
        const editableDiv = document.querySelector('.kix-appview-editor'); // The editable div class in Google Docs.
        if (editableDiv) {
            enableEditing();
        } else {
            setTimeout(waitForDocument, 1000);
        }
    }

    // Convert the document to editable mode by enabling DOM manipulation
    function enableEditing() {
        // Remove the 'view-only' overlays and restrictions
        const viewerOverlay = document.querySelector('.kix-viewer-overlay');
        if (viewerOverlay) {
            viewerOverlay.style.display = 'none';
        }

        // Force editable mode on the document body or specific areas
        const body = document.querySelector('.kix-appview-editor');
        if (body) {
            body.contentEditable = true;
            body.setAttribute('data-disable-input', 'false');
        }

        console.log('Google Docs in viewer mode is now editable.');
    }

    // Start the process once the page is ready
    waitForDocument();
})();