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. Seeprocess.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. Requiresmin
andmax
properties.val
will be String.select
- Drop-down selector. Requiresoptions
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 iftype
isslider
.max
Number (optional) - Maximum value for slider. Required iftype
isslider
.step
Number (optional) - Granularity that the slider value must adhere to.options
Object (optional) - Options for drop-down selector type. Required iftype
isselect
.[key: String]
String - Option entry. Key will be used asval
, 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 returnsDOMString
. You can set this tofunction () { 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 totrue
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 matchinglocations
andplatforms
. 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