A library to help you set up configure in greasemonkey script.
สคริปต์นี้ไม่ควรถูกติดตั้งโดยตรง มันเป็นคลังสำหรับสคริปต์อื่น ๆ เพื่อบรรจุด้วยคำสั่งเมทา // @require https://update.greasyfork.org/scripts/7212/156587/GM_config%20%28eight%27s%20version%29.js
A library to help you set up configure in greasemonkey script.
This project is a rewrite of sizzlemctwizzle/GM_config and use the interface similar to GM_config (JoeSimmons) (the legacy interface of sizzlemctwizzle/GM_config).
The title of the config dialog.
The definition is a map object look like:
{
key: {
label: "the label of the input",
// input type. could be text, number, checkbox, textarea, radio, or
// select.
type: "text",
// could be String, Number, Boolean, or Array. See following example.
default: "default value"
}
}
Example:
{
text: {
label: "Text field",
type: "text",
default: "a string"
},
number: {
label: "Number field",
type: "number",
default: 12345
},
checkbox: {
label: "Checkbox field",
type: "checkbox",
default: true
},
textarea: {
label: "Textarea field",
type: "textarea",
default: "multi\nline"
},
radio: {
label: "Select your language",
type: "radio",
default: "en",
options: {
en: "English",
tw: "Traditional Chinese",
cn: "Simplified Chinese"
}
},
select: {
label: "Choose a color",
type: "select",
default: "orange",
options: {
red: "Red",
orange: "Orange",
yellow: "Yellow"
}
},
multipleSelect: {
label: "Multiple select",
type: "select",
default: ["n1", "n3"],
options: {
n1: "1",
n2: "2",
n3: "3"
},
multiple: true
}
}
Open config dialog.
If key
is not setted, return a key-value map of the config.
If key
is a string, return the config value of the key.
If key
is an object, copy all properties from the config to the object.
This is a helper function to do a simple setup.
function setup(options, saveCallback) {
GM_config.init(GM_info.script.name, options);
GM_config.onload = loadCallback;
GM_registerMenuCommand(GM_info.script.name + " - Configure", GM_config.open);
saveCallback();
}
Called when the dialog is closed.
true
if the user pressed "Save" button.
Called when the config is saved.
Using NodeJS, Bower, Grunt:
npm install
bower install
grunt
white-space: nowrap
to dialog footer.LGPL version 3 or any later version; http://www.gnu.org/copyleft/lgpl.html
.onload
and .setup
.document.open, document.close
.GM_config.get()
.