Using the chat textbox with javascript

Hello! I am trying to learn javascript, watch a lot of Twitch and had an idea for a small script for personal use.

So, in short: I would like to create a bookmarklet which fills the chatbox with text (channel emotes in this case. If a user subscribes I want to click the bookmarklet to automatically put some ‘sub hype’ emotes into the chatbox).

Here’s what I tried:

I got a reference to the chatbox using queryselector, then just changed the value to “test”.

This works, but the chat button is disabled, making me think that the textbox needs to fire some event.

I tried the dispatchEvent function with various events like ‘change’ or ‘keydown’, I tried to call the ‘focus’ function of the textbox. No luck. As far as I saw the chat-button does not have an ‘enabled’ property.

So, does anyone know what I am missing? What do I need to learn to properly understand this? Is this even possible from the client side?

Thanks for any input!

The long and short of it, you can’t and shouldn’t do that.

What you describe is basically clickjacking, and Twitch (and other entities) often go to great lengths to prevent this, in order to stop malicious scripts doing what you are trying to do.

That’s what I thought. Thank you very much!

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.