I narrowed down the reason. It was not working only in my script but
working in the others I installed. So I found out that when I write
this code directly in a user.js file :

        if(GM_setValue)
        {
                alert('yes');
                if(GM_getValue('Test','') == '')
                {
                        alert('not found');
                        GM_setValue('Test','Passed');
                }
                else alert(GM_getValue('Test',''));
        }

It works perfectly and gets/sets a value and I can see that in
about:config.

But when my script changes to this :

myScript = function()
{
        if(GM_setValue)
        {
                alert('yes');
                if(GM_getValue('Test','') == '')
                {
                        alert('not found');
                        GM_setValue('Test','Passed');
                }
                else alert(GM_getValue('Test',''));
        }
alert('something');

}

document.body.appendChild(document.createElement("script")).innerHTML
= "("+myScript+")()";

It doesn't work !!! But I need my methods to be embedded in the
document body,  they won't work otherwise ! How can I get it to work?

Thanks,
Piyush


On Apr 5, 12:24 pm, "Brian L. Matthews" <[email protected]> wrote:
> On 4/5/10 9:17 AM, Piyush Soni wrote:
>
>
>
> > Anyone?
>
> > Thanks,
>
> > On Apr 4, 3:57 pm, Piyush Soni<[email protected]>  wrote:
>
> >> Hi All,
> >> I must be doing something severely wrong, but I don't know what's
> >> that. I have written a lot of scripts for my personal use on my
> >> machines, but at no place any of the GM_ methods are working. It
> >> doesn't give any error message also. (I remember getting the variable
> >> GM_log not defined message in the Error Console once, but I don't see
> >> even that now). I have read at places about making
> >> javascript.options.strict and javascript.options.showInConsole true
> >> and did that, but even that didn't help. Similarly I cannot use
> >> GM_setValue and GM_setValue which I really need now.
>
> >> If that matters at all, I have Firebug also installed.
>
> I use a bunch of scripts and they all seem to work fine, and I'm working
> on a pretty extensive one right now that uses GM_[sg]etValue and
> GM_xmlhttpRequest and it works (I also have Firebug installed). The
> usual path is to create a new, empty Firefox profile and install just
> Greasemonkey and the script you're working on. If things work there,
> start bringing it up to the non-working profile's level until things
> stop working. As a quick first test, it might be useful to uninstall
> Greasemonkey then reinstall it, but if that doesn't help, the empty
> profile is probably the way to go.
>
> Brian

-- 
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