topSites.get()

Gets an array containing all the sites listed in the browser's "New Tab" page.

The "New Tab" page is the page that opens when the user opens a new tab without immediately loading a page into it: for example, using the "Open a new tab" button. The browser generally fills this list with sites the user visits most often.

This is an asynchronous function that returns a Promise.

Syntax

var gettingTopSites = browser.topSites.get()

Parameters

None.

Return value

A Promise. This will be fulfilled with an array of MostVisitedURL objects, one for each site listed in the browser's "New Tab" page. If an error occurs, the promise will be rejected with an error message.

Browser compatibility

ChromeEdgeFirefoxFirefox for AndroidOpera
Basic supportYesNo5252Yes

Examples

This code logs the title and URL for all sites in the "New Tab" page:

function logTopSites(topSitesArray) {
  for (topSite of topSitesArray) {
    console.log(`Title: ${topSite.title}, URL: ${topSite.url}`);
  }
}
function onError(error) {
  console.log(error);
}
var gettingTopSites = browser.topSites.get();
gettingTopSites.then(logTopSites, onError);

Example extensions

Acknowledgements

This API is based on Chromium's chrome.topSites API.

Microsoft Edge compatibility data is supplied by Microsoft Corporation and is included here under the Creative Commons Attribution 3.0 United States License.

Document Tags and Contributors

 Contributors to this page: wbamberg
 Last updated by: wbamberg,