Plugin Remote Code
DANGER
Untrusted remote source will cause security and privacy issues.
❌ DO NOT use untrusted code or remote source.
❌ DO NOT use remote code which is not under your control.
As a required condition, set ALLOW_REMOTE_CODE
to true
in task configure JSON.
Using jiant.parse.plugin
to import remote code in task script.
Set REMOTE_CONFIGURE_FOR_CHECKING
to import remote JSON in task configure.
Import Remote Code in script
jiant.parse.plugin(httpUrl, maxAge, forceReload) -> Promise
Param | Type | Required | Description |
---|---|---|---|
httpUrl | string | ✅ | URL of remote raw string code |
maxAge | number | ❌ | Default: 3600 * 24 . Max age in seconds of local cached value. Minimum value is 60 seconds. |
forceReload | boolean | ❌ | Default: When manually checking and editing task, default value is true . In global continuous checking, default value is false . Whether to ignore local cached value and reload from remote. There is a built-in minimum interval of reloading: 10 seconds. . |
Example
Click Build your own
to open the example in your browser extension.
Important
In configure JSON, ALLOW_REMOTE_CODE
must be true
, otherwise method jiant.parse.plugin
will always throw error.
Import Remote Configure JSON
TIP
The cache and reload rule of remote configure is same to jiant.parse.plugin
default maxAge
and forceReload
.
- Here is an example of remote configure JSON. The URL must return raw JSON in
string
.
// Remote Configure
// https://raw.githubusercontent.com/jiant-ing/jianting-scripts/refs/heads/main/scripts/examples/remoteCode/printPageUrl.json
{
"DISABLE_AUTO_OPEN_PAGE_URL": true,
"customParams": {}
}
- Here is local configure JSON.
ALLOW_REMOTE_CODE
must betrue
, otherwise it will throw error when checking.- Set
REMOTE_CONFIGURE_FOR_CHECKING
with remote confiure JSON URL.
// Local Task Configure JSON
{
"ALLOW_REMOTE_CODE": true,
"DISABLE_AUTO_OPEN_PAGE_URL": false,
"ALLOW_PARSED_ITEMS_EMPTY": true,
"REMOTE_CONFIGURE_FOR_CHECKING": "https://raw.githubusercontent.com/jiant-ing/jianting-scripts/refs/heads/main/scripts/examples/remoteCode/printPageUrl.json",
}
- At the start of running the task, the remote configure will merge and override the local one for checking.
In this example, DISABLE_AUTO_OPEN_PAGE_URL
is true
in remote and overrides local value.
// Merged and overrided
{
"ALLOW_REMOTE_CODE": true,
"DISABLE_AUTO_OPEN_PAGE_URL": false,
"DISABLE_AUTO_OPEN_PAGE_URL": true,
"ALLOW_PARSED_ITEMS_EMPTY": true,
"REMOTE_CONFIGURE_FOR_CHECKING": "https://raw.githubusercontent.com/jiant-ing/jianting-scripts/refs/heads/main/scripts/examples/remoteCode/printPageUrl.json",
"customParams": {}
}
Fetch Your Remote Code with Authentication
If you want to keep your remote code private, set HEADER_VALUE_FETCHING_REMOTE_CODE
of customParams
in configure JSON.
When fetching remote code, the request headers
will always take HEADER_VALUE_FETCHING_REMOTE_CODE
value of key: X-Jiant-Plugin-Auth
which can be verified by server.
With following example code, when fetching REMOTE_CONFIGURE_FOR_CHECKING
or jiant.parse.plugin
, the request headers
will always contain X-Jiant-Plugin-Auth: VALUE_FOR_AUTH
.
{
"customParams": {
"private": true,
"HEADER_VALUE_FETCHING_REMOTE_CODE": "VALUE_FOR_AUTH"
},
"ALLOW_REMOTE_CODE": true,
"REMOTE_CONFIGURE_FOR_CHECKING": "https://example.yourserver.com/api1/configure.json"
}