Making a userscript - idkr-client/idkr GitHub Wiki

How userscripts are loaded

Userscripts are loaded with Node's require() from a renderer process.

Export object structure

  • name String (optional) - Name of the script.
  • description String (optional) - Description of the script.
  • version String (optional) - Version of the script.
  • Author String (optional) - Name of the author.
  • locations String[] (optional)- Types of windows the script should run. Valid string values are 'all' | 'docs' | 'game' | 'social' | 'viewer' | 'editor'. Defaults to ['all'].
  • platforms String[] (optional) - Platforms the script should run on. See process.platform for valid values. ['all'] is also accepted. Defaults to ['all'].
  • settings Object (optional) - Additional setting entries. Settings will be added under "idkr" tab.
    • [key: String] Object - Setting entry.
      • name String - Name of the setting.
      • id String - ID of the setting.
      • cat String - Category of the setting entry. Adjacent settings with the same category will be grouped.
      • type String - Type of setting. Valid values are:
        • checkbox - Toggle switch. val will be Boolean.
        • slider - Slider. Requires min and max properties. val will be String.
        • select - Drop-down selector. Requires options property. val will be String.
        • text - Text input. val will be String.
      • val - Default value of the setting.
      • min Number (optional) - Minimum value for slider. Required if type is slider.
      • max Number (optional) - Maximum value for slider. Required if type is slider.
      • step Number (optional) - Granularity that the slider value must adhere to.
      • options Object (optional) - Options for drop-down selector type. Required if type is select.
        • [key: String] String - Option entry. Key will be used as val, and value will be visible to users as a label of the option.
      • placeholder String (optional) - Placeholder text for text input type.
      • html Function - Function that returns DOMString. You can set this to function () { return window.clientUtil.genCSettingsHTML(this) } for a basic behavior.
      • set Function (optional) - Function that gets called when new value is set. Also called when initiating the setting.
        • value - New value.
        • init Boolean - Indicates if this function is called when initiating the settings.
      • needsRestart Boolean (optional) - Set to true if the settings need the page to be refreshed or the client to be restarted.
      • info String (optional) - Tooltip text that appears when the user hovers over the setting entry.
  • run Function (optional) - Function that gets called if loaded with matching locations and platforms. You should write your main code here.
    • config Store - electron-store instance object. Can be used to get and set option values.

External resources

Discord Server

You can join idkr Discord to find userscripts in the #userscripts channel.

Built-in settings

https://github.com/Mixaz017/idkr/blob/master/app/exports/settings.js