Question

I'm trying to get a fairly simple script which persists a value and retrieves it in the successor to GreaseMonkey: Scriptish.

Browser: Firefox 9.0
Scriptish: 0.1.7
On Windows 7 Ultimate 64-bit

// ==UserScript==
// @id             testSerialization
// @name           Test Serialization
// @version        1.0
// @namespace      com.mobilvox.com
// @author         
// @description    
// @include        http://www.google.com/
// @run-at         document-end
// ==/UserScript==

GM_setValue("isCurrent", true);
GM_log("Is this script current? " + GM_getValue("isCurrent", false));

When I run it I get:

[10:29:59.074] GM_setValue is not defined
@Scratchpad:29
 @ Scratchpad:29
Was it helpful?

Solution

This looks like a possible bug, see related bugs like "GM_setValue not working".

Possible actions:

  1. Firefox 9 is getting obsolete. Upgrade to FF 12 or FF 13 and see if the problem persists.
  2. File a bug report for Scriptish.

OTHER TIPS

I have a complete working code with jQuery and GM_ codes. Try this:

// ==UserScript==
// @name           GM_ debug script
// @description    checking GM_setValue and GM_getValue with jQuery
// @namespace      eaposztrof
// @include        *
// @require     http://code.jquery.com/jquery-1.9.1.js
// @grant       GM_getValue // [grants][1]
// @grant       GM_setValue
// ==/UserScript==

function GM_getValueUTF8(key) { // UTF8 safe
    var value = GM_getValue(key);
    return (value && value.length) ? decodeURI(value) : '';
}

function GM_setValueUTF8(key, value) {
    GM_setValue(key, encodeURI(value));
}

    GM_setValueUTF8('asd','GM_setValue, GM_getValue working! press [Alt+X] to check with jQuery');
    alert(GM_getValueUTF8('asd'));

(function (){
    this.$ = this.jQuery = jQuery.noConflict(true);

    $(document).ready(function () {

        $ (document).keydown (function (e) {
            switch (e.keyCode) {
                case 88:    // "x"
                    if (e.altKey) {
                        setTimeout(function() { // [workaround][2]
                            GM_setValueUTF8('asd','GM_setValue, GM_getValue working inside jQuery');
                            alert(GM_getValueUTF8('asd'));
                        }, 0);
                    }
            }
        });
    });
}
//
) ();
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top