简体   繁体   中英

Change the value of a textarea in way that its react prop “value” changes

I need to change value of textarea(commnet box of instagram.com) through a chrome extension's script(content script) so that its react prop "value"(this.props.value) changes and on triggering submit event on the parent form element the comment get posted.

If I trigger the event after changing the textarea's value with $commentBox.value = "comment" and then trigger submit event on the form element the comment doesnt get posted and I checked through react devtools that prop value is "". I think prop value changes only on keydown/keypress but faking keydown/keypress after changing the value also doesnt work

how can I insert the comment through javascript and then post it? also see this SO post

was just checking questions I'd asked and found this one

This cannot be done through an extension's script because using javascript there we can only fire untrusted events which woukld get filtered. This would be possible only with puppeteer

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM