Skip to content

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

ParamTypeRequiredDescription
httpUrlstringURL of remote raw string code
maxAgenumberDefault: 3600 * 24. Max age in seconds of local cached value. Minimum value is 60 seconds.
forceReloadbooleanDefault: 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.

RSS Feed Example:
hidden

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.

  1. Here is an example of remote configure JSON. The URL must return raw JSON in string.
text
// 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": {}
}
  1. Here is local configure JSON.
JSON
// 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",
}
  1. 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.

JSON
// 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.

JSON
{
    "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"
}