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.
@@ -0,0 +1,331 @@
1
+ {
2
+ "id": "reddit-subreddit-posts",
3
+ "name": "Reddit subreddit posts reader",
4
+ "description": "Read posts in a Reddit subreddit using Chrome's session via same-origin JSON with visible shreddit-post DOM fallback.",
5
+ "source": {
6
+ "type": "builtin",
7
+ "urls": [
8
+ "https://www.reddit.com/r/programming/hot/",
9
+ "https://www.reddit.com/r/javascript/hot/"
10
+ ]
11
+ },
12
+ "domains": [
13
+ "www.reddit.com",
14
+ "reddit.com",
15
+ "old.reddit.com"
16
+ ],
17
+ "keywords": [
18
+ "reddit",
19
+ "红迪",
20
+ "subreddit",
21
+ "posts",
22
+ "feed",
23
+ "hot",
24
+ "new",
25
+ "top",
26
+ "板块",
27
+ "帖子",
28
+ "Reddit帖子",
29
+ "版块热帖"
30
+ ],
31
+ "startUrl": "https://www.reddit.com/r/{{subreddit}}/{{sort}}/",
32
+ "inputSchema": {
33
+ "type": "object",
34
+ "properties": {
35
+ "subreddit": {
36
+ "type": "string",
37
+ "pattern": "^[A-Za-z0-9_]{2,50}$"
38
+ },
39
+ "sort": {
40
+ "type": "string",
41
+ "enum": [
42
+ "hot",
43
+ "new",
44
+ "top",
45
+ "rising"
46
+ ],
47
+ "default": "hot"
48
+ },
49
+ "limit": {
50
+ "type": "integer",
51
+ "minimum": 1,
52
+ "maximum": 20,
53
+ "default": 8
54
+ }
55
+ },
56
+ "required": [
57
+ "subreddit"
58
+ ],
59
+ "additionalProperties": false
60
+ },
61
+ "outputSchema": {
62
+ "oneOf": [
63
+ {
64
+ "type": "object",
65
+ "properties": {
66
+ "success": {
67
+ "const": true
68
+ },
69
+ "status": {
70
+ "const": "ok"
71
+ },
72
+ "subreddit": {
73
+ "type": "string",
74
+ "minLength": 1
75
+ },
76
+ "sort": {
77
+ "type": "string"
78
+ },
79
+ "posts": {
80
+ "type": "array",
81
+ "minItems": 1,
82
+ "maxItems": 20,
83
+ "items": {
84
+ "type": "object",
85
+ "properties": {
86
+ "id": {
87
+ "type": "string",
88
+ "minLength": 1
89
+ },
90
+ "title": {
91
+ "type": "string",
92
+ "minLength": 1
93
+ },
94
+ "author": {
95
+ "type": "string"
96
+ },
97
+ "score": {
98
+ "type": "integer"
99
+ },
100
+ "commentsCount": {
101
+ "type": "integer",
102
+ "minimum": 0
103
+ },
104
+ "url": {
105
+ "type": "string",
106
+ "pattern": "^https://(?:(?:www|old|sh|new)\\.)?reddit\\.com/r/"
107
+ },
108
+ "externalUrl": {
109
+ "type": "string"
110
+ },
111
+ "createdUtc": {
112
+ "type": "integer",
113
+ "minimum": 0
114
+ }
115
+ },
116
+ "required": [
117
+ "id",
118
+ "title",
119
+ "author",
120
+ "score",
121
+ "commentsCount",
122
+ "url",
123
+ "externalUrl",
124
+ "createdUtc"
125
+ ],
126
+ "additionalProperties": false
127
+ }
128
+ },
129
+ "sources": {
130
+ "type": "object",
131
+ "properties": {
132
+ "api": {
133
+ "oneOf": [
134
+ {
135
+ "type": "string",
136
+ "pattern": "^https://(?:(?:www|old|sh|new)\\.)?reddit\\.com/"
137
+ },
138
+ {
139
+ "type": "null"
140
+ }
141
+ ]
142
+ },
143
+ "page": {
144
+ "type": "string",
145
+ "pattern": "^https://(?:(?:www|old|sh|new)\\.)?reddit\\.com/"
146
+ }
147
+ },
148
+ "required": [
149
+ "api",
150
+ "page"
151
+ ],
152
+ "additionalProperties": false
153
+ }
154
+ },
155
+ "required": [
156
+ "success",
157
+ "status",
158
+ "subreddit",
159
+ "sort",
160
+ "posts",
161
+ "sources"
162
+ ],
163
+ "additionalProperties": false
164
+ },
165
+ {
166
+ "type": "object",
167
+ "properties": {
168
+ "success": {
169
+ "const": true
170
+ },
171
+ "status": {
172
+ "const": "empty"
173
+ },
174
+ "subreddit": {
175
+ "type": "string",
176
+ "minLength": 1
177
+ },
178
+ "sort": {
179
+ "type": "string"
180
+ },
181
+ "posts": {
182
+ "type": "array",
183
+ "minItems": 0,
184
+ "maxItems": 0
185
+ },
186
+ "sources": {
187
+ "type": "object",
188
+ "properties": {
189
+ "api": {
190
+ "oneOf": [
191
+ {
192
+ "type": "string",
193
+ "pattern": "^https://(?:(?:www|old|sh|new)\\.)?reddit\\.com/"
194
+ },
195
+ {
196
+ "type": "null"
197
+ }
198
+ ]
199
+ },
200
+ "page": {
201
+ "type": "string",
202
+ "pattern": "^https://(?:(?:www|old|sh|new)\\.)?reddit\\.com/"
203
+ }
204
+ },
205
+ "required": [
206
+ "api",
207
+ "page"
208
+ ],
209
+ "additionalProperties": false
210
+ }
211
+ },
212
+ "required": [
213
+ "success",
214
+ "status",
215
+ "subreddit",
216
+ "sort",
217
+ "posts",
218
+ "sources"
219
+ ],
220
+ "additionalProperties": false
221
+ }
222
+ ]
223
+ },
224
+ "steps": [
225
+ {
226
+ "tool": "chrome_javascript",
227
+ "args": {
228
+ "code": "const subreddit = String(input.subreddit || '').trim();\nconst rawSort = String((input && input.sort) || '').trim().toLowerCase();\nconst sort = ['hot', 'new', 'top', 'rising'].includes(rawSort) ? rawSort : 'hot';\nconst limit = Math.max(1, Math.min(Number(input.limit) || 8, 20));\nconst fallbackUrl = 'https://www.reddit.com/r/' + encodeURIComponent(subreddit) + '/' + encodeURIComponent(sort) + '/';\nconst origin = typeof location !== 'undefined' && typeof location.origin === 'string' && /^https:\\/\\/(?:(?:www|old|new|sh)\\.)?reddit\\.com$/i.test(location.origin) ? location.origin : '';\nif (!origin) {\n return { success: false, status: 'page_not_ready', subreddit, sort, message: 'Reddit page origin is not ready', source: fallbackUrl };\n}\nconst pageUrl = new URL('/r/' + encodeURIComponent(subreddit) + '/' + encodeURIComponent(sort) + '/', origin).href;\nconst fetchLimit = Math.min(100, Math.max(limit * 2, 25));\nconst jsonUrl = new URL('/r/' + encodeURIComponent(subreddit) + '/' + encodeURIComponent(sort) + '.json?limit=' + fetchLimit + '&raw_json=1', origin).href;\nconst redditPostUrlRe = /^https:\\/\\/(?:(?:www|old|sh|new)\\.)?reddit\\.com\\/r\\//i;\nlet blockedStatus = null;\ntry {\n const response = await fetch(jsonUrl, { credentials: 'include', headers: { Accept: 'application/json' } });\n if (response.status === 429) {\n blockedStatus = { success: false, status: 'rate_limited', subreddit, sort, httpStatus: 429, source: response.url || jsonUrl };\n } else if (response.status === 404) {\n return { success: false, status: 'not_found', subreddit, sort, httpStatus: 404, source: response.url || jsonUrl };\n } else if (response.status === 401) {\n blockedStatus = { success: false, status: 'requires_auth', subreddit, sort, requiresLogin: true, httpStatus: 401, source: response.url || jsonUrl };\n } else if (response.status === 403) {\n let reason = '';\n try {\n const errBody = await response.json();\n reason = String((errBody && (errBody.reason || errBody.message)) || '').toLowerCase();\n } catch {}\n if (reason.includes('quarantin') || reason.includes('over18')) {\n blockedStatus = { success: false, status: 'over18_or_quarantined', subreddit, sort, httpStatus: 403, message: 'Reddit subreddit is quarantined or requires 18+ confirmation', source: response.url || jsonUrl };\n } else if (reason.includes('private')) {\n blockedStatus = { success: false, status: 'requires_auth', subreddit, sort, requiresLogin: true, httpStatus: 403, message: 'Reddit subreddit is private or requires authentication', source: response.url || jsonUrl };\n } else {\n blockedStatus = { success: false, status: 'blocked', subreddit, sort, httpStatus: 403, message: 'Reddit returned HTTP 403 for this subreddit', source: response.url || jsonUrl };\n }\n } else if (response.ok) {\n const data = await response.json();\n const reason = String((data && data.reason) || '').toLowerCase();\n if (reason.includes('quarantin') || reason.includes('over18')) {\n blockedStatus = { success: false, status: 'over18_or_quarantined', subreddit, sort, message: 'Reddit subreddit is quarantined or requires 18+ confirmation', source: response.url || jsonUrl };\n }\n const children = data && data.data && Array.isArray(data.data.children) ? data.data.children : null;\n if (children) {\n if (children.length === 0) {\n return { success: true, status: 'empty', subreddit, sort, posts: [], sources: { api: response.url || jsonUrl, page: pageUrl } };\n }\n const posts = children.map(entry => {\n const d = (entry && entry.data) || {};\n if (d.promoted) return null;\n const permalink = String(d.permalink || '').trim();\n return {\n id: String(d.id || '').trim(),\n title: String(d.title || '').trim(),\n author: String(d.author || '').trim(),\n score: Math.floor(Number(d.score) || 0),\n commentsCount: Math.max(0, Math.floor(Number(d.num_comments) || 0)),\n url: permalink ? new URL(permalink, 'https://www.reddit.com').href : '',\n externalUrl: String(d.url || '').trim(),\n createdUtc: Math.max(0, Math.floor(Number(d.created_utc) || 0))\n };\n }).filter(post => post && post.id && post.title && redditPostUrlRe.test(post.url)).slice(0, limit);\n if (posts.length > 0) {\n return { success: true, status: 'ok', subreddit, sort, posts, sources: { api: response.url || jsonUrl, page: pageUrl } };\n }\n }\n }\n} catch {\n // Fall back to visible DOM below.\n}\nif (typeof document !== 'undefined' && document && typeof document.querySelectorAll === 'function') {\n const shredditPosts = Array.from(document.querySelectorAll('shreddit-post')).map(el => {\n const hasPromoted = (typeof el.hasAttribute === 'function' && el.hasAttribute('promoted')) || (typeof el.getAttribute === 'function' && el.getAttribute('promoted') !== null && el.getAttribute('promoted') !== undefined);\n if (hasPromoted) return null;\n const rawId = String(el.getAttribute('id') || '').replace(/^t3_/, '').trim();\n const permalink = String(el.getAttribute('permalink') || '').trim();\n const title = String(el.getAttribute('post-title') || '').trim();\n return {\n id: rawId,\n title,\n author: String(el.getAttribute('author') || '').trim(),\n score: Math.floor(Number(el.getAttribute('score')) || 0),\n commentsCount: Math.max(0, Math.floor(Number(el.getAttribute('comment-count')) || 0)),\n url: permalink ? new URL(permalink, origin).href : '',\n externalUrl: String(el.getAttribute('content-href') || '').trim(),\n createdUtc: 0\n };\n }).filter(post => post && post.id && post.title && redditPostUrlRe.test(post.url)).slice(0, limit);\n if (shredditPosts.length > 0) {\n return { success: true, status: 'ok', subreddit, sort, posts: shredditPosts, sources: { api: null, page: location.href || pageUrl } };\n }\n const oldPosts = Array.from(document.querySelectorAll('#siteTable .thing.link, .thing.link')).map(el => {\n const cls = String(el.className || (typeof el.getAttribute === 'function' ? el.getAttribute('class') : '') || '');\n if (/\\bpromoted\\b/i.test(cls)) return null;\n const titleEl = typeof el.querySelector === 'function' ? el.querySelector('a.title') : null;\n const title = String((titleEl && (titleEl.innerText || titleEl.textContent)) || '').trim();\n const permalink = String((typeof el.getAttribute === 'function' && el.getAttribute('data-permalink')) || '').trim();\n const rawHref = String((typeof el.getAttribute === 'function' && el.getAttribute('data-url')) || (titleEl && typeof titleEl.getAttribute === 'function' && titleEl.getAttribute('href')) || '').trim();\n let externalUrl = rawHref;\n if (rawHref && rawHref.startsWith('/')) {\n try { externalUrl = new URL(rawHref, origin).href; } catch {}\n }\n const rawCommentsCount = typeof el.getAttribute === 'function' ? el.getAttribute('data-comments-count') : null;\n const commentsLink = rawCommentsCount === null && typeof el.querySelector === 'function' ? el.querySelector('a.comments') : null;\n const commentsMatch = commentsLink ? String(commentsLink.innerText || commentsLink.textContent || '').match(/\\d+/) : null;\n const rawTs = typeof el.getAttribute === 'function' ? Number(el.getAttribute('data-timestamp')) : 0;\n return {\n id: String((typeof el.getAttribute === 'function' && el.getAttribute('data-fullname')) || '').replace(/^t3_/, '').trim(),\n title,\n author: String((typeof el.getAttribute === 'function' && el.getAttribute('data-author')) || '').trim(),\n score: Math.floor(Number(typeof el.getAttribute === 'function' ? el.getAttribute('data-score') : 0) || 0),\n commentsCount: Math.max(0, Math.floor(Number(rawCommentsCount !== null && rawCommentsCount !== undefined ? rawCommentsCount : (commentsMatch ? commentsMatch[0] : 0)) || 0)),\n url: permalink ? new URL(permalink, origin).href : '',\n externalUrl,\n createdUtc: rawTs > 0 ? Math.floor(rawTs / 1000) : 0\n };\n }).filter(post => post && post.id && post.title && redditPostUrlRe.test(post.url)).slice(0, limit);\n if (oldPosts.length > 0) {\n return { success: true, status: 'ok', subreddit, sort, posts: oldPosts, sources: { api: null, page: location.href || pageUrl } };\n }\n}\nconst pathname = String(location.pathname || '');\nif (typeof document !== 'undefined' && document && typeof document.querySelector === 'function') {\n if (/^\\/over18(?:\\/|$)/i.test(pathname) || document.querySelector('form[action*=\"/over18\"], shreddit-over18-interstitial, [data-testid=\"nsfw-interstitial\"], button[name=\"over18\"]')) {\n return { success: false, status: 'over18_or_quarantined', subreddit, sort, message: 'Reddit requires NSFW (18+) confirmation for this subreddit', source: location.href || pageUrl };\n }\n if (document.querySelector('.quarantine-notice, form[action*=\"/quarantine\"], [data-testid=\"quarantine-interstitial\"]')) {\n return { success: false, status: 'over18_or_quarantined', subreddit, sort, message: 'This Reddit subreddit is quarantined', source: location.href || pageUrl };\n }\n}\nif (blockedStatus) return blockedStatus;\nif (/^\\/login(?:\\/|$)/i.test(pathname) || (typeof document !== 'undefined' && document && typeof document.querySelector === 'function' && document.querySelector('form[action*=\"/login\"], input[name=\"username\"]'))) {\n return { success: false, status: 'requires_auth', subreddit, sort, requiresLogin: true, message: 'Reddit requires authentication for this page', source: location.href || pageUrl };\n}\nreturn { success: false, status: 'blocked', subreddit, sort, message: 'Reddit posts were not readable via JSON API or visible DOM', source: location.href || pageUrl };",
229
+ "timeoutMs": 25000
230
+ },
231
+ "resultPath": "/result"
232
+ }
233
+ ],
234
+ "verification": {
235
+ "tool": "chrome_read_dom",
236
+ "args": {
237
+ "format": "compact",
238
+ "selector": "main",
239
+ "activeViewportOnly": false,
240
+ "limit": 80,
241
+ "maxTextLength": 220
242
+ },
243
+ "resultPath": "/treeString"
244
+ },
245
+ "tests": [
246
+ {
247
+ "inputs": {
248
+ "subreddit": "programming",
249
+ "sort": "hot",
250
+ "limit": 3
251
+ },
252
+ "expect": {
253
+ "type": "object",
254
+ "properties": {
255
+ "success": {
256
+ "const": true
257
+ },
258
+ "status": {
259
+ "const": "ok"
260
+ },
261
+ "subreddit": {
262
+ "const": "programming"
263
+ },
264
+ "posts": {
265
+ "type": "array",
266
+ "minItems": 1
267
+ },
268
+ "sources": {
269
+ "type": "object",
270
+ "required": [
271
+ "page"
272
+ ]
273
+ }
274
+ },
275
+ "required": [
276
+ "success",
277
+ "status",
278
+ "subreddit",
279
+ "posts",
280
+ "sources"
281
+ ]
282
+ },
283
+ "observe": {
284
+ "type": "string",
285
+ "pattern": "programming|r/programming|Reddit"
286
+ }
287
+ },
288
+ {
289
+ "inputs": {
290
+ "subreddit": "javascript",
291
+ "sort": "hot",
292
+ "limit": 3
293
+ },
294
+ "expect": {
295
+ "type": "object",
296
+ "properties": {
297
+ "success": {
298
+ "const": true
299
+ },
300
+ "status": {
301
+ "const": "ok"
302
+ },
303
+ "subreddit": {
304
+ "const": "javascript"
305
+ },
306
+ "posts": {
307
+ "type": "array",
308
+ "minItems": 1
309
+ },
310
+ "sources": {
311
+ "type": "object",
312
+ "required": [
313
+ "page"
314
+ ]
315
+ }
316
+ },
317
+ "required": [
318
+ "success",
319
+ "status",
320
+ "subreddit",
321
+ "posts",
322
+ "sources"
323
+ ]
324
+ },
325
+ "observe": {
326
+ "type": "string",
327
+ "pattern": "javascript|r/javascript|Reddit"
328
+ }
329
+ }
330
+ ]
331
+ }
@@ -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
+ }