Favicon Replacer

Subscribe to Favicon Replacer 3 posts, 3 voices

 
Greg Bartell User

Today I installed about ten scripts and totally customized google. It's exactly how I want it, except the favicon. I would love it if someone made a script to replace the favicon. Thanks!

 
Arvid Scriptwright

var faviconsrc = 'http://swedvdr.org/favicon.ico';

function trim(str) {
    return str.match(/^\W*(.*?)\W*$/)[1];
}

function remove(node) {
    if (node.parentNode)
        node.parentNode.removeChild(node);
}

var head = document.getElementsByTagName('head')[0];
var lns = head.getElementsByTagName('link');
for (var i = 0; i < lns.length; i++) {
    v = lns[i];
    var relval = trim(v.getAttribute('rel'));
    if (relval == 'shortcut icon' || relval == 'icon')
        remove(v);
}
var newln = document.createElement('link');
newln.setAttribute('rel', 'icon');
newln.setAttribute('href', faviconsrc);
head.appendChild(newln);

Hope that helps!

 
Johan Sundström Scriptwright

Mark my links does that, among other things, and with a totally no-programming interface too. Install it, go to the site where you want to change favicons, use the bookmarklet, check the "Override original favicon" checkbox, click the google favicon, paste in your preferred favicon URL, click the "add link" icon on the right, click "Save changes".

Yes, that's a whole lot of clicking, but after that, all pages at www.google.com will use your favicon instead. Click the "Site" text if you want more hard-core tweaking, allowing you to change the matcher to be a regexp applied to the whole URL (if you perhaps wanted it only on pages below http://www.google.com/reader/, for instance).