Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Remove favicon using javascript in Google Chrome

How can you remove the favicon using Javascript in google chrome? The goal is to return it to the browser default, which is in this case a blank image.

I found this question, but it doesn't work if you leave the link.href attribute as empty.

Even if the favicon is set because there is a favicon.ico file on the server, I'd like to remove it and set it back to the default.

This only needs to work in chrome.

Thanks!

like image 924
Cyclone Avatar asked May 19 '10 23:05

Cyclone


People also ask

How do I remove favicon from Chrome?

From the context menu, select 'Options'. This will open a new tab listing all your bookmarks. Expand a folder of bookmarks, and select the bookmark you want to change the favicon for. Right-click the bookmark you want to change the favicon for, and from the context menu, select 'Change Favicon'.

How can I delete favicon?

By default, your browser will use the favicon in the same folder with your html file, so removing your link tag will do nothing. You need to move the favicon elsewhere or delete it. Then, if it stills shows up, clear your cache and go to the icon to see the new one.

How do I change my favicon dynamically?

$('head'). append('<link id="dynamic-favicon" rel="shortcut icon" href="https://www.XYZ.com/favicon.ico" />'); This works by adding a link to the head of the page, which changes the shortcut icon of the page to the specified image. Causing the image on the tab in the browser to change.

What is the favicon changer in Chrome?

Favicon Changer. Lets you change favicons for your bookmarks, single webpages and entire websites.


2 Answers

Have you tried using an empty transparent image?

Try:

data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAAZiS0dEAP8A/wD/oL2nkwAAAAlwSFlzAAALEwAACxMBAJqcGAAAAAd0SU1FB9oFFAADATTAuQQAAAAZdEVYdENvbW1lbnQAQ3JlYXRlZCB3aXRoIEdJTVBXgQ4XAAAAEklEQVQ4y2NgGAWjYBSMAggAAAQQAAGFP6pyAAAAAElFTkSuQmCC
like image 149
Matthew Flaschen Avatar answered Oct 15 '22 12:10

Matthew Flaschen


Putting those comments into answer form:

Suggestions:

  • chrome-resource://favicon/ or chrome://favicon/
  • Dynamic Favicon with AJAX
  • Chrome extension (hopefully you can base it off of this)

I'm a bit surprised the AJAX solution worked for you because, I'm on Chrome 4.1.249.1064 (45376) and it doesn't work for me.

EDIT: It doesn't seem like you'll need much from the AJAX solution. It seems that favicon.js is all you really need. All it seems to do is what the JavaScript solution you mentioned plus a little more handling (ie remove existing favicon). Their "dynamic" part is just a document.onkeypress.

EDIT: Additional reference:

  • chrome.tabs.executeScript
  • Whitelisting the favicon
like image 35
nevets1219 Avatar answered Oct 15 '22 13:10

nevets1219