Skip to content

Rewriter Api

GL.rewriter

The rewriter API allows you to modify the bundled code of Gimkit in order to expose values or change certain behaviors. Due to the unpredictable nature of bundling, you cannot assume that variable names will remain the same beteen updates.

Methods

addParseHook()

addParseHook(pluginName, prefix, callback): () => void

Creates a hook that will modify the code of a script before it is run. This value is cached, so this hook may not run on subsequent page loads. addParseHook should always be called in the top level of a script.

Parameters

ParameterTypeDescription
pluginNamestringThe name of the plugin creating the hook.
prefixstring | booleanLimits the hook to only running on scripts beginning with this prefix. Passing true will only run on the index script, and passing false will run on all scripts.
callback(code) => stringThe function that will modify the code. Should return the modified code. Cannot have side effects.

Returns

Function

Returns

void


createShared()

createShared(pluginName, id, value): string

Creates a shared value that can be accessed from any script.

Parameters

ParameterTypeDescription
pluginNamestringThe name of the plugin creating the shared value.
idstringA unique identifier for the shared value.
valueanyThe value to be shared.

Returns

string

A string representing the code to access the shared value.


removeParseHooks()

removeParseHooks(pluginName): void

Removes all hooks created by a certain plugin

Parameters

ParameterType
pluginNamestring

Returns

void


removeShared()

removeShared(pluginName): void

Removes all values created by createShared by a certain plugin

Parameters

ParameterType
pluginNamestring

Returns

void


removeSharedById()

removeSharedById(pluginName, id): void

Removes the shared value with a certain id created by createShared

Parameters

ParameterType
pluginNamestring
idstring

Returns

void