Greasy Fork 还支持 简体中文。

Tampermonkey Config

Simple Tampermonkey script config library

Tính đến 06-07-2023. Xem phiên bản mới nhất.

Script này sẽ không được không được cài đặt trực tiếp. Nó là một thư viện cho các script khác để bao gồm các chỉ thị meta // @require https://updategf.qytechs.cn/scripts/470224/1216039/Tampermonkey%20Config.js

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install a user script manager extension to install this script.

(Tôi đã có Trình quản lý tập lệnh người dùng, hãy cài đặt nó!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

Tác giả
PRO-2684
Phiên bản
0.2.2
Đã tạo
05-07-2023
Đã cập nhật
06-07-2023
Kích thước
3 KB
Giấy phép
GPL-3.0

🪄 Function

Simple config lib for Tampermonkey scripts.

🤔 Permission

This script needs the following permissions to work:

// @grant        GM_setValue // Save your config
// @grant        GM_getValue // Get your config
// @grant        GM_registerMenuCommand // Register menu
// @grant        GM_unregisterMenuCommand // Update menu

📖 Usage

let config_desc = { // Config description
    password: {
        name: "Password", // Display name
        value: "tmp", // Default value
        processor: (v) => { // Process user inputs, throw error if invalid
            if (v.length < 3) throw "Too short!";
            return v;
        }
    },
    enabled: {
        name: "Enabled",
        value: true,
        processor: GM_config_builtin_processors.boolean // You can use builtin processors
    },
    price: {
        name: "Price",
        value: 10,
        processor: GM_config_builtin_processors.integer(0, 100) // Some builtin processors accept arguments
    },
    foo: {
        name: "Foo",
        value: "bar"
        // You may omit processor if you don't need to validate or process user inputs
    }
}

let config = GM_config(config_desc); // Register menu commands
console.log(config.price); // Start using config as you wish 🎉

⚠️ Note

  • This project is in early development.
  • Avoid modify config values in your script. If you really need to do so, remember to invoke _GM_config_register(config_desc, config); so as to update the displayed menu.