Greasy Fork is available in English.

Furaffinity-Custom-Settings

Helper Script to create Custom settings on Furaffinitiy

Этот скрипт недоступен для установки пользователем. Он является библиотекой, которая подключается к другим скриптам мета-ключом // @require https://update.greasyfork.org/scripts/475041/1267274/Furaffinity-Custom-Settings.js

Автор
Midori Tsume
Версия
4.0.13
Создан
11.09.2023
Обновлён
19.10.2023
Лицензия
MIT

Furaffinity Custom Settings

Helper Script to create Custom settings on Furaffinitiy

How to use

  • @require this script

  • Optional: Change Extension Settings Header Name at any Point in your Code: CustomSettings.name = "Extension Settings";
    (Defines the Navigation Header Name)

  • Optional: Change Extension Settings Name at any Point in your Code: CustomSettings.provider = "Midori's Script Settings";
    (Defines the actual Navigation Points Name)

  • Optional: Change the Settings Header Name: CustomSettings.headerName = "My Script Settings";

  • Create a new Setting: const setting = CustomSettings.newSetting("Setting Name", "Setting Description", SettingType, "Type Description", DefaultValue, Action);
    See Setting for more info

  • Trigger when settings should be loaded: CustomSettings.loadSettings();

  • Optional: Create a whole new Settings Page: const AnotherCustomSettings = new Settings();
    Next steps are the same as above. (If Name is indentical between multiple Settings it serves as a Header for the multiple subpages)

Features

  • Create new Settings and easily access Settings change
  • Have different Setting Types
    • Number (TextField that only allowes Numbers)
    • Text (TextField that allows any Character)
    • Boolean (Checkbox with a description)
    • Action (Button with a description)
  • Change Settings Page Name and Header Name
  • Have multiple different Setting Pages

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. (Also defines Settings Header name)
  • description - Description of the Setting.
  • type - Type of the Setting. (See SettingTypes for more info)
  • typeDescription - Description of the Setting element itself. (Doesn't apply on SettingTypes.Number)
  • 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.

SettingTypes

SettingTypes can have the following values:

  • SettingTypes.Number - A TextField that only accepts Numbers (Type Description doesn't apply here)
  • SettingsTypes.Text - A TextField that allows any Character (Type Description doesn't apply here)
  • SettingTypes.Boolean - A Checkbox with a description
  • SettingTypes.Action - A Button with a certain Action

Action

The Action Parameter defines a Function that is executed when the Setting changed. It receives the Settings Element as a Parameter. Example:

new Setting("Name", "Description", SettingTypes.Boolean, "Checkbox Description", false, (target) => {
  console.log(target.checked); // In this case target is a Checkbox
});

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