Skip to content

Commit f2557ba

Browse files
committed
docs: 📝 更新说明文档
1 parent 24d0be5 commit f2557ba

13 files changed

Lines changed: 201 additions & 27 deletions

File tree

.vscode/settings.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,6 @@
120120
"cSpell.ignorePaths": [
121121
"*.yaml",
122122
"*.vscode",
123-
"dist/*.user.js"
123+
"dist/*.js"
124124
]
125125
}

dist/xpath-selector.lib.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
// ==UserScript==
2+
// name XPath Selector
3+
// namespace xiaohuohumax/userscripts/xpath-selector
4+
// version 1.0.3
5+
// author xiaohuohumax
6+
// description XPath Selector -- 一个 XPath 选择器库,快速获取节点数据
7+
// license MIT
8+
// ==/UserScript==
9+
110
var xpathSelector = function() {
211
"use strict";
312
function t$2(t2, s2, r2, i2) {

dist/zip-downloader.lib.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
// ==UserScript==
2+
// name Zip Downloader
3+
// namespace xiaohuohumax/userscripts/zip-downloader
4+
// version 2.0.1
5+
// author xiaohuohumax
6+
// description Zip Downloader -- 资源下载器(下载资源、Zip 压缩、下载到本地)
7+
// license MIT
8+
// ==/UserScript==
9+
110
var zipDownloader = function() {
211
"use strict";var __defProp = Object.defineProperty;
312
var __typeError = (msg) => {

libs/xpath-selector/CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# @xiaohuohumax/xpath-selector
22

3+
## 1.0.4
4+
5+
### Patch Changes
6+
7+
- 更新说明文档
8+
39
## 1.0.3
410

511
### Patch Changes

libs/xpath-selector/README.md

Lines changed: 68 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,7 @@
1515
<img src="https://img.shields.io/badge/issues-问题反馈-yellow?style=for-the-badge&logo=github" alt="问题反馈" />
1616
</a>
1717

18-
## 📖 使用方式
19-
20-
### ✍ 添加元数据
21-
22-
```typescript
23-
// @require https://**/xpath-selector.js?*
24-
```
25-
26-
### 📥 参数说明
18+
## 📥 参数说明
2719

2820
**Options 参数说明:**
2921

@@ -33,7 +25,7 @@
3325
| `returnType` | string || | 获取结果的类型,可选值:`string``strings``number``numbers``boolean``nodes``first-node``map``array``all-results` |
3426
| `node` | Node || `document` | 要搜索的节点 |
3527

36-
### 📦 使用示例
28+
## 📦 使用示例
3729

3830
```html
3931
<!DOCTYPE html>
@@ -137,6 +129,72 @@ const customHtmlTitle = xpathSelector({
137129
console.log(customHtmlTitle) // Hello
138130
```
139131

132+
## 📖 使用方式
133+
134+
### 方式一:直接引入库文件
135+
136+
```typescript
137+
// ==UserScript==
138+
// @require https://**/xpath-selector.js?*
139+
// ==/UserScript==
140+
141+
(function () {
142+
'use strict'
143+
const title = xpathSelector({
144+
expression: '//title/text()',
145+
returnType: 'string'
146+
})
147+
console.log(title) // hello world
148+
})()
149+
```
150+
151+
### 方式二:vite + vite-plugin-monkey [推荐]
152+
153+
1. 初始化项目
154+
155+
```shell
156+
npm create monkey
157+
```
158+
159+
2. 安装 xpath-selector 依赖
160+
161+
```shell
162+
npm i @xiaohuohumax/xpath-selector
163+
```
164+
165+
3. 在 main.ts 中使用 xpath-selector
166+
167+
```typescript
168+
import xpathSelector from '@xiaohuohumax/xpath-selector'
169+
170+
const title = xpathSelector({
171+
expression: '//title/text()',
172+
returnType: 'string'
173+
})
174+
175+
console.log(title) // Output: "Test Page"
176+
```
177+
178+
4. 修改 vite.config.ts 排除 xpath-selector 依赖
179+
180+
```typescript
181+
import { defineConfig } from 'vite'
182+
import monkey, { cdn } from 'vite-plugin-monkey'
183+
184+
// https://vitejs.dev/config/
185+
export default defineConfig({
186+
plugins: [
187+
monkey({
188+
build: {
189+
externalGlobals: {
190+
'@xiaohuohumax/xpath-selector': cdn.jsdelivr('xpathSelector', 'dist/index.lib.js'),
191+
},
192+
},
193+
}),
194+
],
195+
})
196+
```
197+
140198
## 🧩 依赖项目
141199

142200
- [fontoxpath](https://github.com/FontoXML/fontoxpath) XPath 引擎

libs/xpath-selector/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@xiaohuohumax/xpath-selector",
33
"type": "module",
4-
"version": "1.0.3",
4+
"version": "1.0.4",
55
"description": "XPath Selector -- 一个 XPath 选择器库,快速获取节点数据",
66
"author": {
77
"name": "xiaohuohumax",

libs/zip-downloader/CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# @xiaohuohumax/xpath-selector
22

3+
## 2.0.2
4+
5+
### Patch Changes
6+
7+
- 更新说明文档
8+
39
## 2.0.1
410

511
### Patch Changes

libs/zip-downloader/README.md

Lines changed: 89 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,7 @@
1515
<img src="https://img.shields.io/badge/issues-问题反馈-yellow?style=for-the-badge&logo=github" alt="问题反馈" />
1616
</a>
1717

18-
## 📖 使用方式
19-
20-
### ✍ 添加元数据
21-
22-
```typescript
23-
// @require https://**/zip-downloader.js?*
24-
// @grant GM_download
25-
```
26-
27-
### 📥 参数说明
18+
## 📥 参数说明
2819

2920
**Options 参数说明:**
3021

@@ -43,7 +34,7 @@
4334
| `url` | string || | URL 类型资源 |
4435
| `blob` | Blob || | Blob 类型资源 |
4536

46-
### 📦 使用示例
37+
## 📦 使用示例
4738

4839
**下载,压缩,并保存到本地**
4940

@@ -84,6 +75,93 @@ const blob = await zipDownloader({
8475
// GM_download(URL.createObjectURL(blob), 'index.zip')
8576
```
8677

78+
## 📖 使用方式
79+
80+
### 方式一:直接引入库文件
81+
82+
```typescript
83+
// ==UserScript==
84+
// @require https://**/zip-downloader.js?*
85+
// @grant GM_download
86+
// ==/UserScript==
87+
88+
(async function () {
89+
'use strict'
90+
await zipDownloader({
91+
filename: 'index.zip',
92+
resources: [
93+
{ name: 'index.html', url: location.href },
94+
{
95+
name: 'hello.txt',
96+
blob: new Blob(['hello world'], { type: 'text/plain' }),
97+
},
98+
],
99+
concurrency: 10,
100+
async onProgress(index) {
101+
console.log(`正在下载第 ${index + 1} 个资源`)
102+
},
103+
})
104+
})()
105+
```
106+
107+
### 方式二:vite + vite-plugin-monkey [推荐]
108+
109+
1. 初始化项目
110+
111+
```shell
112+
npm create monkey
113+
```
114+
115+
2. 安装 zip-downloader 依赖
116+
117+
```shell
118+
npm i @xiaohuohumax/zip-downloader
119+
```
120+
121+
3. 在 main.ts 中使用 zip-downloader
122+
123+
```typescript
124+
import zipDownloader from '@xiaohuohumax/zip-downloader'
125+
126+
await zipDownloader({
127+
filename: 'index.zip',
128+
resources: [
129+
{ name: 'index.html', url: location.href },
130+
{
131+
name: 'hello.txt',
132+
blob: new Blob(['hello world'], { type: 'text/plain' }),
133+
},
134+
],
135+
concurrency: 10,
136+
async onProgress(index) {
137+
console.log(`正在下载第 ${index + 1} 个资源`)
138+
},
139+
})
140+
```
141+
142+
1. 修改 vite.config.ts 排除 zip-downloader 依赖和添加 GM_download 权限
143+
144+
```typescript
145+
import { defineConfig } from 'vite'
146+
import monkey, { cdn } from 'vite-plugin-monkey'
147+
148+
// https://vitejs.dev/config/
149+
export default defineConfig({
150+
plugins: [
151+
monkey({
152+
build: {
153+
externalGlobals: {
154+
'@xiaohuohumax/zip-downloader': cdn.jsdelivr('zipDownloader', 'dist/index.lib.js'),
155+
},
156+
},
157+
userscript: {
158+
grant: ['GM_download']
159+
},
160+
}),
161+
],
162+
})
163+
```
164+
87165
## 🧩 依赖项目
88166

89167
- [zip.js](https://github.com/gildas-lormeau/zip.js) Zip 压缩库

libs/zip-downloader/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@xiaohuohumax/zip-downloader",
33
"type": "module",
4-
"version": "2.0.1",
4+
"version": "2.0.2",
55
"description": "Zip Downloader -- 资源下载器(下载资源、Zip 压缩、下载到本地)",
66
"author": {
77
"name": "xiaohuohumax",
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# lib-default-config
2+
3+
## 1.0.1
4+
5+
### Patch Changes
6+
7+
- 修复元数据缺失异常

0 commit comments

Comments
 (0)