dsh-browserpaw 5.0.0 → 5.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -5
- package/index.js +6 -3
- package/package.json +2 -2
- package/skills/browserpaw/SKILL.md +4 -4
- package/skills/browserpaw/assets/recipes/bilibili-popular-videos.json +364 -0
- package/skills/browserpaw/assets/recipes/bilibili-video-detail.json +395 -0
- package/skills/browserpaw/assets/recipes/github-issue-thread.json +313 -0
- package/skills/browserpaw/assets/recipes/github-releases.json +86 -45
- package/skills/browserpaw/assets/recipes/github-repo-readme.json +306 -0
- package/skills/browserpaw/assets/recipes/github-repo-search.json +313 -0
- package/skills/browserpaw/assets/recipes/mdn-search.json +93 -48
- package/skills/browserpaw/assets/recipes/npm-compare.json +6 -4
- package/skills/browserpaw/assets/recipes/reddit-post-read.json +289 -0
- package/skills/browserpaw/assets/recipes/reddit-subreddit-posts.json +331 -0
- package/skills/browserpaw/assets/recipes/v2ex-node-topics.json +334 -0
- package/skills/browserpaw/assets/recipes/v2ex-topic-read.json +325 -0
- package/skills/browserpaw/assets/recipes/x-profile-posts.json +332 -0
- package/skills/browserpaw/assets/recipes/x-search-thread.json +13 -41
- package/skills/browserpaw/assets/recipes/x-visible-thread.json +40 -83
- package/skills/browserpaw/assets/recipes/youtube-search-videos.json +279 -0
- package/skills/browserpaw/assets/recipes/youtube-video-read.json +349 -0
- package/skills/browserpaw/references/recipe-contract.md +4 -3
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# BrowserPaw Bundle for DeepSeek Harness (`dsh-browserpaw`)
|
|
2
2
|
|
|
3
|
-
DeepSeek Harness (`dsh`) Cordis bundle for **BrowserPaw v5.0.
|
|
3
|
+
DeepSeek Harness (`dsh`) Cordis bundle for **BrowserPaw v5.0.1**. One install brings in both the `browserpaw` npm CLI package (`dependencies.browserpaw`) and the read-only canonical `browserpaw` Agent Skill inside the DeepSeek Harness profile directory.
|
|
4
4
|
|
|
5
5
|
## Why This Layout Works Cleanly
|
|
6
6
|
|
|
@@ -10,12 +10,12 @@ DeepSeek Harness (`dsh`) Cordis bundle for **BrowserPaw v5.0.0**. One install br
|
|
|
10
10
|
|
|
11
11
|
## Installation
|
|
12
12
|
|
|
13
|
-
> **Quick Start alternative:** For cross-agent setups, the recommended default in the root [README](../../README.md) is global skill + npm (`npm install -g browserpaw@5.0.
|
|
13
|
+
> **Quick Start alternative:** For cross-agent setups, the recommended default in the root [README](../../README.md) is global skill + npm (`npm install -g browserpaw@5.0.1 && browserpaw setup`) plus loading the Chrome extension. Use `dsh-browserpaw` when you want a self-contained DeepSeek Harness profile plugin.
|
|
14
14
|
|
|
15
15
|
1. Install the bundle into your DeepSeek Harness profile (requires `pnpm` and Node.js `>= 22.6.0`):
|
|
16
16
|
|
|
17
17
|
```sh
|
|
18
|
-
# From npm (after v5.0.
|
|
18
|
+
# From npm (after v5.0.1 publication)
|
|
19
19
|
dsh plugin --profile web add dsh-browserpaw
|
|
20
20
|
|
|
21
21
|
# Or from a local checkout
|
|
@@ -37,9 +37,9 @@ DeepSeek Harness (`dsh`) Cordis bundle for **BrowserPaw v5.0.0**. One install br
|
|
|
37
37
|
## Bundle Manifest Declarations
|
|
38
38
|
|
|
39
39
|
- **`dsh.bundle.patch`** points to `./cordis.patch.yml`, inserting `browserpaw-skill` as a profile bundle layer.
|
|
40
|
-
- **`dependencies.browserpaw`** pins `^5.0.
|
|
40
|
+
- **`dependencies.browserpaw`** pins `^5.0.1` so DSH installs the `browserpaw` npm CLI alongside the plugin.
|
|
41
41
|
- **`engines.dsh`** declares `>=0.2.0-rc.1 <0.3.0-0` (no in-box `@deepseek-ai/*` package is listed in `dependencies`, avoiding duplicate Cordis symbol registration).
|
|
42
42
|
|
|
43
43
|
## Upgrading from v4 (`dsh-browserpaw` 4.x)
|
|
44
44
|
|
|
45
|
-
v4's `browserpaw_session` MCP bridge tool and `@deepseek-ai/dsh-mcp-client` integration are retired in v5.0.0. Upgrade `dsh-browserpaw` to `5.0.
|
|
45
|
+
v4's `browserpaw_session` MCP bridge tool and `@deepseek-ai/dsh-mcp-client` integration are retired in v5.0.0. Upgrade `dsh-browserpaw` to `5.0.1`, remove any legacy `127.0.0.1:12306` MCP settings, run `browserpaw setup --no-skill`, and load the v5 Chrome extension. See [docs/MIGRATION.md](../../docs/MIGRATION.md).
|
package/index.js
CHANGED
|
@@ -8,7 +8,7 @@ const SKILL_NAME = 'browserpaw';
|
|
|
8
8
|
const DEFAULT_DESCRIPTION =
|
|
9
9
|
"Control the user's Chrome or Chromium through the BrowserPaw CLI and run learned site workflows stored in ~/.browserpaw.";
|
|
10
10
|
const MAX_INDEX_BYTES = 1024 * 1024;
|
|
11
|
-
const MAX_ROUTING_ROWS =
|
|
11
|
+
const MAX_ROUTING_ROWS = 30;
|
|
12
12
|
|
|
13
13
|
export const name = 'browserpaw-skill';
|
|
14
14
|
export const inject = ['skills'];
|
|
@@ -40,7 +40,10 @@ export function readLearnedWorkflows(homeDir = resolveBrowserPawHome()) {
|
|
|
40
40
|
if (!parsed || !Array.isArray(parsed.workflows)) return [];
|
|
41
41
|
return parsed.workflows
|
|
42
42
|
.filter(
|
|
43
|
-
(item) =>
|
|
43
|
+
(item) =>
|
|
44
|
+
item &&
|
|
45
|
+
typeof item.id === 'string' &&
|
|
46
|
+
(!item.status || item.status === 'active' || item.status === 'bundled'),
|
|
44
47
|
)
|
|
45
48
|
.slice(0, MAX_ROUTING_ROWS)
|
|
46
49
|
.map((item) => ({
|
|
@@ -98,7 +101,7 @@ export function buildRuntimeNote({ bundledCliPath = null, homeDir = '~/.browserp
|
|
|
98
101
|
);
|
|
99
102
|
} else {
|
|
100
103
|
lines.push(
|
|
101
|
-
'> **CLI Prerequisite**: Run `browserpaw status` to verify the host and Chrome extension. If `browserpaw` is not on `PATH`, install with `npm install -g browserpaw@5.0.
|
|
104
|
+
'> **CLI Prerequisite**: Run `browserpaw status` to verify the host and Chrome extension. If `browserpaw` is not on `PATH`, install with `npm install -g browserpaw@5.0.1 && browserpaw setup --no-skill`.',
|
|
102
105
|
);
|
|
103
106
|
}
|
|
104
107
|
return lines.join('\n');
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-browserpaw",
|
|
3
|
-
"version": "5.0.
|
|
3
|
+
"version": "5.0.1",
|
|
4
4
|
"description": "DeepSeek Harness bundle for BrowserPaw: installs the browserpaw CLI and registers the canonical BrowserPaw Agent Skill.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "index.js",
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"!**/*.test.*"
|
|
37
37
|
],
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"browserpaw": "^5.0.
|
|
39
|
+
"browserpaw": "^5.0.1"
|
|
40
40
|
},
|
|
41
41
|
"engines": {
|
|
42
42
|
"dsh": ">=0.2.0-rc.1 <0.3.0-0",
|
|
@@ -9,15 +9,15 @@ Run `browserpaw status` to confirm the host and extension are connected. Use `br
|
|
|
9
9
|
|
|
10
10
|
For browser history, bookmarks, or site storage, use `browserpaw help data` and [browser data](references/browser-data.md). For network, performance, or CDP work, use `browserpaw help debug` and [debugging](references/debugging.md).
|
|
11
11
|
|
|
12
|
-
|
|
12
|
+
When invoked on demand, the CLI checks npm every 24 hours, installs verified updates under `~/.browserpaw/cli-versions/`, and refreshes the host, bundled recipes, and managed Skills (`BROWSERPAW_NO_AUTO_UPDATE=1` / `BROWSERPAW_NO_UPDATE_CHECK=1` opt out). If auto-update is disabled and stderr reports an update, mention it once after finishing the task before running `browserpaw setup`. Same-major CLI updates (`5.0.x` with extension `>= 5.0.0`) stay compatible without requiring an extension reload; `browserpaw status` reports `extensionUpdateAvailable` or incompatibility for manual updates in `chrome://extensions`. Update plugin-bundled Skills via their Agent's plugin manager.
|
|
13
13
|
|
|
14
|
-
For an npx-only installation, use `npx --yes browserpaw@5.0.
|
|
14
|
+
For an npx-only installation, use `npx --yes browserpaw@5.0.1` in place of `browserpaw` throughout.
|
|
15
15
|
|
|
16
16
|
## Learned Workflows & Auto-Routing (`~/.browserpaw`)
|
|
17
17
|
|
|
18
|
-
Before manually browsing a site, check any synced `Learned Workflows` table
|
|
18
|
+
Before manually browsing a site, check any synced `Learned Workflows` table or run `browserpaw recipe find <query> --url <url>` / `browserpaw recipe list` (offline against `~/.browserpaw`). Trusted bundled read-only skills appear by default with status `bundled` (no `--all` needed); unvalidated custom or proposed candidates require `recipe list --all` and `browserpaw recipe validate ID`. When a recipe matches, inspect inputs with `browserpaw recipe show ID` if needed and run `browserpaw recipe run ID key=value...` directly.
|
|
19
19
|
|
|
20
|
-
|
|
20
|
+
First `browserpaw recipe run ID ...` on a `bundled` skill auto-validates and activates it; newer bundled revisions auto-upgrade with rollback on validation failure, preserving user-created, disabled, and pinned skills. For custom or repaired candidates (`recipe list --all`), run `browserpaw recipe validate ID` once with Chrome connected. Only verified read-only workflows auto-activate; write-capable candidates remain manual.
|
|
21
21
|
|
|
22
22
|
When you solve a repeatable site workflow that has no learned entry yet (such as a site search or structured page reader), save it into `~/.browserpaw` with `browserpaw recipe save FILE` including `id`, `name`, `description`, `domains`, `keywords`, `inputs`, and `steps` (or propose a verified read-only skill). Saving creates a candidate, which remains discoverable through `recipe list --all` but does not enter automatic routing until validation. Repair one failing step with `browserpaw recipe patch ID --step INDEX -- ARGS...`; the candidate revision is written separately, so a failed repair or validation preserves the active workflow. A failed recipe returns `failedStepIndex`, `failedStep`, `completedSteps`, and a bounded page summary when a temporary task remains available. Never store passwords, cookies, tokens, tab IDs, or observed refs in saved recipes.
|
|
23
23
|
|
|
@@ -0,0 +1,364 @@
|
|
|
1
|
+
{
|
|
2
|
+
"id": "bilibili-popular-videos",
|
|
3
|
+
"name": "Bilibili popular videos reader",
|
|
4
|
+
"description": "Read Bilibili's trending popular videos via Bilibili's web-interface API inside Chrome with browser cookies and Referer.",
|
|
5
|
+
"source": {
|
|
6
|
+
"type": "builtin",
|
|
7
|
+
"urls": [
|
|
8
|
+
"https://www.bilibili.com/v/popular/all",
|
|
9
|
+
"https://api.bilibili.com/x/web-interface/popular?ps=10&pn=1"
|
|
10
|
+
]
|
|
11
|
+
},
|
|
12
|
+
"domains": [
|
|
13
|
+
"www.bilibili.com",
|
|
14
|
+
"m.bilibili.com",
|
|
15
|
+
"bilibili.com",
|
|
16
|
+
"api.bilibili.com"
|
|
17
|
+
],
|
|
18
|
+
"keywords": [
|
|
19
|
+
"bilibili",
|
|
20
|
+
"b站",
|
|
21
|
+
"哔哩哔哩",
|
|
22
|
+
"popular",
|
|
23
|
+
"trending",
|
|
24
|
+
"hot",
|
|
25
|
+
"videos",
|
|
26
|
+
"热门",
|
|
27
|
+
"热榜",
|
|
28
|
+
"视频",
|
|
29
|
+
"B站热门",
|
|
30
|
+
"哔哩哔哩热门",
|
|
31
|
+
"B站视频"
|
|
32
|
+
],
|
|
33
|
+
"startUrl": "https://www.bilibili.com/v/popular/all",
|
|
34
|
+
"inputSchema": {
|
|
35
|
+
"type": "object",
|
|
36
|
+
"properties": {
|
|
37
|
+
"limit": {
|
|
38
|
+
"type": "integer",
|
|
39
|
+
"minimum": 1,
|
|
40
|
+
"maximum": 20,
|
|
41
|
+
"default": 10
|
|
42
|
+
},
|
|
43
|
+
"page": {
|
|
44
|
+
"type": "integer",
|
|
45
|
+
"minimum": 1,
|
|
46
|
+
"maximum": 10,
|
|
47
|
+
"default": 1
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
"required": [],
|
|
51
|
+
"additionalProperties": false
|
|
52
|
+
},
|
|
53
|
+
"outputSchema": {
|
|
54
|
+
"oneOf": [
|
|
55
|
+
{
|
|
56
|
+
"type": "object",
|
|
57
|
+
"properties": {
|
|
58
|
+
"success": {
|
|
59
|
+
"const": true
|
|
60
|
+
},
|
|
61
|
+
"status": {
|
|
62
|
+
"const": "ok"
|
|
63
|
+
},
|
|
64
|
+
"page": {
|
|
65
|
+
"type": "integer",
|
|
66
|
+
"minimum": 1
|
|
67
|
+
},
|
|
68
|
+
"videos": {
|
|
69
|
+
"type": "array",
|
|
70
|
+
"minItems": 1,
|
|
71
|
+
"maxItems": 20,
|
|
72
|
+
"items": {
|
|
73
|
+
"type": "object",
|
|
74
|
+
"properties": {
|
|
75
|
+
"bvid": {
|
|
76
|
+
"type": "string",
|
|
77
|
+
"pattern": "^BV[0-9A-Za-z]+$"
|
|
78
|
+
},
|
|
79
|
+
"title": {
|
|
80
|
+
"type": "string",
|
|
81
|
+
"minLength": 1
|
|
82
|
+
},
|
|
83
|
+
"url": {
|
|
84
|
+
"type": "string",
|
|
85
|
+
"pattern": "^https://www\\.bilibili\\.com/video/BV[0-9A-Za-z]+$"
|
|
86
|
+
},
|
|
87
|
+
"author": {
|
|
88
|
+
"type": "string"
|
|
89
|
+
},
|
|
90
|
+
"category": {
|
|
91
|
+
"type": "string"
|
|
92
|
+
},
|
|
93
|
+
"durationSeconds": {
|
|
94
|
+
"type": "integer",
|
|
95
|
+
"minimum": 0
|
|
96
|
+
},
|
|
97
|
+
"views": {
|
|
98
|
+
"type": "integer",
|
|
99
|
+
"minimum": 0
|
|
100
|
+
},
|
|
101
|
+
"likes": {
|
|
102
|
+
"type": "integer",
|
|
103
|
+
"minimum": 0
|
|
104
|
+
},
|
|
105
|
+
"danmaku": {
|
|
106
|
+
"type": "integer",
|
|
107
|
+
"minimum": 0
|
|
108
|
+
},
|
|
109
|
+
"publishedAt": {
|
|
110
|
+
"type": "integer",
|
|
111
|
+
"minimum": 0
|
|
112
|
+
}
|
|
113
|
+
},
|
|
114
|
+
"required": [
|
|
115
|
+
"bvid",
|
|
116
|
+
"title",
|
|
117
|
+
"url",
|
|
118
|
+
"author",
|
|
119
|
+
"category",
|
|
120
|
+
"durationSeconds",
|
|
121
|
+
"views",
|
|
122
|
+
"likes",
|
|
123
|
+
"danmaku",
|
|
124
|
+
"publishedAt"
|
|
125
|
+
],
|
|
126
|
+
"additionalProperties": false
|
|
127
|
+
}
|
|
128
|
+
},
|
|
129
|
+
"sources": {
|
|
130
|
+
"type": "object",
|
|
131
|
+
"properties": {
|
|
132
|
+
"api": {
|
|
133
|
+
"oneOf": [
|
|
134
|
+
{
|
|
135
|
+
"type": "string",
|
|
136
|
+
"pattern": "^https://api\\.bilibili\\.com/x/web-interface/popular\\?"
|
|
137
|
+
},
|
|
138
|
+
{
|
|
139
|
+
"type": "null"
|
|
140
|
+
}
|
|
141
|
+
]
|
|
142
|
+
},
|
|
143
|
+
"page": {
|
|
144
|
+
"type": "string",
|
|
145
|
+
"pattern": "^https://www\\.bilibili\\.com/"
|
|
146
|
+
}
|
|
147
|
+
},
|
|
148
|
+
"required": [
|
|
149
|
+
"api",
|
|
150
|
+
"page"
|
|
151
|
+
],
|
|
152
|
+
"additionalProperties": false
|
|
153
|
+
}
|
|
154
|
+
},
|
|
155
|
+
"required": [
|
|
156
|
+
"success",
|
|
157
|
+
"status",
|
|
158
|
+
"page",
|
|
159
|
+
"videos",
|
|
160
|
+
"sources"
|
|
161
|
+
],
|
|
162
|
+
"additionalProperties": false
|
|
163
|
+
},
|
|
164
|
+
{
|
|
165
|
+
"type": "object",
|
|
166
|
+
"properties": {
|
|
167
|
+
"success": {
|
|
168
|
+
"const": true
|
|
169
|
+
},
|
|
170
|
+
"status": {
|
|
171
|
+
"const": "empty"
|
|
172
|
+
},
|
|
173
|
+
"page": {
|
|
174
|
+
"type": "integer",
|
|
175
|
+
"minimum": 1
|
|
176
|
+
},
|
|
177
|
+
"videos": {
|
|
178
|
+
"type": "array",
|
|
179
|
+
"minItems": 0,
|
|
180
|
+
"maxItems": 0
|
|
181
|
+
},
|
|
182
|
+
"sources": {
|
|
183
|
+
"type": "object",
|
|
184
|
+
"properties": {
|
|
185
|
+
"api": {
|
|
186
|
+
"oneOf": [
|
|
187
|
+
{
|
|
188
|
+
"type": "string",
|
|
189
|
+
"pattern": "^https://api\\.bilibili\\.com/x/web-interface/popular\\?"
|
|
190
|
+
},
|
|
191
|
+
{
|
|
192
|
+
"type": "null"
|
|
193
|
+
}
|
|
194
|
+
]
|
|
195
|
+
},
|
|
196
|
+
"page": {
|
|
197
|
+
"type": "string",
|
|
198
|
+
"pattern": "^https://www\\.bilibili\\.com/"
|
|
199
|
+
}
|
|
200
|
+
},
|
|
201
|
+
"required": [
|
|
202
|
+
"api",
|
|
203
|
+
"page"
|
|
204
|
+
],
|
|
205
|
+
"additionalProperties": false
|
|
206
|
+
}
|
|
207
|
+
},
|
|
208
|
+
"required": [
|
|
209
|
+
"success",
|
|
210
|
+
"status",
|
|
211
|
+
"page",
|
|
212
|
+
"videos",
|
|
213
|
+
"sources"
|
|
214
|
+
],
|
|
215
|
+
"additionalProperties": false
|
|
216
|
+
}
|
|
217
|
+
]
|
|
218
|
+
},
|
|
219
|
+
"steps": [
|
|
220
|
+
{
|
|
221
|
+
"tool": "chrome_javascript",
|
|
222
|
+
"args": {
|
|
223
|
+
"code": "const limit = Math.max(1, Math.min(Number(input.limit) || 10, 20));\nconst page = Math.max(1, Math.min(Math.floor(Number(input.page) || 1), 10));\nconst pageUrl = 'https://www.bilibili.com/v/popular/all';\nconst origin = typeof location !== 'undefined' && typeof location.origin === 'string' && /^https:\\/\\/(?:www\\.|m\\.)?bilibili\\.com$/i.test(location.origin) ? location.origin : '';\nif (!origin) {\n return { success: false, status: 'page_not_ready', page, message: 'Bilibili page origin is not ready', source: pageUrl };\n}\nconst endpoint = new URL('/x/web-interface/popular', 'https://api.bilibili.com');\nendpoint.searchParams.set('ps', String(limit));\nendpoint.searchParams.set('pn', String(page));\nconst mapApiVideos = list => {\n const out = [];\n const seen = new Set();\n for (const item of list) {\n const bvid = String((item && item.bvid) || '').trim();\n const title = String((item && item.title) || '').trim();\n if (!/^BV[0-9A-Za-z]+$/.test(bvid) || !title || seen.has(bvid)) continue;\n seen.add(bvid);\n const stat = (item && item.stat) || {};\n out.push({\n bvid,\n title,\n url: 'https://www.bilibili.com/video/' + bvid,\n author: String((item && item.owner && item.owner.name) || '').trim(),\n category: String((item && item.tname) || '').trim(),\n durationSeconds: Math.max(0, Math.floor(Number(item && item.duration) || 0)),\n views: Math.max(0, Math.floor(Number(stat.view) || 0)),\n likes: Math.max(0, Math.floor(Number(stat.like) || 0)),\n danmaku: Math.max(0, Math.floor(Number(stat.danmaku) || 0)),\n publishedAt: Math.max(0, Math.floor(Number(item && item.pubdate) || 0))\n });\n if (out.length >= limit) break;\n }\n return out;\n};\nconst readFallbackVideos = () => {\n if (page !== 1) return [];\n const root = typeof globalThis !== 'undefined' ? globalThis : {};\n const state = root.__INITIAL_STATE__;\n if (state && typeof state === 'object') {\n const candidates = [state.popularList, state.list, state.rankList, state.videoList];\n for (const list of candidates) {\n if (Array.isArray(list) && list.length > 0) {\n const mapped = mapApiVideos(list);\n if (mapped.length > 0) return mapped;\n }\n }\n }\n if (typeof document === 'undefined' || !document || typeof document.querySelectorAll !== 'function') return [];\n const isHidden = el => Boolean(el && (el.hidden === true || (typeof el.hasAttribute === 'function' && el.hasAttribute('hidden')) || (typeof el.getAttribute === 'function' && el.getAttribute('aria-hidden') === 'true')));\n const out = [];\n const seen = new Set();\n const cards = Array.from(document.querySelectorAll('.video-card, .rank-item, .popular-video-card'));\n const nodes = cards.length > 0 ? cards : Array.from(document.querySelectorAll('a[href*=\"/video/BV\"]'));\n for (const node of nodes) {\n if (isHidden(node)) continue;\n const link = node.matches && node.matches('a[href]') ? node : (typeof node.querySelector === 'function' ? node.querySelector('a[href*=\"/video/BV\"]') : null);\n const href = link && typeof link.getAttribute === 'function' ? String(link.getAttribute('href') || '') : '';\n const m = href.match(/\\/video\\/(BV[0-9A-Za-z]+)/);\n const bvid = m ? m[1] : '';\n if (!bvid || seen.has(bvid)) continue;\n const titleEl = typeof node.querySelector === 'function' ? node.querySelector('.video-name, .title, h3, [title]') : null;\n const title = String((titleEl && ((typeof titleEl.getAttribute === 'function' && titleEl.getAttribute('title')) || titleEl.innerText || titleEl.textContent)) || (link && ((typeof link.getAttribute === 'function' && link.getAttribute('title')) || link.innerText || link.textContent)) || '').trim();\n if (!title) continue;\n const authorEl = typeof node.querySelector === 'function' ? node.querySelector('.up-name__text, .up-name, .author') : null;\n seen.add(bvid);\n out.push({\n bvid,\n title,\n url: 'https://www.bilibili.com/video/' + bvid,\n author: authorEl ? String(authorEl.innerText || authorEl.textContent || '').trim() : '',\n category: '',\n durationSeconds: 0,\n views: 0,\n likes: 0,\n danmaku: 0,\n publishedAt: 0\n });\n if (out.length >= limit) break;\n }\n return out;\n};\nconst tryFallback = () => {\n const videos = readFallbackVideos();\n if (!videos.length) return null;\n return {\n success: true,\n status: 'ok',\n page,\n videos,\n sources: { api: null, page: pageUrl }\n };\n};\nlet response;\ntry {\n response = await fetch(endpoint.href, { credentials: 'include', headers: { Accept: 'application/json' } });\n} catch (error) {\n const fb = tryFallback();\n if (fb) return fb;\n return { success: false, status: 'fetch_error', page, message: String(error && error.message || error), source: endpoint.href };\n}\nif (response.status === 403) {\n const fb = tryFallback();\n if (fb) return fb;\n return { success: false, status: 'requires_auth', page, requiresLogin: true, httpStatus: 403, source: response.url || endpoint.href };\n}\nif (response.status === 412 || response.status === 429) {\n const fb = tryFallback();\n if (fb) return fb;\n return { success: false, status: 'rate_limited', page, httpStatus: response.status, source: response.url || endpoint.href };\n}\nif (!response.ok) {\n const fb = tryFallback();\n if (fb) return fb;\n return { success: false, status: 'http_error', page, httpStatus: response.status, source: response.url || endpoint.href };\n}\nlet payload;\ntry {\n payload = await response.json();\n} catch {\n const fb = tryFallback();\n if (fb) return fb;\n return { success: false, status: 'invalid_json', page, source: response.url || endpoint.href };\n}\nif (!payload || typeof payload !== 'object') {\n const fb = tryFallback();\n if (fb) return fb;\n return { success: false, status: 'schema_changed', page, source: response.url || endpoint.href };\n}\nif (payload.code === -101 || payload.code === -403) {\n const fb = tryFallback();\n if (fb) return fb;\n return { success: false, status: 'requires_auth', page, requiresLogin: true, code: payload.code, message: String(payload.message || 'Bilibili requires authentication'), source: response.url || endpoint.href };\n}\nif (payload.code === -352 || payload.code === -412) {\n const fb = tryFallback();\n if (fb) return fb;\n return { success: false, status: 'rate_limited', page, code: payload.code, message: String(payload.message || 'Bilibili risk control triggered'), source: response.url || endpoint.href };\n}\nif (payload.code !== 0 || !payload.data || !Array.isArray(payload.data.list)) {\n const fb = tryFallback();\n if (fb) return fb;\n return { success: false, status: 'schema_changed', page, code: payload.code, message: String(payload.message || ''), source: response.url || endpoint.href };\n}\nif (payload.data.list.length === 0) {\n return { success: true, status: 'empty', page, videos: [], sources: { api: response.url || endpoint.href, page: pageUrl } };\n}\nconst videos = mapApiVideos(payload.data.list);\nif (!videos.length) {\n return { success: false, status: 'schema_changed', page, source: response.url || endpoint.href };\n}\nreturn {\n success: true,\n status: 'ok',\n page,\n videos,\n sources: { api: response.url || endpoint.href, page: pageUrl }\n};",
|
|
224
|
+
"timeoutMs": 30000
|
|
225
|
+
},
|
|
226
|
+
"resultPath": "/result"
|
|
227
|
+
}
|
|
228
|
+
],
|
|
229
|
+
"verification": {
|
|
230
|
+
"tool": "chrome_network_request",
|
|
231
|
+
"args": {
|
|
232
|
+
"url": "https://api.bilibili.com/x/web-interface/popular?ps=1&pn=1",
|
|
233
|
+
"method": "GET",
|
|
234
|
+
"timeout": 30000
|
|
235
|
+
},
|
|
236
|
+
"resultPath": "/response/body"
|
|
237
|
+
},
|
|
238
|
+
"tests": [
|
|
239
|
+
{
|
|
240
|
+
"inputs": {
|
|
241
|
+
"limit": 3,
|
|
242
|
+
"page": 1
|
|
243
|
+
},
|
|
244
|
+
"expect": {
|
|
245
|
+
"type": "object",
|
|
246
|
+
"properties": {
|
|
247
|
+
"success": {
|
|
248
|
+
"const": true
|
|
249
|
+
},
|
|
250
|
+
"status": {
|
|
251
|
+
"const": "ok"
|
|
252
|
+
},
|
|
253
|
+
"page": {
|
|
254
|
+
"const": 1
|
|
255
|
+
},
|
|
256
|
+
"videos": {
|
|
257
|
+
"type": "array",
|
|
258
|
+
"minItems": 1
|
|
259
|
+
},
|
|
260
|
+
"sources": {
|
|
261
|
+
"type": "object",
|
|
262
|
+
"required": [
|
|
263
|
+
"api",
|
|
264
|
+
"page"
|
|
265
|
+
]
|
|
266
|
+
}
|
|
267
|
+
},
|
|
268
|
+
"required": [
|
|
269
|
+
"success",
|
|
270
|
+
"status",
|
|
271
|
+
"page",
|
|
272
|
+
"videos",
|
|
273
|
+
"sources"
|
|
274
|
+
]
|
|
275
|
+
},
|
|
276
|
+
"observe": {
|
|
277
|
+
"type": "object",
|
|
278
|
+
"properties": {
|
|
279
|
+
"code": {
|
|
280
|
+
"const": 0
|
|
281
|
+
},
|
|
282
|
+
"data": {
|
|
283
|
+
"type": "object",
|
|
284
|
+
"properties": {
|
|
285
|
+
"list": {
|
|
286
|
+
"type": "array",
|
|
287
|
+
"minItems": 1
|
|
288
|
+
}
|
|
289
|
+
},
|
|
290
|
+
"required": [
|
|
291
|
+
"list"
|
|
292
|
+
]
|
|
293
|
+
}
|
|
294
|
+
},
|
|
295
|
+
"required": [
|
|
296
|
+
"code",
|
|
297
|
+
"data"
|
|
298
|
+
]
|
|
299
|
+
}
|
|
300
|
+
},
|
|
301
|
+
{
|
|
302
|
+
"inputs": {
|
|
303
|
+
"limit": 5,
|
|
304
|
+
"page": 2
|
|
305
|
+
},
|
|
306
|
+
"expect": {
|
|
307
|
+
"type": "object",
|
|
308
|
+
"properties": {
|
|
309
|
+
"success": {
|
|
310
|
+
"const": true
|
|
311
|
+
},
|
|
312
|
+
"status": {
|
|
313
|
+
"const": "ok"
|
|
314
|
+
},
|
|
315
|
+
"page": {
|
|
316
|
+
"const": 2
|
|
317
|
+
},
|
|
318
|
+
"videos": {
|
|
319
|
+
"type": "array",
|
|
320
|
+
"minItems": 1
|
|
321
|
+
},
|
|
322
|
+
"sources": {
|
|
323
|
+
"type": "object",
|
|
324
|
+
"required": [
|
|
325
|
+
"api",
|
|
326
|
+
"page"
|
|
327
|
+
]
|
|
328
|
+
}
|
|
329
|
+
},
|
|
330
|
+
"required": [
|
|
331
|
+
"success",
|
|
332
|
+
"status",
|
|
333
|
+
"page",
|
|
334
|
+
"videos",
|
|
335
|
+
"sources"
|
|
336
|
+
]
|
|
337
|
+
},
|
|
338
|
+
"observe": {
|
|
339
|
+
"type": "object",
|
|
340
|
+
"properties": {
|
|
341
|
+
"code": {
|
|
342
|
+
"const": 0
|
|
343
|
+
},
|
|
344
|
+
"data": {
|
|
345
|
+
"type": "object",
|
|
346
|
+
"properties": {
|
|
347
|
+
"list": {
|
|
348
|
+
"type": "array",
|
|
349
|
+
"minItems": 1
|
|
350
|
+
}
|
|
351
|
+
},
|
|
352
|
+
"required": [
|
|
353
|
+
"list"
|
|
354
|
+
]
|
|
355
|
+
}
|
|
356
|
+
},
|
|
357
|
+
"required": [
|
|
358
|
+
"code",
|
|
359
|
+
"data"
|
|
360
|
+
]
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
]
|
|
364
|
+
}
|