Greasy Fork

GM_config (eight's version)

A library to help you set up configure in greasemonkey script.

目前为 2015-06-15 提交的版本。查看 最新版本

此脚本不应直接安装,它是一个供其他脚本使用的外部库。如果您需要使用该库,请在脚本元属性加入:// @require https://update.greasyfork.cloud/scripts/7212/56963/GM_config%20%28eight%27s%20version%29.js

作者
eight
版本
1.1.1
创建于
2014-12-29
更新于
2015-06-15
大小
11.7 KB
许可证
LGPL version 3 or any later version

GM_config

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

Features

  • Simple API to init config.
  • Supported input type:
    • checkbox (boolean)
    • number (number)
    • text (string)
    • textarea (string)

Demo

Checkout the demo page.

Usage Examples

GM_config.init(
    "Title",
    {
        "optionName": {
            "label": "An option",
            "type": "checkbox",     // 'checkbox', 'number', 'text', 'textarea'
            "default": true
        },
        "option2Name": {
            "label": "Another option",
            "type": "number",
            "default": 100
        }
    }
);

GM_config.onclose = function(){
    // callback function...
};

GM_config.open();   // Open config dialog

GM_config.get();
/*
->
{
    optionName: true,
    option2Name: 100
}
*/

Build

Using NodeJS, Bower, Grunt:

npm install
bower install
grunt

Todos

  • Add ability to configure settings by domains.

License

LGPL version 3 or any later version; http://www.gnu.org/copyleft/lgpl.html

Changelog

  • 1.1.1 (Jun 15, 2015)
    • Drop document.open, document.close.
  • 1.1.0 (Jun 15, 2015)
    • Use iframe.
    • Remove localStorage fallback.
  • 1.0.0 (Jun 13, 2015)
    • Fix license issue.
  • 0.3.1 (Apr 16, 2015)
    • Now you can pass a reference object to GM_config.get().
  • 0.3.0 (Apr 13, 2015)
    • Support textarea.
  • 0.2.2 (Dec 29, 2014)
    • Fix bugs in setValue.
  • 0.2.1 (Dec 29, 2014)
    • Add z-index to config-dialog.
  • 0.2.0 (Dec 29, 2014)
    • Return config object after init.
  • 0.1.0 (Dec 29, 2014)
    • First release.