5

I am making a chrome extension to get urls of all open tabs and save them all to send them to a domain.so i require 2 steps:

  1. Get urls of all open tabs and store them in an array or stuff like that.
  2. Send the array of all urls to a domain.
Rob W
  • 341,306
  • 83
  • 791
  • 678
fahadsafdar
  • 109
  • 1
  • 1
  • 3
  • I'm guessing by the votes I'm not the only one who thinks this sounds dodgy... – Adam M-W Jun 25 '12 at 04:17
  • This question has an answer that explains how to find all the open tab URLs using Javascript: http://stackoverflow.com/questions/11915370/retrieving-which-tabs-are-open-in-chrome – Anderson Green Aug 23 '12 at 21:29

1 Answers1

9

Look at chrome.windows.getAll to get a list of open windows. Each window has a tabs property that contains a list of tabs in the window. Each tab has a url property. See tabs documentation.

You'll want to loop over the windows, and then the tabs in each window, and add these to your array and then do whatever it is you want to do.

Normally you can't do this, but chrome extensions with the necessary permissions are allowed to do Cross-Origin XMLHttpRequest. You'll need that to send the list to the other domain.

You can use JSON.stringify to convert an array to a string that you can send and then some similar function on the server side to convert it back to an array.

sachleen
  • 30,730
  • 8
  • 78
  • 73