Simple Chrome Extension : Open an url in a new tab -
i'm looking create "new tab" extension panda or product hunt extension: user can open new tab website inside, hidden url.
i've generated package awesome extensionizr , here manifest.json
:
manifest.json
{ "name": "my app", "version": "0.0.1", "manifest_version": 2, "description": "my awesome app", "homepage_url": "http://myapp.com", "icons": { "16": "icons/icon16.png", "48": "icons/icon48.png", "128": "icons/icon128.png" }, "default_locale": "en", "background": { "scripts": [ "src/bg/background.js" ], "persistent": false }, "permissions": [ "tabs", "http://myapp.com/*" ] }
my background.js
come this answer, problem seems similar.
background.js
chrome.browseraction.onclicked.addlistener(function(activetab) { var newurl = "http://myapp.com"; chrome.tabs.create({ url: newurl }); });
i'm still getting error when try run background page extension settings : uncaught typeerror: cannot read property 'onclicked' of undefined
and when open new tab, google chrome took advantage , display me google search page.
i wrong, , don't know how/where/why
you're off-track. don't want open (simple) new tab, want replace "new tab page".
daniel's answer correctly explains why code not work, won't wanted.
to replace chrome's new tab page, need use override pages:
"chrome_url_overrides" : { "newtab": "mypage.html" },
inside mypage.html
, can add <iframe>
remote content.
Comments
Post a Comment