Quantcast
Channel: Active questions tagged tabs - Stack Overflow
Viewing all articles
Browse latest Browse all 579

Chrome Ext to open a new tab and populate fields in the newly opened tab

$
0
0

I am trying to build an ext that will Chrome Ext to open a new tab and populate fields in the newly opened tab. So far, I am able to open the new tab but can't get it to populate the fields in the nw tab.

Popup.html:

<html>..../* user selects which url to open*/<select name="choices" id="choice"><option value="a"> a</option>...</select>

popup.js

document.getElementById("choice").addEventListener("change",func)func(){switch(choice){case a:newurl="https://:.abc.com"break;.....}chrome.tabs.create({url: newurl},populate) // also tried .then( , , ,)populate(){chrome.tabs.onActivated.addListener(function(activeInfo) {  \\also tried onUpdated   chrome.tabs.get(activeInfo.tabId, function(tab){     chrome.scripting.executeScript({target : {tabId :getCurrentTab()},files : [ "abc.js" ] })  });}}
async function getCurrentTab() { let queryOptions = { active: true };let [tab] = await chrome.tabs.query(queryOptions);}

// I figured maybe I should put the onUpdated listener and populate function in the background script, but if I first open the site independently (manually) then run the ext it works, but not if I run it from a different site,

Can anyone provide an example of how to accomplish this.

Thank you in advance.


Viewing all articles
Browse latest Browse all 579

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>