How to check if a specific page is already open in Google Chrome?

Look inside the Google Mail Checker extension, which has this functionality:

function goToInbox() {
  chrome.tabs.getAllInWindow(undefined, function(tabs) {
    for (var i = 0, tab; tab = tabs[i]; i++) {
      if (tab.url && isGmailUrl(tab.url)) {
        chrome.tabs.update(tab.id, {selected: true});
        return;
      }
    }
    chrome.tabs.create({url: getGmailUrl()});
  });
}

In particular, you pass getAllInWindow the windowId (or undefined for the current window) and a function, which receives the array of Tab objects. You don't modify the properties of the tab directly; rather you pass its id to the update function in order to manipulate it.


To make Josh Lee's answer work using version 2 manifest, you have to add permission to the tabs in the manifest.json file:

...
"permissions": [
    "tabs"
]
...

I have no clue how this kind of construction adds 'security' to the web ...