$Config

Allows end users to configure scripts.

目前為 2022-08-13 提交的版本,檢視 最新版本

此腳本不應該直接安裝,它是一個供其他腳本使用的函式庫。欲使用本函式庫,請在腳本 metadata 寫上: // @require https://update.gf.qytechs.cn/scripts/446506/1081059/%24Config.js

作者
ctl2
版本
0.0.1.20220813095626
建立日期
2022-06-15
更新日期
2022-08-13
尺寸
14.7 KB
授權條款
未知

See config editor demo here

Images are attached below to describe constructor parameters.

Usage

const $config = new $Config(
    ([node0, node1, node2]) => {
        const config = {};
        // ...
        return config;
    },
    'STORAGE_KEY',
    {
        'children': [
            {'label': 'node0'},
            {'label': 'node1'},
            {'label': 'node2'}
        ]
    },
    'Example Title'
);

function useConfig() {
    const config = $config.get();

    // ...
}

$config.init()
    .catch(({message}) => {
        window.alert(message);
    })
    .then(useConfig);

const button = document.createElement('button');

// ...

button.addEventListener('click', () => {
    $config.edit()
        .catch(({message}) => {
            if (window.confirm(`${message}\n\nWould you like to erase your data?`)) {
                $config.reset();
            }
        })
        .finally(useConfig);
});

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址