I'm trying to create a Chrome Extension which modifies the submitted message when the user presses enter in the chatbox. HTML-Code for textarea:
<textarea class="uiTextareaAutogrow input" onkeydown="Bootloader.loadComponents(["control-textarea"], function() { TextAreaControl.getInstance(this) }.bind(this)); "></textarea>
I tried to use something like this for onkeydown-event. I want to replace users message with the text 'test' when he presses Enter and submits the text
if (event.keyCode == 13) {this.value='test';}
But of course this doesn't work because facebooks javascript uses Eventlisteners and .bind so the value in the textarea changes AFTER the text is processed and submitted but I need to modify it BEFORE it is processed. Does somebody know how I could solve this?
来源:https://stackoverflow.com/questions/11529083/chrome-extension-modify-messagetext-in-facebook-chat-when-submitted