Skip to content

Instantly share code, notes, and snippets.

@smialex
Last active April 8, 2022 18:06
Show Gist options
  • Save smialex/ca983b62e9f138fa2078561230d1df4a to your computer and use it in GitHub Desktop.
Save smialex/ca983b62e9f138fa2078561230d1df4a to your computer and use it in GitHub Desktop.
function setNativeValue(element, value) {
const valueSetter = Object.getOwnPropertyDescriptor(element, 'value').set;
const prototype = Object.getPrototypeOf(element);
const prototypeValueSetter = Object.getOwnPropertyDescriptor(prototype, 'value').set;
if (valueSetter && valueSetter !== prototypeValueSetter) {
prototypeValueSetter.call(element, value);
} else {
valueSetter.call(element, value);
}
}
function sendText(text){
textarea = document.querySelector('.chat-input__textarea > [data-a-target="chat-input"]')
textarea.focus()
setNativeValue(textarea, text);
textarea.dispatchEvent(new Event('input', { bubbles: true }));
button = document.querySelector('[data-a-target = "chat-send-button"]')
button.click()
}
function sendMessage(){
sendText('!guit');
sendText('круто');
}
setInterval( sendMessage , 1000)
@devjanger
Copy link

noice

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment