In my chrome extension\'s content script, I click on certain links/buttons on webpages from certain sites. To do that, I use following code in the content script (I embed jQ
Due to browser extension sand-boxing, and basic jQuery functionality, you cannot trigger a non-jQuery click event with trigger or click.
You can however call the raw DOM element click method, which will act exactly as if the element was clicked with the mouse. Just use [0] to access the DOM element:
$(css_selector)[0].click();
Although you would seldom need to, you can trigger all matching buttons using the same code in an each. As the this in an each is the DOM element it is quite simple:
$(css_selector).each(function(){
this.click();
});