Reputation: 6834
I'm building a Chrome Extension
which overrides the new tab. I managed to override the new tab with my HTML file and also the page title. However, the favicon doesn't show up on the new tab with no errors showing up.
Here is my manifest.json
:
{
"manifest_version": 2,
"name": "Hello World",
"browser_action": {
"default_icon": "icon.png",
"default_popup": "popup.html"
},
"chrome_url_overrides" : {
"newtab": "hello_world.html"
},
"permissions": [
"activeTab",
"tabs"
]
}
Here is hello_world.html
:
<html>
<head>
<title>Hello World</title>
<link rel="shortcut icon" href="favicon.ico"/>
</head>
<body>
<div>Hello World</div>
</body>
</html>
I couldn't find anything in the docs
regarding favicon on a new tab.
Upvotes: 2
Views: 1794
Reputation: 288
You have to add favicon.ico
to web_accessible_resources in your manifest, so that your hello_world.html
can access it. And then you have to change the href
of your favicon dynamically to the result of chrome.extension.getURL("favicon.ico")
.
Add this to your manifest: "web_accessible_resources": [ "favicon.ico" ]
EDIT: Deleted code sample because it didn't work and added a new one.
This code just works if you override the history
or bookmarks
page because they have a favicon by default. Just change this in the manifest to try out and edit the head
of hello_world.html
to the code below.
<title>Hello World</title>
<link rel="shortcut icon" href="chrome-extension://{ID OF YOUR EXTENSION}/favicon.ico" />
Sadly it isn't possible to add a favicon to the newtab
page. I hope you can live without it ;)
Upvotes: 3