Created
February 28, 2017 21:23
-
-
Save matt-curtis/1fc2ba834d51f09d2e179ee77945a57b to your computer and use it in GitHub Desktop.
Google Docs - Accept all suggestions
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
function run(){ | |
var shouldRun = confirm("Are you sure you want to accept all suggestions?\n\n(Note: Depending on the number of suggestions you have, this script may take a few seconds to run.)"); | |
if(!shouldRun) return false; | |
var events = [ "mouseover", "mousedown", "click", "mouseup" ]; | |
var suggestionButtons = Array.from(document.querySelectorAll("[role='button'][aria-label='Accept suggestion']")); | |
suggestionButtons.forEach((el) => { | |
events.forEach((eventName, i) => { | |
el.dispatchEvent(new MouseEvent(eventName)); | |
}); | |
}); | |
return true; | |
} | |
run(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment