Skip to content

Commit a1ff258

Browse files
chore: 整理仓库结构,新增文档系统,bump 版本测试 webhook 同步
- 删除 ASMR/ 历史遗留文件夹 - 修复 autoclick/bilibili-block meta.ts 中的 downloadURL/updateURL(改为构建自动注入) - 修正 bilibili-block greasyforkId: 467384 → 497929 - 新增 scripts/docs.ts 文档构建(README + changelog 拼接) - 新增 CONTRIBUTING.md 开发指南 - 重写 readme.md(脚本列表 + 安装链接) - 为每个脚本添加 README.md(基于 GreasyFork 现有描述) - 所有脚本 version bump +0.0.1(测试 GreasyFork webhook 同步)
1 parent eccaad5 commit a1ff258

30 files changed

Lines changed: 425 additions & 2728 deletions

File tree

ASMR/批量打开网站/openUrl.bat

Lines changed: 0 additions & 30 deletions
This file was deleted.

ASMR/批量打开网站/urls.txt

Lines changed: 0 additions & 19 deletions
This file was deleted.

ASMR/文件夹处理/combineFolder.bat

Lines changed: 0 additions & 18 deletions
This file was deleted.

ASMR/文件夹处理/getFolderName.bat

Lines changed: 0 additions & 4 deletions
This file was deleted.

ASMR/文件夹处理/list.md

Lines changed: 0 additions & 2592 deletions
This file was deleted.

ASMR/文件夹处理/list.txt

Lines changed: 0 additions & 2 deletions
This file was deleted.

CONTRIBUTING.md

Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
# 开发指南
2+
3+
## 项目结构
4+
5+
```
6+
├── src/ # 脚本源码
7+
│ ├── {script-name}/ # 每个脚本一个文件夹
8+
│ │ ├── meta.ts # 脚本配置(构建模式、UserScript header)
9+
│ │ ├── index.ts # 入口文件
10+
│ │ ├── README.md # 脚本说明(同步到 GreasyFork)
11+
│ │ └── changelog/ # 版本更新日志
12+
│ │ └── v1.0.md
13+
│ └── shared/ # 共享代码和类型定义
14+
├── scripts/ # 构建工具
15+
│ ├── build.ts # 主构建脚本
16+
│ ├── docs.ts # 文档生成
17+
│ └── manifest.ts # 同步清单生成
18+
├── .github/workflows/ # CI/CD
19+
│ └── publish.yml # 自动构建 + 部署到 GitHub Pages
20+
├── readme.md # 项目说明(面向用户)
21+
└── CONTRIBUTING.md # 本文件
22+
```
23+
24+
## 添加新脚本
25+
26+
1.`src/` 下创建新文件夹(使用 kebab-case 命名)
27+
2. 创建 `meta.ts`,定义脚本配置:
28+
29+
```ts
30+
import { defineConfig } from '../shared/define';
31+
32+
export default defineConfig({
33+
meta: {
34+
name: '脚本名称',
35+
namespace: 'https://github.com/XiaoLinXiaoZhu/JavaScriptTools',
36+
version: '0.1',
37+
description: '脚本描述',
38+
author: 'XLXZ',
39+
match: 'https://example.com/*',
40+
grant: 'none',
41+
license: 'MIT',
42+
},
43+
category: 'tools', // 决定 dist/{category}/ 输出路径
44+
});
45+
```
46+
47+
3. 创建 `index.ts` 作为入口文件
48+
4. (可选)创建 `README.md``changelog/` 用于文档同步
49+
50+
### 构建模式
51+
52+
- `userscript`(默认):油猴脚本,IIFE 格式 + UserScript header
53+
- `plain`:纯 JS 输出,无 header(适用于 Obsidian 等)
54+
- `node`:Node.js 模块,支持 external dependencies
55+
56+
## 文档约定
57+
58+
每个脚本可以有自己的文档,会在构建时生成并部署到 GitHub Pages,用于 GreasyFork 同步。
59+
60+
### README.md
61+
62+
脚本目录下的 `README.md` 支持 `{{changelog}}` 占位符,构建时会自动替换为 changelog 内容。
63+
64+
### changelog/
65+
66+
更新日志以独立 markdown 文件存放在 `changelog/` 文件夹下:
67+
68+
```
69+
src/my-script/changelog/
70+
├── v1.2.md
71+
├── v1.1.md
72+
└── v1.0.md
73+
```
74+
75+
每个文件内容格式:
76+
77+
```markdown
78+
### v1.2
79+
80+
- 新增了某功能
81+
- 修复了某 bug
82+
```
83+
84+
构建时按版本号降序拼接,替换 README.md 中的 `{{changelog}}`
85+
86+
也支持使用单文件 `CHANGELOG.md` 替代文件夹方式。
87+
88+
## 常用命令
89+
90+
```bash
91+
npm run build # 构建所有脚本到 dist/
92+
npm run build:watch # 监听模式,修改后自动重建
93+
npm run typecheck # TypeScript 类型检查
94+
npm run manifest # 生成 sync-manifest.json
95+
npm run clean # 清理 dist/
96+
```
97+
98+
## 发布流程
99+
100+
1. 修改脚本代码
101+
2.`meta.ts` 中 bump `version` 字段
102+
3.`changelog/` 下添加新版本的 `.md` 文件
103+
4. Push 到 `main` 分支
104+
5. CI 自动执行:typecheck → build → 部署到 gh-pages
105+
6. GitHub webhook 通知 GreasyFork → 自动同步更新
106+
107+
### GreasyFork 同步配置
108+
109+
每个发布到 GreasyFork 的脚本需要在 GreasyFork 后台设置:
110+
111+
- **Sync URL**`https://raw.githubusercontent.com/XiaoLinXiaoZhu/JavaScriptTools/gh-pages/{category}/{script-name}.user.js`
112+
- **附加信息 URL**`https://raw.githubusercontent.com/XiaoLinXiaoZhu/JavaScriptTools/gh-pages/{category}/{script-name}.md`
113+
114+
Webhook 已配置,push 到仓库后 GreasyFork 会即时同步。
115+
116+
## URL 规则
117+
118+
- **GitHub Pages**(用户安装):`https://xiaolinxiaozhu.github.io/JavaScriptTools/{category}/{script-name}.user.js`
119+
- **Raw GitHub**(GreasyFork 同步):`https://raw.githubusercontent.com/XiaoLinXiaoZhu/JavaScriptTools/gh-pages/{category}/{script-name}.user.js`
120+
- 构建系统会自动将 GitHub Pages URL 注入为 `@downloadURL``@updateURL`(无需手写)

