开发者

Chrome extension; How to get all tabs, store tab info to array?

开发者 https://www.devze.com 2023-04-11 22:09 出处:网络
I would like to take all the windows/tabs from chrome and store the titles/urls to a localstorage array to access later.

I would like to take all the windows/tabs from chrome and store the titles/urls to a localstorage array to access later.

I currently have the code below, b开发者_如何学编程ut it is stopping after the alert and returning "tab is undefined" and I can't figure it out! Am I completely off base here?

function asdf()
{

  chrome.windows.getAll({"populate" : true}, function(windows)

  {

    for(var i = 0; i < windows.length; i++)
    {
      for(var j = 0; j < windows[i].tabs.length; j++)
      {
        original.push(new tabInfo(windows[i].tabs[j], j));
        alert(original[i*j].tab.title);
        original[i*j].tab.title = tab.title;
        original[i*j].tab.url = tab.url;
        original[i*j].tab.status = tab.status;
        original[i*j].count = 0;

        localstorage.setitem["tab.title"];
        localstorage.setitem["tab.url"];
        localstorage.setitem["tab.status"];
       }
    }
  });


You use incorrect index accessor. Just change original[i*j] to original[original.length - 1].


See also the OneTab extension for doing just that: http://www.one-tab.com/

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号