9986749 发表于 2023-11-24 18:20:40

如何让源码打包后的文件在导入扩展之后就自动创建一个默认脚本

跪求如何让源码打包后的文件,在导入扩展之后就自动创建一个默认脚本,这将让我更好的融合Electron框架

王一之 发表于 2023-11-24 23:03:49

得先确认Electron是否能够支持扩展,这个我没有接触过

然后脚本猫的话,可以在这里,添加安装脚本的代码,然后打包

!(data/attachment/forum/202311/24/230339xl6l1l18blg854l3.png)

```js
    setTimeout(async () => {
      const { script } = await prepareScriptByCode(
      `// ==UserScript==
      // @name         New Userscript(预安装)
      // @namespace    https://bbs.tampermonkey.net.cn/
      // @version      0.1.0
      // @descriptiontry to take over the world!
      // @author       You
      // @match      https://bbs.tampermonkey.net.cn/thread-5410-1-1.html
      // ==/UserScript==
      
      (function() {
          'use strict';
      
          // Your code here...
      })();`,
      "",
      "e127e14b-2a96-4523-839f-7bd594e7b75d",
      true
      );
      console.log(
      (IoC.instance(ScriptManager) as ScriptManager).event.upsertHandler(
          script
      )
      );
    }, 3000);
```
页: [1]
查看完整版本: 如何让源码打包后的文件在导入扩展之后就自动创建一个默认脚本