简体   繁体   English

更改文本区域的值,使其响应属性“值”改变

[英]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. 我需要通过Chrome扩展程序的脚本(内容脚本)更改textarea(instagram.com的COMNET框)的值,以便其反应属性“值”(this.props.value)发生变化并触发父表单元素上的Submit事件评论发表。

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 "". 如果我在使用$commentBox.value = "comment"更改textarea的值后触发事件,然后在form元素上触发$commentBox.value = "comment"事件,则注释不会被发布,并且我通过react devtools检查了prop值为“”。 I think prop value changes only on keydown/keypress but faking keydown/keypress after changing the value also doesnt work 我认为prop值仅在keydown / keypress上更改,但是在更改值后伪造keydown / keypress也不起作用

how can I insert the comment through javascript and then post it? 如何通过javascript插入评论,然后发布? 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. 这不能通过扩展程序的脚本来完成,因为在那使用javascript,我们只能触发woukld被过滤的不可信事件。 This would be possible only with puppeteer 只有木偶戏才有可能

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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