Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Invoke button.onclick through content scripts for Chrome extension [closed]

We are developing an Chrome extension, where in we faced the following issue.

We try to access submit button.onclick() through content scripts.js for Chrome extensions. But onclick() event is not getting triggered while we invoke from content scripts.js.

How to resolve this issue?

like image 418
Viswa Avatar asked Nov 29 '25 03:11

Viswa


1 Answers

Content scripts have access to the DOM but not directly to the code execution environment - however you should be able to get the DOM element and call the "click()" method which should then issue the command.

If, that doesn't work, it is perfectly possible for you to inject a new <script> tag via the content script which will instead call the submit button using something like <script>$("button")[0].click()</script>

like image 161
Kinlan Avatar answered Nov 30 '25 16:11

Kinlan



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!