简体   繁体   中英

Detecting active tab is a new tab in chrome extension

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)

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM