Configuration Dialog

A enhanced configuration dialog for Userscripts.

이 스크립트는 직접 설치해서 쓰는 게 아닙니다. 다른 스크립트가 메타 명령 // @require https://update.greasyfork.org/scripts/45343/759338/Configuration%20Dialog.js(으)로 포함하여 쓰는 라이브러리입니다.

질문, 리뷰하거나, 이 스크립트를 신고하세요.
개발자
Devy
버전
0.0.1.20191220072345
생성
2018-04-30
갱신
2019-12-20
라이선스
없음

Configuration dialog for Grease- and Tampermonkey Userscripts.

More information

Requirements

  • // @grant GM_getValue
  • // @grant GM_setValue
  • JQuery 2.1.1+

Configuration Example

{
    'title': 'Test Window', //Title of the window
    'id': 'settings_window', //ID of the window div

    "theme": "mac/win10/winXP", //Select a theme for the window
    'theme_selector': true, //Show Theme-Selector
    'theme_section_color': true, //Section color matches the window style

    "height": "75", //Initial height in percent
    "width": "75", //Initial width in percent

    'confirm_close': "Ungespeicherte Änderungen. Wirklich verwerfen?", //Confirm message on dialog close without having saved
    'confirm_revert': "Alle Änderungen verwerfen?", //Confirm message for reseting the current changes
    'confirm_reset': "Einstellungen auf Standard zurücksetzen?", //Confirm message for factory reset

    "top": {
        "minimize": "true", //Option to show minimize button
        "maximize": "true", //Option to show maximize button
        "close": "true" //Option to show close button
    },

    "font": {
        "size": "18px",  //Font size of content
        "family": "Consolas" //Font family of content
    },

    "savebutton": "true",  //Display of save button
    "revertbutton": "true", //Display of revert button
    "completeresetbutton": "true", //Display of factory reset button

    'content':
    [
        {
            "type": "p",
            "label": "This is just a normal Text."
        },
        {
            "type": "h1",
            "label": "This ist just a normal header."
        },
        {
            "type": "section",
            "label": "I'm a section",
            "collapsible": true,    //If section should be collapsible
            "collapsed": false      //If section should be collapsed by default
        },
        {
            "type": "subsection",
            "label": "I'm a subsection"
            "collapsible": true,    //If subsection should be collapsible
            "collapsed": false      //If subsection should be collapsed by default
        },
        {
            "label": "Text input field",
            "type": "input",
            "id": "username",
            "default": "default name"
        },
        {
            "label": "Checkbox",
            "type": "checkbox",
            "id": "checkbox",
            "default": false
        },
        {
            "type": "subsection",
            "label": "I'm a subsection"
        },
        {
            "label": "Dropdown field",
            "type": "select",
            "id": "selection",
            "options": [ "Pizza", "Pasta", "Cookies", "Döner" ],
            "default": "Cookies",
            "require": "checkbox"   //Requires the checkbox "checkbox" to be checked, otherwise it gets disabled
        },
        {
            "label": "Numeric field",
            "type": "numeric",
            "id": "numeric",
            "default": "0",
            "min": "10",
            "max": "40"
        },
        {
            "label": "Color field",
            "type": "color",
            "id": "color",
            "default": "#000000"
        },
    ]
}

Load a Configuration

configurationWindow.create( <JSON CODE> );

Show Configuration Window

configurationWindow.open();

Open Configuration Window via the context menu

  • // @grant GM_registerMenuCommand
GM_registerMenuCommand("Menu Item Name", function() { configurationWindow.open(); });