script only modifies the current configuration copy and does not directly modify the original subscription text.
生成一个符合 YumeBox 运行时约束的 JavaScript 覆写
Execution process
1
Initialize runtime
Initializes the JavaScript runtime and built-in methods the first time a
.js file appears in the current override chain.2
Pass in configuration object
The current configuration is converted to a JavaScript object and passed in as the
profile parameter.3
execute main
The script can modify
profile directly or return a new configuration object. Both synchronous return values and completed Promises are supported.4
Check return value
The return value must be convertible to a JSON object. Script errors, missing
main, or returning non-object values will stop the current override chain.main, variables, and declarations of the previous script are not leaked to the next script.
main(profile)
Minimal script
最小覆写.js
Modify fields
修改字段.js
expected diff
修改字段 diff.js
// [!code --] and // [!code ++] are only used for diff display in documentation and are legal JavaScript comments themselves.
Condition modification
按模式修改.js
Asynchronous script
异步 main.js
async main(profile) did not settle when it is pending.
Return value requirements
Error example:
错误的返回值.js
profile.rules is an array, the script will fail instead of continuing with the array as a complete configuration.