From 9ac2a0b1465c00649c30244527c7e2edab10426a Mon Sep 17 00:00:00 2001 From: Rintim Date: Mon, 18 Sep 2023 17:49:05 +0800 Subject: [PATCH] =?UTF-8?q?[2023/09/18:=20=E2=91=A2]=20Add=20prework.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- game/game.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/game/game.js b/game/game.js index 47b1ee89f..439b9c543 100644 --- a/game/game.js +++ b/game/game.js @@ -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={