|
Script Summary:
Show a neat preference window for your userscript Version: 1.0.2 |
this script has 2 topics, 9 posts |
this script has 1 review |
||||||||||||||||||||||||
This script was inspired by
"Greasemonkey Shell" by DavidJCobb
http://userscripts.org/scripts/show/45517
Version 1.0.0 can now be @require'd without change.
Description
Darkens the current page and displays a preference window for integer, string, boolean values and arrays. String values can also be grouped into a radio button group using simple arrays. The values are then stored as normal userscript preferences (GM_getValue, GM_setValue ...). The type of each value is determined by its "theDefault" entry. Arrays are stored as JSON strings. Use USP.getValue to get the preference value as it will convert the JSON string into a native array.Usage and Example
The preference window is initialised by calling USP.init with any number of object parameters of this style:{theName:'Name of value to be stored', theText:'Text to be shown in the preference window', theDefault:Value with the type of the preference value to be stored,
OPTIONAL: theValues:['any','number','of','strings'] with theDefault: 'aString'}.
When theValues is given (as an Array) you get an option group and the value will be stored as string.
The following example will produce the screenshot underneath:
1. Put the USP object into your source code OR add a @require to http://userscripts.org/scripts/source/45988.use...
2. Add the following lines to your own script:
USP.theScriptName = 'Testscript';
USP.init({theName:'OneOfMany', theText:'Which values should be displayed?', theValues:['All','None'], theDefault:'All'},
{theName:'intValue', theText:'Integer:', theDefault:100},
{theName:'stringValue', theText:'String:', theDefault:'Testvalue'},
{theName:'boolValue', theText:'Boolean?', theDefault:true}
);
3. Add this line to show a menu entry in the User Script Commands of Greasemonkey:
GM_registerMenuCommand('Preferences for ~'+USP.theScriptName+'~', USP.invoke);
4. Get the preference value with USP.getValue('aName'). You can also use GM_getValue().
Works together with my modified SVC Script Version Checker http://userscripts.org/scripts/show/45989 by calling SVC.versionInfo.manualChecking()






