Hi everyone,

Please forgive my not-so-well English.

I have already read http://wiki.greasespot.net/0.7.20080121.0_compatibility.
The script I am writing is to display picture thumbnails from links
like http://moby.to/rrrg1x.

I got 'Greasemonkey access violation: unsafeWindow cannot call
GM_getValue.' errors when I call MobyUtils.getThumbUrl() function. And
the code is listed below.

I am not sure whether the GM_getValue was called in unsafeWindow,
because I am not using the 'unsafeWindow' word at all. I just want to
load the api key at run time via getKey method.

So, how can I get the returned value from GM_getValue() properly?

Thanks.

MobyUtils = {

        apiKeyStorage: "mobypicture.api.key",
        apiKeyCache: '',

        setKey:function(key){
                GM_setValue(this.apiKeyStorage,key);
        },

        getKey: function(){
                return this.apiKeyCache || ( this.apiKeyCache = GM_getValue
(this.apiKeyStorage) );
        },

        getThumbUrl: function(tinyUrlCode, size, format, callback){

                if('function' === typeof size){
                        callback = size;
                        size = null;
                }

                if('function' === typeof format){
                        callback = format;
                        format = null;
                }

                size = size || 'small';
                format = format || 'json';

                url = 'http://api.mobypicture.com/?action=getThumbUrl'
                + '&t=' + encodeURIComponent(tinyUrlCode)
                + '&s=' + size
                + '&k=' + encodeURIComponent(this.getKey())
                + '&format=' + format;

                tFormat = (format == 'plain')?'text':format;

                $.ajax({
                        'url': url,
                        'type': 'GET',
                        'success': function(data, status){callback(data, 
status)},
                        'dataType': tFormat
                });

        }
};
--~--~---------~--~----~------------~-------~--~----~
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