I am learning to building a relatively simple Chrome extension and I'm at a point where I've got a background.js
file with this set of code.
chrome.browserAction.onClicked.addListener(function(tab) { chrome.tabs.getSelected(null,function(tab) { chrome.tabs.create( { url: " https://hello.world.com/ " } ); }); });
Upon button press of the extension, it's supposed to launch a new Chrome tab with https://hello.world.com .
There is a specific AngularJS button on https//hello.world.com
called ng-click="aaa.bbb()"
that I would like to trigger as part of the same process (when the new Chrome tab is launching http://hello.world.com
), but I'm not sure what lines I need to add to the my background.js
file to trigger that action.
Appreciate anyone's help. Thanks in advance.
You have to prepare content_script and execute it in the URL of the tab to open. However, since the trigger of content_script is sandbox, it cannot be triggered directly. Therefore, from content_script It finally works by adding a script element containing the code to target.click (); to document.body.
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.