Allow editing in Google Docs viewer mode
当前为
// ==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();
})();