Skip to content

Instantly share code, notes, and snippets.

@matt-curtis
Created February 28, 2017 21:23
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save matt-curtis/1fc2ba834d51f09d2e179ee77945a57b to your computer and use it in GitHub Desktop.
Save matt-curtis/1fc2ba834d51f09d2e179ee77945a57b to your computer and use it in GitHub Desktop.
Google Docs - Accept all suggestions
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