GM_config (eight's version)

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

目前為 2015-08-06 提交的版本,檢視 最新版本

此腳本不應該直接安裝,它是一個供其他腳本使用的函式庫。欲使用本函式庫,請在腳本 metadata 寫上: // @require https://update.cn-greasyfork.org/scripts/7212/66285/GM_config%20%28eight%27s%20version%29.js

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

作者
eight
版本
2.1.0
建立日期
2014-12-29
更新日期
2015-08-06
尺寸
18.3 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) (the legacy interface of sizzlemctwizzle/GM_config).

Features

  • Create a dialog to show, edit settings.
  • Reset settings to default.
  • Save setting depends on different domains.
  • Import, export settings.
    • Note: export function will only grab settings on current domain.
  • Supported input type:
    • checkbox (boolean)
    • number (number)
    • text (string)
    • textarea (string)
    • radio (string)
    • select (string or array)

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

  • Create dialog with htmlString?
  • Add white-space: nowrap to dialog footer.
  • Refactor
    • Pull out createInput from createInputs.
    • Pull out grabDialogSetting from close.

License

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

Changelog

  • 2.1.0 (Aug 7, 2015)
    • Support radio.
    • Support select.
    • Update end2end.
  • 2.0.4 (Jul 3, 2015)
    • Fix dialog container style.
  • 2.0.3 (Jun 18, 2015)
    • Fix dialog footer style.
  • 2.0.2 (Jun 18, 2015)
    • Add license header to source.
  • 2.0.1 (Jun 18, 2015)
    • Update meta data.
  • 2.0.0 (Jun 18, 2015)
    • Change folder structure.
  • 1.3.0 (Jun 18, 2015)
    • Add import, export feature.
    • Add local setting feature.
    • Fix the flickering of opening, closing dialog.
  • 1.2.0 (Jun 15, 2015)
    • Add transition animation.
  • 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.