Search code examples
javascriptgoogle-chromegoogle-chrome-extension

How to get just opened pages not chrome special pages in my own extension


I want to get opened tabs but not opened empty new tabs, bookmarks tab, download tabs and etc. How can I do it?


Solution

  • Use *://*/* where the first * matches http and https, more info in the documentation.

    chrome.tabs.query({url: '*://*/*'}, tabs => {
      // process tabs here
    });
    

    If you want to include file:// tabs too:

    chrome.tabs.query({url: ['*://*/*', 'file://*/*']}, tabs => {
      // process tabs here
    });