amithal
amithal

Reputation: 31

Can an extension detect Google Chrome's home page?

Is there a way to detect Google Chrome's home page via the chrome.* extension API, or any other way? Thanks!

Upvotes: 3

Views: 400

Answers (1)

serg
serg

Reputation: 111285

There is no API call for this. The closest I could get was to run chrome.tabs.getAllInWindow in the beginning of a background page and then analyze returned tabs.

chrome.tabs.getAllInWindow(null, function(tabs) {
    if(tabs.length == 1 && tabs[0].status == "loading") {
        console.log("possible home page:", tabs[0].url);
    }
});

This would work most of the times, but if your extension will be enabled when current window happens to have 1 tab which is currently loading - it would return wrong url. So you need to implement check to at least not run this code during first extension installation (by using some localStorage flag).

Upvotes: 3

Related Questions