一个轻量级的脚本注入管理系统,类似油猴(Tampermonkey),用于内部系统的前端自定义扩展。
* 通配符)自动注入脚本go build -o script-injector . ./script-injector
服务默认监听 http://localhost:8080
http://localhost:8080/admin?token=你的用户标识
在管理页面可以:
在目标页面添加一行代码即可自动加载匹配的脚本:
<script src="http://localhost:8080/api/loader.js?token=用户标识" defer></script>
| 规则示例 | 说明 |
|---|---|
https://example.com/* | 匹配 example.com 下所有页面 |
https://example.com/app/* | 匹配 /app/ 路径下所有页面 |
*://example.com/* | 匹配 http 和 https |
* | 匹配所有页面 |
| 方法 | 路径 | 说明 |
|---|---|---|
| GET | /api/scripts?token=xxx | 获取脚本列表 |
| POST | /api/scripts?token=xxx | 创建脚本 |
| PUT | /api/scripts/:id?token=xxx | 更新脚本 |
| DELETE | /api/scripts/:id?token=xxx | 删除脚本 |
| GET | /api/loader.js?token=xxx | 动态脚本加载器 |
| GET | /admin?token=xxx | 管理页面 |
├── main.go # 程序入口 ├── database.go # SQLite 数据库操作 ├── handlers.go # HTTP 处理函数 ├── static/ # 静态资源(jQuery、Monaco Editor) └── templates/ # HTML 模板