5

Until recently it was possible, in a chrome extension, to know if the current tab was a new tab by checking if the tab url was "chrome://newtab/" however since the last update it seems that the new tab url is something like "https://www.google.[...]/webhp?sourceid=chrome-instant&[...]".

Is there a robust way to find if the active tab is newtab ? (I don't consider catching newtab event or having a superficial look at the url shape as robust)

2
  • Please show your code. I cannot reproduce your problem in Chrome 32.0.1667.0 (Canary Aura, Windows). I've created a dummy extension with the <all_urls> and tabs permissions, and read the current URL in the chrome.browserAction.onClicked event, which showed "chrome://newtab/".
    – Rob W
    Commented Oct 11, 2013 at 20:49
  • Did you ever find a solution for this? I'm doing the exact same thing. Thanks! Commented Jan 11, 2020 at 20:54

1 Answer 1

2

Use activeTab.url == "chrome://newtab/"

At least in Chrome Version 79.0.3945.88 (Official Build) (64-bit), to check if the current/active tab is a new tab, you can still do:

activeTab.url == "chrome://newtab/"

Maybe you have another extension or a configuration setting where it's defaulting your new tabs to a certain URL.

1
  • If I understand correctly, [activeTab] = await window.browser.tabs.query({ active: true, currentWindow: true }); and you must have the activeTab or tabs permission in your manifest, otherwise url is unset.
    – gman
    Commented Apr 5 at 17:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.