Skip to content

Instantly share code, notes, and snippets.

@azizimusa
Created November 7, 2021 01:13
Show Gist options
  • Save azizimusa/160fdce78ea453478316c01f2509b7d5 to your computer and use it in GitHub Desktop.
Save azizimusa/160fdce78ea453478316c01f2509b7d5 to your computer and use it in GitHub Desktop.
Send chat message to active window
window.InputEvent = window.Event || window.InputEvent;
var ev = new KeyboardEvent('keydown', {altKey:false,
bubbles: true,
code: "Enter",
key: "Enter",
keyCode: 13,
type: "keydown",
which: 13});
var event = new InputEvent('input', {
bubbles: true
});
var textbox = document.getElementsByTagName('textarea')[0];
textbox.textContent = "Testing";
textbox.dispatchEvent(event);
textbox.dispatchEvent(ev);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment