Created
May 1, 2026 17:04
-
-
Save thekingofspain/8e14c3110956cb095ebd2ec2b13e40b8 to your computer and use it in GitHub Desktop.
Google Docs Annoyance Helper - Tamper Monkey Script - DeNag for User Confirmation & Paste Unformatted
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // ==UserScript== | |
| // @name googleDocsAnnoyanceHelper.js | |
| // @namespace https://gist.github.com/thekingofspain | |
| // @version 1.1.0 | |
| // @description Automates "Cancel" on Google Docs paste nags and removes account modals. | |
| // @author thekingofspain | |
| // @match https://docs.google.com/* | |
| // @match https://sheets.google.com/* | |
| // @match https://slides.google.com/* | |
| // @grant none | |
| // @run-at document-end | |
| // @updateURL https://gist.github.com/thekingofspain/raw/googleDocsAnnoyanceHelper.js | |
| // @downloadURL https://gist.github.com/thekingofspain/raw/googleDocsAnnoyanceHelper.js | |
| // @date 2026-05-01 | |
| // ==/UserScript== | |
| (function() { | |
| 'use strict'; | |
| /** | |
| * Handle the "Active Account" modal using a polling interval. | |
| * Stops once found or after 60 attempts (approx 6 seconds). | |
| */ | |
| const initAccountModalRemover = () => { | |
| let tries = 0; | |
| const intervalId = window.setInterval(() => { | |
| const modal = document.querySelector('.modal-dialog.active-account-dialog'); | |
| if (modal) { | |
| modal.remove(); | |
| console.log("Account modal removed."); | |
| } | |
| if (modal || ++tries > 60) { | |
| window.clearInterval(intervalId); | |
| } | |
| }, 100); | |
| }; | |
| /** | |
| * Handle the "Paste Nag" dialog using a MutationObserver. | |
| * Persistent because this popup recurs on context menu usage. | |
| */ | |
| const initPasteNagHandler = () => { | |
| const observer = new MutationObserver(() => { | |
| const dialog = document.querySelector('.javascriptMaterialdesignGm3WizDialog-dialog--open'); | |
| if (dialog && dialog.innerText.includes("Enable copy, cut, and paste?")) { | |
| const buttons = dialog.querySelectorAll('button'); | |
| const cancelButton = Array.from(buttons).find(btn => | |
| btn.innerText.includes('Cancel') | |
| ); | |
| if (cancelButton) { | |
| cancelButton.click(); | |
| // Small delay to let the UI clear before triggering paste | |
| setTimeout(() => { | |
| const pasteEvent = new KeyboardEvent('keydown', { | |
| key: 'v', | |
| keyCode: 86, | |
| code: 'KeyV', | |
| ctrlKey: true, | |
| bubbles: true | |
| }); | |
| document.activeElement.dispatchEvent(pasteEvent); | |
| }, 100); | |
| } | |
| } | |
| }); | |
| observer.observe(document.body, { | |
| childList: true, | |
| subtree: true | |
| }); | |
| }; | |
| // Initialize both functional listeners | |
| initAccountModalRemover(); | |
| initPasteNagHandler(); | |
| })(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment