0

I am trying to write an extension for Google Chrome. My extension will need info about opened tabs, actually, I want to know, for instance, in tab[1], http://www.google.com is open.

How I will achieve this, thanks :)

msharpp
  • 379
  • 1
  • 6
  • 20

1 Answers1

0

You'll have to add "tabs" to your permissions in your manifest.json file. Then, you can simply use the chrome.tabs.query function and specify no properties to get all the tabs.

Some sample code would look like this:

chrome.tabs.query(null, function (tab){
    console.log(tab[0].url);
});
Some Guy
  • 15,854
  • 10
  • 58
  • 67
  • Thanks but, how do I use chrome.tabs api? I added your code to my code file, nothing happened. – msharpp Dec 18 '11 at 17:46
  • Oops. I forgot to `console.log` it. :P. Try opening the file wherever you put the code in the console. It should tell you the first tab's URL. – Some Guy Dec 18 '11 at 18:02