diff --git a/README.md b/README.md index 926cc78..dc1b7e8 100644 --- a/README.md +++ b/README.md @@ -8,6 +8,13 @@ [![GitHub Downloads (all assets, all releases)](https://img.shields.io/github/downloads/PRO-2684/Scriptio/total?logo=github)](https://github.com/PRO-2684/Scriptio/releases) [![GitHub Downloads (all assets, latest release)](https://img.shields.io/github/downloads/PRO-2684/Scriptio/latest/total?logo=github)](https://github.com/PRO-2684/Scriptio/releases/latest) +> [!NOTE] +> 若需在 LiteLoaderQQNT 中使用此插件,需要修改 [框架的白名单代码](https://github.com/LiteLoaderQQNT/LiteLoaderQQNT/blob/9628031664e9d3df35834f373cd5456f92ea250a/src/main/api.js#L45-L51),使得 Scriptio 能够读取 LiteLoader 对象。 +> +> 具体来说,对于 CJS `require`,error stack 会使用正常的平台路径,例如 `D:\LiteLoader\plugins\plugininstaller\dist\main.js:16:362331`;但是此插件使用了 ESM `import`,因此 error stack 中的路径会被转换为 `file:///D:/LiteLoader/plugins/Scriptio/modules/loaders/unified.js:3:38`,从而导致框架的白名单代码无法正确识别路径。 +> +> [此 PR 中对 `whitelist` 的修改](https://github.com/LiteLoaderQQNT/LiteLoaderQQNT/commit/7575d7b3b0576d4a5f08c425e67b89fa6846944c#diff-1baf6e1c82a8708570aa947887a99298911bec4554ae8acae3aa92eae21aafcd) 可能对您有所帮助。 + [LiteLoaderQQNT](https://github.com/mo-jinran/LiteLoaderQQNT) / QwQNT 插件,用于为 QQNT 加载任意 **渲染层** 的用户脚本。 你可能也感兴趣:[Transitio](https://github.com/PRO-2684/transitio),自定义用户样式加载器。 diff --git a/main.cjs b/main.cjs new file mode 100644 index 0000000..7cb9397 --- /dev/null +++ b/main.cjs @@ -0,0 +1,3 @@ +(async () => { + await import("./main.js"); +})(); diff --git a/manifest.json b/manifest.json index 7bb28f7..6e2b646 100644 --- a/manifest.json +++ b/manifest.json @@ -2,7 +2,6 @@ "$schema": "./manifest.schema.json", "manifest_version": 4, "type": "extension", - "esm": true, "name": "Scriptio", "slug": "scriptio", "description": "📄 自定义用户脚本加载器", @@ -31,7 +30,7 @@ "platform": ["win32", "linux", "darwin"], "injects": { "renderer": "./renderer.js", - "main": "./main.js", + "main": "./main.cjs", "preload": "./preload.js" } } diff --git a/modules/loaders/unified.js b/modules/loaders/unified.js index 58d83a2..6bb4a5f 100644 --- a/modules/loaders/unified.js +++ b/modules/loaders/unified.js @@ -1,8 +1,9 @@ // Unified API for LiteLoader & QwQNT, main & renderer -const { dataPathOrig, pluginPathOrig, scriptioVersion, configApi } = globalThis.LiteLoader ? - await import("./liteloader.js") : - await import("./qwqnt.js"); +const { dataPathOrig, pluginPathOrig, scriptioVersion, configApi } = + globalThis.LiteLoader + ? await import("./liteloader.js") + : await import("./qwqnt.js"); /** Scriptio data path, normalized to use `/`, ending with `/` */ const dataPath = normalize(dataPathOrig) + "/"; /** Scriptio script path, normalized to use `/`, ending with `/` */ @@ -27,4 +28,4 @@ export { /** Should only be used in main */ configApi, normalize, -} +};