[2023/09/18: ③] Add prework.

New `game.import` uses `document.currentScript` to determine the code caller.

If the script is not `game.js`, we put the result to `_status` for `game.js` to wait, otherwise return the promise directly.
This commit is contained in:
Rintim 2023-09-18 17:49:05 +08:00
parent 76e058159f
commit 9ac2a0b146
1 changed files with 5 additions and 2 deletions

View File

@ -29,6 +29,7 @@
}
}
}
const GameJS=document.currentScript;
const GeneratorFunction=(function*(){}).constructor;
// gnc: GeNCoroutine
const gnc={
@ -166,6 +167,8 @@
hook:{globaltrigger:{},globalskill:{}},
//函数钩子
hooks:{
// getCurrentScript用到的接口
_getCurrentScript:()=>null,
// 本体势力的颜色
addGroup:[(id,_short,_name,config)=>{
if("color" in config&&config.color!=null){
@ -32578,8 +32581,8 @@
'妹子,交个朋友吧',
],
other:{
bool:(item)=>Boolean(item),
ignore:()=>{}
getCurrentScript:()=>document.currentScript||lib.hooks._getCurrentScript(),
ignore:()=>void 0
}
};
const game={