How to make chrome.tabs.update works with content script

Posted by user1673772 on Stack Overflow See other posts from Stack Overflow or by user1673772
Published on 2012-11-04T16:58:39Z Indexed on 2012/11/04 16:59 UTC
Read the original article Hit count: 160

I work on a little extension on Google Chrome, I want to create a new tab, go on the url "sample"+i+".com", launch a content script on this url, update the current tab to "sample"+(i+1)+".com", and launch the same script. I looked the Q&A available on stackoverflow and I google it but I didn't found a solution who works. This is my actually code of background.js (it works), it creates two tabs (i=21 and i=22) and load my content script for each url, when I tried to do a chrome.tabs.update Chrome launchs directly a tab with i = 22 (and the script works only one time) :

function extraction(tab) {
for (var i =21; i<23;i++)
    {
        chrome.storage.sync.set({'extraction' : 1}, function() {}); //for my content script
        chrome.tabs.create({url: "http://example.com/"+i+".html"}, function() {});
    } 
}
chrome.browserAction.onClicked.addListener(function(tab) {extraction(tab);});

If anyone can help me, the content script and manifest.json are not the problem. I want to make that 15000 times so I can't do otherwise.

Thank you.

© Stack Overflow or respective owner

Related posts about google-chrome-extension