PRinCEKtd PRinCEKtd - 5 months ago 148x
Javascript Question

Google chrome extension to open the New Tab page

I am trying to make a simple chrome extension.
It is supposed to add an item "Open new tab" in the 'windows system tray chrome icon context menu' (similar to how the checker plus for gmail extension has done; see the second image given below).

when I click the option, chrome is supposed to (check if any window is open. If yes, then it is supposed to) open a new tab page. If no windows are open, then it is supposed to open a new chrome window with the new tab page showing.

What I have done till now:


"manifest_version": 2,

"name": "Open New Tab",
"description": "This extension open a new tab page",
"version": "1.0",
"browser_action": {
"default_icon": "icon.png"
"persistent": false
"permissions": [


chrome.tabs.create({ url: "chrome://newtab" });


{{url: "chrome://newtab", type: "normal"});

I have already loaded this extension.
The effects of my extension on chrome so far:

1) Chrome window is already open.
My icon shows up in the list of extensions and is clickable.enter image description here

On clicking, a 'new tab' page is opened in the same window. This is correct. (Though I don't need this. For now, let it be.)

2) Chrome window is closed, and chrome is allowed to run in the background. Rightclick the chrome tray icon. My extension menu 'Open a new tab' shows up in the menu.enter image description here

This is also correct. On clicking it, a new chrome window is created. (Currently, I have not yet checked if a window already exists. That is to come later.).

The problem is that, in the new window that opens, instead of the 'new tab' page, chrome automatically opens the 'chrome://extensions' URL. This is wrong, and I cannot understand why the extensions page is opening. I want to open the new tab page, and i am passing the 'chrome://newtab' URL. How do I make chrome open the new tab page from here? Chrome works correctly when I start it from my desktop icon or windows start menu. So, the problem seems to be something with my code.

Any help is appreciated.


Listen to event, when right clicking chrome tray icon, a new window would be launched, then you could create a new tab in the event handler. { {
        if (windows.length === 1) {           
            chrome.tabs.create({windowId:, url: "chrome://newtab"});