I ran your script and it works fine and changes the icon. Actually
since I'm not on Facebook, I commented out the stuff that scrapes the
page and changes document.title and ran the script on the URL

 http://apps.facebook.com/castle_age/*

(Yes that is a '*' at the end of the URL)..

I thought you might be having some scope/closure issues in your timer
called function but you lucked out.

What does the Tools>Error Console say?

I also thought you might be having problems with expando properties
that don't work in the GM sandbox but that is also not the case. BTW,
here is a slightly more transparent way to make a link where the
expando issue doesn't come up.

 var dummyDiv = document.createElement('div');
 dummyDiv.innerHTML = '<link id="ico_e" rel="icon" type="img/png"'
     + ' href="http://www.rw-designer.com/icon-image/
273-16x16x32.png">';
 var newLink = dummyDiv.firstChild;

Also, when you want to remove a DOM node it is easier to directly
access its parent

  var head = oldLink.parentNode;
  head.removeChild(oldLink);
  head.appendChild(newLink);

But neither such clarifications were necessary for your script to run.
On Jan 21, 7:56 am, jure <[email protected]> wrote:
> hi,
>
> i want dynamically replace Castle Age's (facebook game) favicon, but
> strangely favicon doesn't change!
>
> where am i wrong?? here is the code:
>
> // ==UserScript==
> // @name           FB Castle Age
> // @namespace      http://apps.facebook.com/castle_age/
> // @include        http://apps.facebook.com/castle_age/*
> // ==/UserScript==
> var head=document.getElementsByTagName("head")[0];
>
> var ico={
>         e:document.createElement("link")}
>
> ico.e.id="ico_e";ico.e.rel="icon";ico.e.type="image/png";
> ico.e.href="http://www.rw-designer.com/icon-image/273-16x16x32.png";;
>
> var getTimers=function(){
>         // energy
>         var t=document.getElementById
> ("app46755028429_energy_time_value").innerHTML;
>         var M=document.getElementById
> ("app46755028429_st_2_2").getElementsByTagName("span")[1].innerHTML;
>         var c=document.getElementById
> ("app46755028429_energy_current_value").innerHTML;
>         document.title=t+" "+c+"/"+M;
>
>         var links=document.getElementsByTagName("link");
>         for(var i=0;i<links.length;i++){
>                 var link=links[i];
>                 if(link.rel=="shortcut icon"||link.rel=="icon"){
>                         head.removeChild(link);
>                 }
>         }
>
>         head.appendChild(ico.e);
>         setTimeout(getTimers,1000);}
>
> getTimers();

-- 
You received this message because you are subscribed to the Google Groups 
"greasemonkey-users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/greasemonkey-users?hl=en.

Reply via email to