Greasy Fork is available in English.

Furaffinity-Custom-Settings

Library to create Custom settings on Furaffinitiy

此腳本不應該直接安裝,它是一個供其他腳本使用的函式庫。欲使用本函式庫,請在腳本 metadata 寫上: // @require https://update.greasyfork.org/scripts/475041/1531083/Furaffinity-Custom-Settings.js

作者
Midori Tsume
版本
4.1.1
建立日期
2023-09-11
更新日期
2025-02-03
尺寸
46.3 KB
授權條款
MIT

Furaffinity Custom Settings

Helper Script to create Custom settings on Furaffinitiy. Also see docs on Furaffinity-Custom-Settings

How to use

  • @require this script
  • Create Settings Object:

    const customSettings = new FACustomSettings(); // Multiple Settings Pages can be created
    customSettings.provider = "Midori's Script Settings"; // Change Navigation Settings Name
    customSettings.headerName = "My Script Settings"; // Change the Settings Header Name
    

    See Settings for more info

  • Create a new Setting:

    const setting = CustomSettings.newSetting(SettingType, "Setting Name");
    setting.description = "Setting Description";
    setting.defaultValue = DefaultValue;
    setting.inInput = (target) => { doSomething(); }; // For Action Settings when clicked otherwise every time the Setting is changed
    setting.addEventListener("input", (target) => { doSomthing(); }); // Alternative to onInput
    setting.verifyRegex = /Regex/; // For Text Settings only
    

    See Settings for more info

  • Trigger when settings should be loaded:

    CustomSettings.loadSettingsMenu(); //loads Navigation Menu & Settings if on Settings Page
    

Feature Roadmap

Feature Status
Create new Settings and easily access Settings change ⠀⠀⠀⠀ ✅ Completed
Have different Setting Types ✅ Completed
⠀⠀⠀⠀Number (TextField that only allows Numbers) ✅ Completed
⠀⠀⠀⠀Boolean (Checkbox with a description) ✅ Completed
⠀⠀⠀⠀Action (Button with a description) ✅ Completed
⠀⠀⠀⠀Text (TextField that allow any Characters) ✅ Completed
Change Settings Page Name and Header Name ✅ Completed
Have multiple different Setting Pages ✅ Completed

Documentation

Setting

The Setting class contains following Properties:

  • id - Can only be set once. Defines the Setting elements html id. Is set to setting Name, if not set manually.
  • name - Name of the Setting.
  • description - Description of the Setting.
  • type - Type of the Setting. (See SettingType for more info)
  • defaultValue - Default value for the Setting. (Is ignored on SettingTypes.Action)
  • action - Action that is executed when the Setting changes. (See Action for more info)
  • value - Current value of the Setting.

  • min - Minimum value for SettingType.Number
  • max - Maximum value for SettingType.Number
  • step - Step value for SettingType.Number

  • verifyRegex - Regex for validation of input for SettingType.Text

SettingType

SettingType can have the following values:

  • SettingType.Number - A TextField that only accepts Numbers. (Enables min, max, step)
  • SettingType.Text - A TextField that allows any Character. (Enables verifyRegex)
  • SettingType.Boolean - A Checkbox with a description.
  • SettingType.Action - A Button with a certain Action. (Value returns the name)

Input

The onInput Property defines a Function that is executed when the Setting changed. It receives the Settings Element as a Parameter. It can also be used with addEventListener. Example:

customSetting.onInput = (target) => {
  console.log(target.value); // Target is the HTML Element of the Setting
};
customSetting.addEventListener("input", (target) => {
  console.log(target.value);
});

Here every time the Checkbox is clicked the program prints out wether it is checked or not.