browserpaw 0.0.0-stage → 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/LICENSE +681 -0
- package/README.md +4 -2
- package/dist/v5/cli-files.cjs +147 -0
- package/dist/v5/cli.cjs +4900 -0
- package/dist/v5/extension/assets/popup-Djl4pI1R.css +359 -0
- package/dist/v5/extension/background.js +39389 -0
- package/dist/v5/extension/browserpaw-build.json +191 -0
- package/dist/v5/extension/chunks/popup-BSqTH70w.js +6575 -0
- package/dist/v5/extension/content-scripts/agent-cursor.js +1475 -0
- package/dist/v5/extension/icon/128.png +0 -0
- package/dist/v5/extension/icon/16.png +0 -0
- package/dist/v5/extension/icon/32.png +0 -0
- package/dist/v5/extension/icon/48.png +0 -0
- package/dist/v5/extension/icon/96.png +0 -0
- package/dist/v5/extension/images/cursor-chat.png +0 -0
- package/dist/v5/extension/inject-scripts/accessibility-tree-helper.js +2031 -0
- package/dist/v5/extension/inject-scripts/keyboard-helper.js +412 -0
- package/dist/v5/extension/inject-scripts/network-helper.js +378 -0
- package/dist/v5/extension/inject-scripts/screenshot-helper.js +449 -0
- package/dist/v5/extension/inpage-engine.js +9437 -0
- package/dist/v5/extension/manifest.json +1 -0
- package/dist/v5/extension/popup.html +14 -0
- package/dist/v5/host.cjs +19813 -0
- package/dist/v5/recipes/bilibili-popular-videos.json +364 -0
- package/dist/v5/recipes/bilibili-video-detail.json +395 -0
- package/dist/v5/recipes/developer.mozilla.org.md +15 -0
- package/dist/v5/recipes/github-issue-thread.json +313 -0
- package/dist/v5/recipes/github-releases.json +218 -0
- package/dist/v5/recipes/github-repo-readme.json +306 -0
- package/dist/v5/recipes/github-repo-search.json +313 -0
- package/dist/v5/recipes/mdn-search.json +219 -0
- package/dist/v5/recipes/npm-compare.json +458 -0
- package/dist/v5/recipes/reddit-post-read.json +289 -0
- package/dist/v5/recipes/reddit-subreddit-posts.json +331 -0
- package/dist/v5/recipes/v2ex-node-topics.json +334 -0
- package/dist/v5/recipes/v2ex-topic-read.json +325 -0
- package/dist/v5/recipes/x-profile-posts.json +332 -0
- package/dist/v5/recipes/x-search-thread.json +293 -0
- package/dist/v5/recipes/x-visible-thread.json +260 -0
- package/dist/v5/recipes/youtube-search-videos.json +279 -0
- package/dist/v5/recipes/youtube-video-read.json +349 -0
- package/dist/v5/run_host.bat +7 -0
- package/dist/v5/run_host.sh +6 -0
- package/dist/v5/skill/browserpaw/SKILL.md +48 -0
- package/dist/v5/skill/browserpaw/assets/recipes/bilibili-popular-videos.json +364 -0
- package/dist/v5/skill/browserpaw/assets/recipes/bilibili-video-detail.json +395 -0
- package/dist/v5/skill/browserpaw/assets/recipes/developer.mozilla.org.md +15 -0
- package/dist/v5/skill/browserpaw/assets/recipes/github-issue-thread.json +313 -0
- package/dist/v5/skill/browserpaw/assets/recipes/github-releases.json +218 -0
- package/dist/v5/skill/browserpaw/assets/recipes/github-repo-readme.json +306 -0
- package/dist/v5/skill/browserpaw/assets/recipes/github-repo-search.json +313 -0
- package/dist/v5/skill/browserpaw/assets/recipes/mdn-search.json +219 -0
- package/dist/v5/skill/browserpaw/assets/recipes/npm-compare.json +458 -0
- package/dist/v5/skill/browserpaw/assets/recipes/reddit-post-read.json +289 -0
- package/dist/v5/skill/browserpaw/assets/recipes/reddit-subreddit-posts.json +331 -0
- package/dist/v5/skill/browserpaw/assets/recipes/v2ex-node-topics.json +334 -0
- package/dist/v5/skill/browserpaw/assets/recipes/v2ex-topic-read.json +325 -0
- package/dist/v5/skill/browserpaw/assets/recipes/x-profile-posts.json +332 -0
- package/dist/v5/skill/browserpaw/assets/recipes/x-search-thread.json +293 -0
- package/dist/v5/skill/browserpaw/assets/recipes/x-visible-thread.json +260 -0
- package/dist/v5/skill/browserpaw/assets/recipes/youtube-search-videos.json +279 -0
- package/dist/v5/skill/browserpaw/assets/recipes/youtube-video-read.json +349 -0
- package/dist/v5/skill/browserpaw/references/TROUBLESHOOTING.md +7 -0
- package/dist/v5/skill/browserpaw/references/TROUBLESHOOTING.zh-CN.md +5 -0
- package/dist/v5/skill/browserpaw/references/browser-data.md +33 -0
- package/dist/v5/skill/browserpaw/references/commands.md +103 -0
- package/dist/v5/skill/browserpaw/references/debugging.md +32 -0
- package/dist/v5/skill/browserpaw/references/recipe-contract.md +47 -0
- package/package.json +67 -4
|
@@ -0,0 +1,334 @@
|
|
|
1
|
+
{
|
|
2
|
+
"id": "v2ex-node-topics",
|
|
3
|
+
"name": "V2EX hot or node topics reader",
|
|
4
|
+
"description": "Read V2EX hot topics, latest topics, or topics in a specific node via V2EX's same-origin public JSON API.",
|
|
5
|
+
"source": {
|
|
6
|
+
"type": "builtin",
|
|
7
|
+
"urls": [
|
|
8
|
+
"https://www.v2ex.com/api/topics/hot.json",
|
|
9
|
+
"https://www.v2ex.com/api/topics/show.json?node_name=python"
|
|
10
|
+
]
|
|
11
|
+
},
|
|
12
|
+
"domains": [
|
|
13
|
+
"www.v2ex.com",
|
|
14
|
+
"v2ex.com"
|
|
15
|
+
],
|
|
16
|
+
"keywords": [
|
|
17
|
+
"v2ex",
|
|
18
|
+
"v站",
|
|
19
|
+
"hot",
|
|
20
|
+
"latest",
|
|
21
|
+
"node",
|
|
22
|
+
"topics",
|
|
23
|
+
"forum",
|
|
24
|
+
"社区",
|
|
25
|
+
"热门",
|
|
26
|
+
"节点",
|
|
27
|
+
"V2EX节点",
|
|
28
|
+
"V2EX热门",
|
|
29
|
+
"V2EX话题"
|
|
30
|
+
],
|
|
31
|
+
"startUrl": "https://www.v2ex.com/api/topics/hot.json",
|
|
32
|
+
"inputSchema": {
|
|
33
|
+
"type": "object",
|
|
34
|
+
"properties": {
|
|
35
|
+
"node": {
|
|
36
|
+
"type": "string",
|
|
37
|
+
"pattern": "^[A-Za-z0-9_-]{1,64}$",
|
|
38
|
+
"default": "hot"
|
|
39
|
+
},
|
|
40
|
+
"limit": {
|
|
41
|
+
"type": "integer",
|
|
42
|
+
"minimum": 1,
|
|
43
|
+
"maximum": 20,
|
|
44
|
+
"default": 10
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
"required": [],
|
|
48
|
+
"additionalProperties": false
|
|
49
|
+
},
|
|
50
|
+
"outputSchema": {
|
|
51
|
+
"oneOf": [
|
|
52
|
+
{
|
|
53
|
+
"type": "object",
|
|
54
|
+
"properties": {
|
|
55
|
+
"success": {
|
|
56
|
+
"const": true
|
|
57
|
+
},
|
|
58
|
+
"status": {
|
|
59
|
+
"const": "ok"
|
|
60
|
+
},
|
|
61
|
+
"node": {
|
|
62
|
+
"type": "string",
|
|
63
|
+
"minLength": 1
|
|
64
|
+
},
|
|
65
|
+
"topics": {
|
|
66
|
+
"type": "array",
|
|
67
|
+
"minItems": 1,
|
|
68
|
+
"maxItems": 20,
|
|
69
|
+
"items": {
|
|
70
|
+
"type": "object",
|
|
71
|
+
"properties": {
|
|
72
|
+
"id": {
|
|
73
|
+
"type": "integer",
|
|
74
|
+
"minimum": 1
|
|
75
|
+
},
|
|
76
|
+
"title": {
|
|
77
|
+
"type": "string",
|
|
78
|
+
"minLength": 1
|
|
79
|
+
},
|
|
80
|
+
"url": {
|
|
81
|
+
"type": "string",
|
|
82
|
+
"pattern": "^https://(?:www\\.)?v2ex\\.com/t/\\d+"
|
|
83
|
+
},
|
|
84
|
+
"node": {
|
|
85
|
+
"type": "string"
|
|
86
|
+
},
|
|
87
|
+
"nodeTitle": {
|
|
88
|
+
"type": "string"
|
|
89
|
+
},
|
|
90
|
+
"author": {
|
|
91
|
+
"type": "string"
|
|
92
|
+
},
|
|
93
|
+
"replies": {
|
|
94
|
+
"type": "integer",
|
|
95
|
+
"minimum": 0
|
|
96
|
+
},
|
|
97
|
+
"created": {
|
|
98
|
+
"type": "integer",
|
|
99
|
+
"minimum": 0
|
|
100
|
+
},
|
|
101
|
+
"excerpt": {
|
|
102
|
+
"type": "string"
|
|
103
|
+
}
|
|
104
|
+
},
|
|
105
|
+
"required": [
|
|
106
|
+
"id",
|
|
107
|
+
"title",
|
|
108
|
+
"url",
|
|
109
|
+
"node",
|
|
110
|
+
"nodeTitle",
|
|
111
|
+
"author",
|
|
112
|
+
"replies",
|
|
113
|
+
"created",
|
|
114
|
+
"excerpt"
|
|
115
|
+
],
|
|
116
|
+
"additionalProperties": false
|
|
117
|
+
}
|
|
118
|
+
},
|
|
119
|
+
"sources": {
|
|
120
|
+
"type": "object",
|
|
121
|
+
"properties": {
|
|
122
|
+
"api": {
|
|
123
|
+
"type": "string",
|
|
124
|
+
"pattern": "^https://(?:www\\.)?v2ex\\.com/api/topics/"
|
|
125
|
+
},
|
|
126
|
+
"page": {
|
|
127
|
+
"type": "string",
|
|
128
|
+
"pattern": "^https://(?:www\\.)?v2ex\\.com/"
|
|
129
|
+
}
|
|
130
|
+
},
|
|
131
|
+
"required": [
|
|
132
|
+
"api",
|
|
133
|
+
"page"
|
|
134
|
+
],
|
|
135
|
+
"additionalProperties": false
|
|
136
|
+
}
|
|
137
|
+
},
|
|
138
|
+
"required": [
|
|
139
|
+
"success",
|
|
140
|
+
"status",
|
|
141
|
+
"node",
|
|
142
|
+
"topics",
|
|
143
|
+
"sources"
|
|
144
|
+
],
|
|
145
|
+
"additionalProperties": false
|
|
146
|
+
},
|
|
147
|
+
{
|
|
148
|
+
"type": "object",
|
|
149
|
+
"properties": {
|
|
150
|
+
"success": {
|
|
151
|
+
"const": true
|
|
152
|
+
},
|
|
153
|
+
"status": {
|
|
154
|
+
"const": "empty"
|
|
155
|
+
},
|
|
156
|
+
"node": {
|
|
157
|
+
"type": "string",
|
|
158
|
+
"minLength": 1
|
|
159
|
+
},
|
|
160
|
+
"topics": {
|
|
161
|
+
"type": "array",
|
|
162
|
+
"minItems": 0,
|
|
163
|
+
"maxItems": 0
|
|
164
|
+
},
|
|
165
|
+
"sources": {
|
|
166
|
+
"type": "object",
|
|
167
|
+
"properties": {
|
|
168
|
+
"api": {
|
|
169
|
+
"type": "string",
|
|
170
|
+
"pattern": "^https://(?:www\\.)?v2ex\\.com/api/topics/"
|
|
171
|
+
},
|
|
172
|
+
"page": {
|
|
173
|
+
"type": "string",
|
|
174
|
+
"pattern": "^https://(?:www\\.)?v2ex\\.com/"
|
|
175
|
+
}
|
|
176
|
+
},
|
|
177
|
+
"required": [
|
|
178
|
+
"api",
|
|
179
|
+
"page"
|
|
180
|
+
],
|
|
181
|
+
"additionalProperties": false
|
|
182
|
+
}
|
|
183
|
+
},
|
|
184
|
+
"required": [
|
|
185
|
+
"success",
|
|
186
|
+
"status",
|
|
187
|
+
"node",
|
|
188
|
+
"topics",
|
|
189
|
+
"sources"
|
|
190
|
+
],
|
|
191
|
+
"additionalProperties": false
|
|
192
|
+
}
|
|
193
|
+
]
|
|
194
|
+
},
|
|
195
|
+
"steps": [
|
|
196
|
+
{
|
|
197
|
+
"tool": "chrome_javascript",
|
|
198
|
+
"args": {
|
|
199
|
+
"code": "const node = String(input.node || 'hot').trim() || 'hot';\nconst limit = Math.max(1, Math.min(Number(input.limit) || 10, 20));\nconst lower = node.toLowerCase();\nconst origin = typeof location !== 'undefined' && typeof location.origin === 'string' && /^https:\\/\\/(?:www\\.)?v2ex\\.com$/i.test(location.origin) ? location.origin : '';\nif (!origin) {\n return { success: false, status: 'page_not_ready', node, message: 'V2EX page origin is not ready', source: 'https://www.v2ex.com/' };\n}\nconst endpoint = lower === 'hot'\n ? new URL('/api/topics/hot.json', origin)\n : lower === 'latest'\n ? new URL('/api/topics/latest.json', origin)\n : new URL('/api/topics/show.json?node_name=' + encodeURIComponent(node), origin);\nconst pageUrl = lower === 'hot' || lower === 'latest'\n ? new URL('/', origin)\n : new URL('/go/' + encodeURIComponent(node), origin);\nlet response;\ntry {\n response = await fetch(endpoint.href, { credentials: 'include', headers: { Accept: 'application/json' } });\n} catch (error) {\n return { success: false, status: 'fetch_error', node, message: String(error && error.message || error), source: endpoint.href };\n}\nif (response.status === 403) {\n return { success: false, status: 'requires_auth', node, requiresLogin: true, httpStatus: 403, message: 'V2EX node requires authentication or is restricted', source: response.url || endpoint.href };\n}\nif (response.status === 429) {\n return { success: false, status: 'rate_limited', node, httpStatus: 429, source: response.url || endpoint.href };\n}\nif (response.status === 404) {\n return { success: false, status: 'not_found', node, httpStatus: 404, source: response.url || endpoint.href };\n}\nif (!response.ok) {\n return { success: false, status: 'http_error', node, httpStatus: response.status, source: response.url || endpoint.href };\n}\nlet data;\ntry {\n data = await response.json();\n} catch {\n return { success: false, status: 'invalid_json', node, source: response.url || endpoint.href };\n}\nif (!Array.isArray(data)) {\n return { success: false, status: 'schema_changed', node, source: response.url || endpoint.href };\n}\nif (data.length === 0) {\n return {\n success: true,\n status: 'empty',\n node,\n topics: [],\n sources: { api: response.url || endpoint.href, page: pageUrl.href }\n };\n}\nconst topics = data\n .map(item => {\n const id = Math.floor(Number(item && item.id) || 0);\n const title = String((item && item.title) || '').trim();\n const url = String((item && item.url) || (id > 0 ? 'https://www.v2ex.com/t/' + id : '')).trim();\n return {\n id,\n title,\n url,\n node: String((item && item.node && item.node.name) || '').trim(),\n nodeTitle: String((item && item.node && item.node.title) || '').trim(),\n author: String((item && item.member && item.member.username) || '').trim(),\n replies: Math.max(0, Math.floor(Number(item && item.replies) || 0)),\n created: Math.max(0, Math.floor(Number(item && item.created) || 0)),\n excerpt: String((item && item.content) || '').replace(/\\s+/g, ' ').trim().slice(0, 300)\n };\n })\n .filter(item => item.id > 0 && item.title && /^https:\\/\\/(?:www\\.)?v2ex\\.com\\/t\\/\\d+/.test(item.url))\n .slice(0, limit);\nif (!topics.length) {\n return { success: false, status: 'schema_changed', node, source: response.url || endpoint.href };\n}\nreturn {\n success: true,\n status: 'ok',\n node,\n topics,\n sources: { api: response.url || endpoint.href, page: pageUrl.href }\n};",
|
|
200
|
+
"timeoutMs": 30000
|
|
201
|
+
},
|
|
202
|
+
"resultPath": "/result"
|
|
203
|
+
}
|
|
204
|
+
],
|
|
205
|
+
"verification": {
|
|
206
|
+
"tool": "chrome_network_request",
|
|
207
|
+
"args": {
|
|
208
|
+
"url": "https://www.v2ex.com/api/topics/hot.json",
|
|
209
|
+
"method": "GET",
|
|
210
|
+
"timeout": 30000
|
|
211
|
+
},
|
|
212
|
+
"resultPath": "/response/body"
|
|
213
|
+
},
|
|
214
|
+
"tests": [
|
|
215
|
+
{
|
|
216
|
+
"inputs": {
|
|
217
|
+
"node": "python",
|
|
218
|
+
"limit": 3
|
|
219
|
+
},
|
|
220
|
+
"expect": {
|
|
221
|
+
"type": "object",
|
|
222
|
+
"properties": {
|
|
223
|
+
"success": {
|
|
224
|
+
"const": true
|
|
225
|
+
},
|
|
226
|
+
"status": {
|
|
227
|
+
"const": "ok"
|
|
228
|
+
},
|
|
229
|
+
"node": {
|
|
230
|
+
"const": "python"
|
|
231
|
+
},
|
|
232
|
+
"topics": {
|
|
233
|
+
"type": "array",
|
|
234
|
+
"minItems": 1
|
|
235
|
+
},
|
|
236
|
+
"sources": {
|
|
237
|
+
"type": "object",
|
|
238
|
+
"required": [
|
|
239
|
+
"api",
|
|
240
|
+
"page"
|
|
241
|
+
]
|
|
242
|
+
}
|
|
243
|
+
},
|
|
244
|
+
"required": [
|
|
245
|
+
"success",
|
|
246
|
+
"status",
|
|
247
|
+
"node",
|
|
248
|
+
"topics",
|
|
249
|
+
"sources"
|
|
250
|
+
]
|
|
251
|
+
},
|
|
252
|
+
"observe": {
|
|
253
|
+
"type": "array",
|
|
254
|
+
"minItems": 1,
|
|
255
|
+
"items": {
|
|
256
|
+
"type": "object",
|
|
257
|
+
"properties": {
|
|
258
|
+
"id": {
|
|
259
|
+
"type": "integer",
|
|
260
|
+
"minimum": 1
|
|
261
|
+
},
|
|
262
|
+
"title": {
|
|
263
|
+
"type": "string",
|
|
264
|
+
"minLength": 1
|
|
265
|
+
}
|
|
266
|
+
},
|
|
267
|
+
"required": [
|
|
268
|
+
"id",
|
|
269
|
+
"title"
|
|
270
|
+
]
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
},
|
|
274
|
+
{
|
|
275
|
+
"inputs": {
|
|
276
|
+
"node": "programmer",
|
|
277
|
+
"limit": 3
|
|
278
|
+
},
|
|
279
|
+
"expect": {
|
|
280
|
+
"type": "object",
|
|
281
|
+
"properties": {
|
|
282
|
+
"success": {
|
|
283
|
+
"const": true
|
|
284
|
+
},
|
|
285
|
+
"status": {
|
|
286
|
+
"const": "ok"
|
|
287
|
+
},
|
|
288
|
+
"node": {
|
|
289
|
+
"const": "programmer"
|
|
290
|
+
},
|
|
291
|
+
"topics": {
|
|
292
|
+
"type": "array",
|
|
293
|
+
"minItems": 1
|
|
294
|
+
},
|
|
295
|
+
"sources": {
|
|
296
|
+
"type": "object",
|
|
297
|
+
"required": [
|
|
298
|
+
"api",
|
|
299
|
+
"page"
|
|
300
|
+
]
|
|
301
|
+
}
|
|
302
|
+
},
|
|
303
|
+
"required": [
|
|
304
|
+
"success",
|
|
305
|
+
"status",
|
|
306
|
+
"node",
|
|
307
|
+
"topics",
|
|
308
|
+
"sources"
|
|
309
|
+
]
|
|
310
|
+
},
|
|
311
|
+
"observe": {
|
|
312
|
+
"type": "array",
|
|
313
|
+
"minItems": 1,
|
|
314
|
+
"items": {
|
|
315
|
+
"type": "object",
|
|
316
|
+
"properties": {
|
|
317
|
+
"id": {
|
|
318
|
+
"type": "integer",
|
|
319
|
+
"minimum": 1
|
|
320
|
+
},
|
|
321
|
+
"title": {
|
|
322
|
+
"type": "string",
|
|
323
|
+
"minLength": 1
|
|
324
|
+
}
|
|
325
|
+
},
|
|
326
|
+
"required": [
|
|
327
|
+
"id",
|
|
328
|
+
"title"
|
|
329
|
+
]
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
]
|
|
334
|
+
}
|
|
@@ -0,0 +1,325 @@
|
|
|
1
|
+
{
|
|
2
|
+
"id": "v2ex-topic-read",
|
|
3
|
+
"name": "V2EX topic and replies reader",
|
|
4
|
+
"description": "Read a V2EX topic and its first-page replies (page=1 only; replies beyond page 1 are not paginated) via V2EX's same-origin public JSON API.",
|
|
5
|
+
"source": {
|
|
6
|
+
"type": "builtin",
|
|
7
|
+
"urls": [
|
|
8
|
+
"https://www.v2ex.com/api/topics/show.json?id=1",
|
|
9
|
+
"https://www.v2ex.com/api/replies/show.json?topic_id=1&page=1"
|
|
10
|
+
]
|
|
11
|
+
},
|
|
12
|
+
"domains": [
|
|
13
|
+
"www.v2ex.com",
|
|
14
|
+
"v2ex.com"
|
|
15
|
+
],
|
|
16
|
+
"keywords": [
|
|
17
|
+
"v2ex",
|
|
18
|
+
"v站",
|
|
19
|
+
"topic",
|
|
20
|
+
"thread",
|
|
21
|
+
"replies",
|
|
22
|
+
"discussion",
|
|
23
|
+
"帖子",
|
|
24
|
+
"回复",
|
|
25
|
+
"详情",
|
|
26
|
+
"V2EX帖子",
|
|
27
|
+
"V2EX回复",
|
|
28
|
+
"V2EX主题"
|
|
29
|
+
],
|
|
30
|
+
"startUrl": "https://www.v2ex.com/api/topics/show.json?id={{topicId}}",
|
|
31
|
+
"inputSchema": {
|
|
32
|
+
"type": "object",
|
|
33
|
+
"properties": {
|
|
34
|
+
"topicId": {
|
|
35
|
+
"type": "integer",
|
|
36
|
+
"minimum": 1,
|
|
37
|
+
"maximum": 100000000
|
|
38
|
+
},
|
|
39
|
+
"limit": {
|
|
40
|
+
"type": "integer",
|
|
41
|
+
"minimum": 1,
|
|
42
|
+
"maximum": 30,
|
|
43
|
+
"default": 15
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
"required": [
|
|
47
|
+
"topicId"
|
|
48
|
+
],
|
|
49
|
+
"additionalProperties": false
|
|
50
|
+
},
|
|
51
|
+
"outputSchema": {
|
|
52
|
+
"type": "object",
|
|
53
|
+
"properties": {
|
|
54
|
+
"success": {
|
|
55
|
+
"const": true
|
|
56
|
+
},
|
|
57
|
+
"status": {
|
|
58
|
+
"const": "ok"
|
|
59
|
+
},
|
|
60
|
+
"coverage": {
|
|
61
|
+
"const": "first_page_only"
|
|
62
|
+
},
|
|
63
|
+
"topic": {
|
|
64
|
+
"type": "object",
|
|
65
|
+
"properties": {
|
|
66
|
+
"id": {
|
|
67
|
+
"type": "integer",
|
|
68
|
+
"minimum": 1
|
|
69
|
+
},
|
|
70
|
+
"title": {
|
|
71
|
+
"type": "string",
|
|
72
|
+
"minLength": 1
|
|
73
|
+
},
|
|
74
|
+
"url": {
|
|
75
|
+
"type": "string",
|
|
76
|
+
"pattern": "^https://(?:www\\.)?v2ex\\.com/t/\\d+"
|
|
77
|
+
},
|
|
78
|
+
"node": {
|
|
79
|
+
"type": "string"
|
|
80
|
+
},
|
|
81
|
+
"nodeTitle": {
|
|
82
|
+
"type": "string"
|
|
83
|
+
},
|
|
84
|
+
"author": {
|
|
85
|
+
"type": "string"
|
|
86
|
+
},
|
|
87
|
+
"repliesCount": {
|
|
88
|
+
"type": "integer",
|
|
89
|
+
"minimum": 0
|
|
90
|
+
},
|
|
91
|
+
"created": {
|
|
92
|
+
"type": "integer",
|
|
93
|
+
"minimum": 0
|
|
94
|
+
},
|
|
95
|
+
"content": {
|
|
96
|
+
"type": "string"
|
|
97
|
+
}
|
|
98
|
+
},
|
|
99
|
+
"required": [
|
|
100
|
+
"id",
|
|
101
|
+
"title",
|
|
102
|
+
"url",
|
|
103
|
+
"node",
|
|
104
|
+
"nodeTitle",
|
|
105
|
+
"author",
|
|
106
|
+
"repliesCount",
|
|
107
|
+
"created",
|
|
108
|
+
"content"
|
|
109
|
+
],
|
|
110
|
+
"additionalProperties": false
|
|
111
|
+
},
|
|
112
|
+
"replies": {
|
|
113
|
+
"type": "array",
|
|
114
|
+
"maxItems": 30,
|
|
115
|
+
"items": {
|
|
116
|
+
"type": "object",
|
|
117
|
+
"properties": {
|
|
118
|
+
"id": {
|
|
119
|
+
"type": "integer",
|
|
120
|
+
"minimum": 1
|
|
121
|
+
},
|
|
122
|
+
"author": {
|
|
123
|
+
"type": "string"
|
|
124
|
+
},
|
|
125
|
+
"created": {
|
|
126
|
+
"type": "integer",
|
|
127
|
+
"minimum": 0
|
|
128
|
+
},
|
|
129
|
+
"content": {
|
|
130
|
+
"type": "string"
|
|
131
|
+
}
|
|
132
|
+
},
|
|
133
|
+
"required": [
|
|
134
|
+
"id",
|
|
135
|
+
"author",
|
|
136
|
+
"created",
|
|
137
|
+
"content"
|
|
138
|
+
],
|
|
139
|
+
"additionalProperties": false
|
|
140
|
+
}
|
|
141
|
+
},
|
|
142
|
+
"sources": {
|
|
143
|
+
"type": "object",
|
|
144
|
+
"properties": {
|
|
145
|
+
"api": {
|
|
146
|
+
"type": "string",
|
|
147
|
+
"pattern": "^https://(?:www\\.)?v2ex\\.com/api/topics/show\\.json"
|
|
148
|
+
},
|
|
149
|
+
"repliesApi": {
|
|
150
|
+
"type": "string",
|
|
151
|
+
"pattern": "^https://(?:www\\.)?v2ex\\.com/api/replies/show\\.json"
|
|
152
|
+
},
|
|
153
|
+
"page": {
|
|
154
|
+
"type": "string",
|
|
155
|
+
"pattern": "^https://(?:www\\.)?v2ex\\.com/t/\\d+"
|
|
156
|
+
}
|
|
157
|
+
},
|
|
158
|
+
"required": [
|
|
159
|
+
"api",
|
|
160
|
+
"repliesApi",
|
|
161
|
+
"page"
|
|
162
|
+
],
|
|
163
|
+
"additionalProperties": false
|
|
164
|
+
}
|
|
165
|
+
},
|
|
166
|
+
"required": [
|
|
167
|
+
"success",
|
|
168
|
+
"status",
|
|
169
|
+
"coverage",
|
|
170
|
+
"topic",
|
|
171
|
+
"replies",
|
|
172
|
+
"sources"
|
|
173
|
+
],
|
|
174
|
+
"additionalProperties": false
|
|
175
|
+
},
|
|
176
|
+
"steps": [
|
|
177
|
+
{
|
|
178
|
+
"tool": "chrome_javascript",
|
|
179
|
+
"args": {
|
|
180
|
+
"code": "const topicId = Math.max(1, Math.floor(Number(input.topicId) || 0));\nconst limit = Math.max(1, Math.min(Number(input.limit) || 15, 30));\nconst origin = typeof location !== 'undefined' && typeof location.origin === 'string' && /^https:\\/\\/(?:www\\.)?v2ex\\.com$/i.test(location.origin) ? location.origin : '';\nif (!origin) {\n return { success: false, status: 'page_not_ready', topicId, message: 'V2EX page origin is not ready', source: 'https://www.v2ex.com/t/' + topicId };\n}\nconst topicUrl = new URL('/api/topics/show.json?id=' + topicId, origin).href;\nconst repliesUrl = new URL('/api/replies/show.json?topic_id=' + topicId + '&page=1', origin).href;\nlet topicRes;\nlet repliesRes;\ntry {\n [topicRes, repliesRes] = await Promise.all([\n fetch(topicUrl, { credentials: 'include', headers: { Accept: 'application/json' } }),\n fetch(repliesUrl, { credentials: 'include', headers: { Accept: 'application/json' } })\n ]);\n} catch (error) {\n return { success: false, status: 'fetch_error', topicId, message: String(error && error.message || error), source: topicUrl };\n}\nif (topicRes.status === 403 || repliesRes.status === 403) {\n const blocked = topicRes.status === 403 ? topicRes : repliesRes;\n return { success: false, status: 'requires_auth', topicId, requiresLogin: true, httpStatus: 403, message: 'V2EX topic requires authentication or is restricted', source: blocked.url || topicUrl };\n}\nif (topicRes.status === 429 || repliesRes.status === 429) {\n const limited = topicRes.status === 429 ? topicRes : repliesRes;\n return { success: false, status: 'rate_limited', topicId, httpStatus: 429, source: limited.url || topicUrl };\n}\nif (topicRes.status === 404 || repliesRes.status === 404) {\n const missing = topicRes.status === 404 ? topicRes : repliesRes;\n return { success: false, status: 'not_found', topicId, httpStatus: 404, source: missing.url || topicUrl };\n}\nif (!topicRes.ok) {\n return { success: false, status: 'http_error', topicId, httpStatus: topicRes.status, source: topicRes.url || topicUrl };\n}\nif (!repliesRes.ok) {\n return { success: false, status: 'http_error', topicId, httpStatus: repliesRes.status, source: repliesRes.url || repliesUrl };\n}\nlet topicList;\nlet replyList;\ntry {\n topicList = await topicRes.json();\n replyList = await repliesRes.json();\n} catch {\n return { success: false, status: 'invalid_json', topicId, source: topicRes.url || topicUrl };\n}\nif (!Array.isArray(topicList) || !Array.isArray(replyList)) {\n return { success: false, status: 'schema_changed', topicId, source: topicRes.url || topicUrl };\n}\nif (topicList.length === 0) {\n return { success: false, status: 'not_found', topicId, source: topicRes.url || topicUrl };\n}\nconst item = topicList[0];\nconst id = Math.floor(Number(item && item.id) || 0);\nconst title = String((item && item.title) || '').trim();\nconst page = String((item && item.url) || (id > 0 ? 'https://www.v2ex.com/t/' + id : '')).trim();\nif (!id || !title || !/^https:\\/\\/(?:www\\.)?v2ex\\.com\\/t\\/\\d+/.test(page)) {\n return { success: false, status: 'schema_changed', topicId, source: topicRes.url || topicUrl };\n}\nconst replies = replyList\n .map(reply => ({\n id: Math.floor(Number(reply && reply.id) || 0),\n author: String((reply && reply.member && reply.member.username) || '').trim(),\n created: Math.max(0, Math.floor(Number(reply && reply.created) || 0)),\n content: String((reply && reply.content) || '').trim().slice(0, 1500)\n }))\n .filter(reply => reply.id > 0)\n .slice(0, limit);\nreturn {\n success: true,\n status: 'ok',\n coverage: 'first_page_only',\n topic: {\n id,\n title,\n url: page,\n node: String((item && item.node && item.node.name) || '').trim(),\n nodeTitle: String((item && item.node && item.node.title) || '').trim(),\n author: String((item && item.member && item.member.username) || '').trim(),\n repliesCount: Math.max(replies.length, Math.floor(Number(item && item.replies) || 0)),\n created: Math.max(0, Math.floor(Number(item && item.created) || 0)),\n content: String((item && item.content) || '').trim().slice(0, 6000)\n },\n replies,\n sources: {\n api: topicRes.url || topicUrl,\n repliesApi: repliesRes.url || repliesUrl,\n page\n }\n};",
|
|
181
|
+
"timeoutMs": 30000
|
|
182
|
+
},
|
|
183
|
+
"resultPath": "/result"
|
|
184
|
+
}
|
|
185
|
+
],
|
|
186
|
+
"verification": {
|
|
187
|
+
"tool": "chrome_network_request",
|
|
188
|
+
"args": {
|
|
189
|
+
"url": "https://www.v2ex.com/api/topics/show.json?id={{topicId}}",
|
|
190
|
+
"method": "GET",
|
|
191
|
+
"timeout": 30000
|
|
192
|
+
},
|
|
193
|
+
"resultPath": "/response/body"
|
|
194
|
+
},
|
|
195
|
+
"tests": [
|
|
196
|
+
{
|
|
197
|
+
"inputs": {
|
|
198
|
+
"topicId": 1,
|
|
199
|
+
"limit": 5
|
|
200
|
+
},
|
|
201
|
+
"expect": {
|
|
202
|
+
"type": "object",
|
|
203
|
+
"properties": {
|
|
204
|
+
"success": {
|
|
205
|
+
"const": true
|
|
206
|
+
},
|
|
207
|
+
"topic": {
|
|
208
|
+
"type": "object",
|
|
209
|
+
"properties": {
|
|
210
|
+
"id": {
|
|
211
|
+
"const": 1
|
|
212
|
+
},
|
|
213
|
+
"title": {
|
|
214
|
+
"type": "string",
|
|
215
|
+
"minLength": 1
|
|
216
|
+
}
|
|
217
|
+
},
|
|
218
|
+
"required": [
|
|
219
|
+
"id",
|
|
220
|
+
"title"
|
|
221
|
+
]
|
|
222
|
+
},
|
|
223
|
+
"sources": {
|
|
224
|
+
"type": "object",
|
|
225
|
+
"required": [
|
|
226
|
+
"api",
|
|
227
|
+
"repliesApi",
|
|
228
|
+
"page"
|
|
229
|
+
]
|
|
230
|
+
}
|
|
231
|
+
},
|
|
232
|
+
"required": [
|
|
233
|
+
"success",
|
|
234
|
+
"topic",
|
|
235
|
+
"replies",
|
|
236
|
+
"sources"
|
|
237
|
+
]
|
|
238
|
+
},
|
|
239
|
+
"observe": {
|
|
240
|
+
"type": "array",
|
|
241
|
+
"minItems": 1,
|
|
242
|
+
"items": {
|
|
243
|
+
"type": "object",
|
|
244
|
+
"properties": {
|
|
245
|
+
"id": {
|
|
246
|
+
"const": 1
|
|
247
|
+
},
|
|
248
|
+
"title": {
|
|
249
|
+
"type": "string",
|
|
250
|
+
"minLength": 1
|
|
251
|
+
}
|
|
252
|
+
},
|
|
253
|
+
"required": [
|
|
254
|
+
"id",
|
|
255
|
+
"title"
|
|
256
|
+
]
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
},
|
|
260
|
+
{
|
|
261
|
+
"inputs": {
|
|
262
|
+
"topicId": 2,
|
|
263
|
+
"limit": 5
|
|
264
|
+
},
|
|
265
|
+
"expect": {
|
|
266
|
+
"type": "object",
|
|
267
|
+
"properties": {
|
|
268
|
+
"success": {
|
|
269
|
+
"const": true
|
|
270
|
+
},
|
|
271
|
+
"topic": {
|
|
272
|
+
"type": "object",
|
|
273
|
+
"properties": {
|
|
274
|
+
"id": {
|
|
275
|
+
"const": 2
|
|
276
|
+
},
|
|
277
|
+
"title": {
|
|
278
|
+
"type": "string",
|
|
279
|
+
"minLength": 1
|
|
280
|
+
}
|
|
281
|
+
},
|
|
282
|
+
"required": [
|
|
283
|
+
"id",
|
|
284
|
+
"title"
|
|
285
|
+
]
|
|
286
|
+
},
|
|
287
|
+
"sources": {
|
|
288
|
+
"type": "object",
|
|
289
|
+
"required": [
|
|
290
|
+
"api",
|
|
291
|
+
"repliesApi",
|
|
292
|
+
"page"
|
|
293
|
+
]
|
|
294
|
+
}
|
|
295
|
+
},
|
|
296
|
+
"required": [
|
|
297
|
+
"success",
|
|
298
|
+
"topic",
|
|
299
|
+
"replies",
|
|
300
|
+
"sources"
|
|
301
|
+
]
|
|
302
|
+
},
|
|
303
|
+
"observe": {
|
|
304
|
+
"type": "array",
|
|
305
|
+
"minItems": 1,
|
|
306
|
+
"items": {
|
|
307
|
+
"type": "object",
|
|
308
|
+
"properties": {
|
|
309
|
+
"id": {
|
|
310
|
+
"const": 2
|
|
311
|
+
},
|
|
312
|
+
"title": {
|
|
313
|
+
"type": "string",
|
|
314
|
+
"minLength": 1
|
|
315
|
+
}
|
|
316
|
+
},
|
|
317
|
+
"required": [
|
|
318
|
+
"id",
|
|
319
|
+
"title"
|
|
320
|
+
]
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
]
|
|
325
|
+
}
|