readme.md

Lines changed: 40 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,40 @@
1-
# 项目名称
2-
3-
## 简介
4-
5-
这是一个用于存放自己写的一些脚本的仓库,主要是用于存放自己写的一些油猴脚本,以及一些其他的脚本。主要语言为JavaScript。
6-
7-
8-
## 使用方法
9-
10-
### 油猴脚本
11-
12-
1. 首先,确保你的浏览器已经安装了油猴插件。你可以在浏览器的插件商店中搜索"油猴",然后点击安装。
13-
14-
2. 打开你想要安装油猴脚本的网页。
15-
16-
3. 在浏览器的工具栏中,点击油猴插件的图标,打开油猴脚本管理界面。
17-
18-
4. 在油猴脚本管理界面中,点击"新建脚本"按钮。
19-
20-
5. 在弹出的编辑器中,粘贴你想要安装的油猴脚本代码。
21-
22-
6. 点击保存按钮,保存脚本。
23-
24-
7. 刷新你想要应用脚本的网页,脚本将会自动生效。
25-
26-
现在,你已经成功安装了油猴脚本!享受它带来的便利吧!
27-
28-
我的大部分油猴脚本都同时发布在了Greasy Fork上,你可以在这里找到它们,使用这个安装和更新会方便很多:[Greasy Fork](https://greasyfork.org/zh-CN/users/1211126-xiaolinxiaozhu)
29-
30-
### npm 包
31-
32-
这些工具是针对于 hexo 博客的图片重定向的,很抱歉,我不知道该如何将其发布到npm,所以不能直接使用npm安装,你可以直接下载源码,然后使用`npm install`安装依赖,然后使用`npm run build`构建,最后使用`npm link`将其链接到全局,这样你就可以在任何地方使用这些工具了。
33-
34-
35-
36-
## 功能列表
37-
- HUST华中科技大学军理线上作业简易自动填充助手.user.js 用于华中科技大学军理线上作业的自动填充
38-
- AutoTool_DownloadASMR.user.js 用于下载ASMR网站的音频
39-
- 屏蔽B站营销视频和推广视频.js 用于屏蔽B站营销视频和推广视频
40-
- hexo-image-redirect 用于hexo博客的图片重定向(因为我不知到该如何将其发布到npm,所以只能放在这里了)
41-
42-
43-
## 许可证
44-
MIT许可证
45-
46-
47-
1+
# JavaScriptTools
2+
3+
个人脚本集合,主要是油猴脚本(UserScript),也包含一些 Obsidian 插件和 Node.js 工具。
4+
5+
## 脚本列表
6+
7+
### 油猴脚本
8+
9+
| 脚本 | 说明 | 安装 |
10+
|------|------|------|
11+
| [屏蔽B站营销视频](src/bilibili-block/) | 屏蔽 B 站主页推荐的营销/推广视频卡片 | [GreasyFork](https://greasyfork.org/scripts/467384) \| [GitHub](https://xiaolinxiaozhu.github.io/JavaScriptTools/bilibili/bilibili-block.user.js) |
12+
| [ASMR 自动下载](src/asmr-download/) | 自动下载 ASMR 网站音频 | [GitHub](https://xiaolinxiaozhu.github.io/JavaScriptTools/tools/asmr-download.user.js) |
13+
| [AutoTool Download](src/autoclick/) | 匹配特殊内容并模拟点击下载 | [GitHub](https://xiaolinxiaozhu.github.io/JavaScriptTools/tools/autoclick.user.js) |
14+
| [动画疯自动脚本](src/bahamut-auto/) | 自动跳过广告、同意年龄确认 | [GitHub](https://xiaolinxiaozhu.github.io/JavaScriptTools/entertainment/bahamut-auto.user.js) |
15+
| [Better Iwara](src/better-iwara/) | Iwara 样式优化 | [GitHub](https://xiaolinxiaozhu.github.io/JavaScriptTools/entertainment/better-iwara.user.js) |
16+
| [评价表自动选择](src/evaluation-auto/) | 自动选择教学评价 | [GitHub](https://xiaolinxiaozhu.github.io/JavaScriptTools/campus/evaluation-auto.user.js) |
17+
| [HUST 军理自动填充](src/hust-autofill/) | 华科军理线上作业自动填充 | [GitHub](https://xiaolinxiaozhu.github.io/JavaScriptTools/campus/hust-autofill.user.js) |
18+
19+
### 其他工具
20+
21+
| 项目 | 说明 | 类型 |
22+
|------|------|------|
23+
| [Obsidian CardView](src/obsidian-cardview/) | Obsidian 卡片视图样式 | Plain JS |
24+
| [Hexo Image Redirect](src/hexo-image-redirect/) | Hexo 博客图片重定向 | Node.js 模块 |
25+
26+
## 安装方式
27+
28+
1. 安装浏览器扩展 [Tampermonkey](https://www.tampermonkey.net/)
29+
2. 点击上方表格中的安装链接,Tampermonkey 会自动弹出安装确认
30+
3. 脚本会通过 `@updateURL` 自动检查更新
31+
32+
部分脚本同时发布在 [GreasyFork](https://greasyfork.org/zh-CN/users/1211126-xiaolinxiaozhu) 上。
33+
34+
## 开发
35+
36+
参见 [CONTRIBUTING.md](CONTRIBUTING.md)
37+
38+
## 许可证
39+
40+
MIT

scripts/build.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import * as esbuild from 'esbuild';
22
import * as fs from 'node:fs';
33
import * as path from 'node:path';
44
import { pathToFileURL } from 'node:url';
5+
56
import type {
67
ScriptConfig,
78
UserScriptConfig,
@@ -347,6 +348,17 @@ async function buildAll(entries: ScriptEntry[]): Promise<void> {
347348
}
348349

349350
console.log(`\n✨ 全部构建完成!\n`);
351+
352+
// 生成脚本文档
353+
console.log('📄 生成脚本文档...\n');
354+
await processAllDocs(entries);
355+
}
356+
357+
async function processAllDocs(entries: ScriptEntry[]): Promise<void> {
358+
const { processScriptDocs } = await import('./docs');
359+
for (const entry of entries) {
360+
await processScriptDocs(entry.name, entry.dir, entry.config);
361+
}
350362
}
351363

352364
async function main(): Promise<void> {

0 commit comments

Comments
 (0)