Question

hello i'm writing a GM user script and i want to change the favicon dynamically changing it the old way is easy but i want to encode it in base64 to avoid hosting it

this is what i have done after hosting the favicon

var link = document.createElement('link');
link.type = 'image/x-icon';
link.rel = 'shortcut icon';
link.href = 'http://img36.imageshack.us/img36/5051/play723.png';
document.getElementsByTagName('head')[0].appendChild(link);

is there a way to do this with an encoded image i tried link.href="url(data:image/png;base64,iVBOR....)" which lead to nothing

Was it helpful?

Solution

You need to drop the url() wrapper. data: is an URL scheme of its own (RFC 2397), and it should constitute the value of the href attribute. Of course, only browsers supporting that RFC would be able to understand this link.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top