Skip to content

Instantly share code, notes, and snippets.

@benzittlau
Created May 29, 2015 21:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save benzittlau/a05e7669a5a53d8f2333 to your computer and use it in GitHub Desktop.
Save benzittlau/a05e7669a5a53d8f2333 to your computer and use it in GitHub Desktop.
Programatically Accept Suggestions in Google Docs
function hardClick(node) {
triggerMouseEvent (node, "mouseover");
triggerMouseEvent (node, "mousedown");
triggerMouseEvent (node, "mouseup");
triggerMouseEvent (node, "click");
}
function triggerMouseEvent (node, eventType) {
var clickEvent = document.createEvent ('MouseEvents');
clickEvent.initEvent (eventType, true, true);
node.dispatchEvent (clickEvent);
}
hardClick(document.getElementsByClassName("docos-icon-accept-suggestion-checkmark")[0])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment