Last active
April 8, 2022 18:06
-
-
Save smialex/ca983b62e9f138fa2078561230d1df4a to your computer and use it in GitHub Desktop.
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 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) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
noice