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/dist/v5/cli.cjs +1207 -335
- package/dist/v5/extension/background.js +8649 -6972
- package/dist/v5/extension/browserpaw-build.json +52 -45
- package/dist/v5/extension/chunks/{popup-DjxqduQH.js → popup-BSqTH70w.js} +39 -6
- package/dist/v5/extension/content-scripts/agent-cursor.js +30 -14
- package/dist/v5/extension/inject-scripts/accessibility-tree-helper.js +377 -229
- package/dist/v5/extension/inject-scripts/keyboard-helper.js +12 -2
- package/dist/v5/extension/inject-scripts/network-helper.js +166 -1
- package/dist/v5/extension/inject-scripts/screenshot-helper.js +397 -356
- package/dist/v5/extension/inpage-engine.js +7070 -6933
- package/dist/v5/extension/manifest.json +1 -1
- package/dist/v5/extension/popup.html +1 -1
- package/dist/v5/host.cjs +445 -73
- package/dist/v5/recipes/bilibili-popular-videos.json +364 -0
- package/dist/v5/recipes/bilibili-video-detail.json +395 -0
- package/dist/v5/recipes/github-issue-thread.json +313 -0
- package/dist/v5/recipes/github-releases.json +86 -45
- 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 +93 -48
- package/dist/v5/recipes/npm-compare.json +6 -4
- 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 +13 -41
- package/dist/v5/recipes/x-visible-thread.json +40 -83
- package/dist/v5/recipes/youtube-search-videos.json +279 -0
- package/dist/v5/recipes/youtube-video-read.json +349 -0
- package/dist/v5/skill/browserpaw/SKILL.md +4 -4
- 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/github-issue-thread.json +313 -0
- package/dist/v5/skill/browserpaw/assets/recipes/github-releases.json +86 -45
- 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 +93 -48
- package/dist/v5/skill/browserpaw/assets/recipes/npm-compare.json +6 -4
- 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 +13 -41
- package/dist/v5/skill/browserpaw/assets/recipes/x-visible-thread.json +40 -83
- 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/recipe-contract.md +4 -3
- package/package.json +1 -1
|
@@ -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
|
+
}
|
|
@@ -0,0 +1,332 @@
|
|
|
1
|
+
{
|
|
2
|
+
"id": "x-profile-posts",
|
|
3
|
+
"name": "X profile and visible posts reader",
|
|
4
|
+
"description": "Read an X account's visible profile summary and bounded recent posts in Chrome; detects login walls and loading timeouts cleanly without fabricating posts.",
|
|
5
|
+
"source": {
|
|
6
|
+
"type": "builtin",
|
|
7
|
+
"urls": [
|
|
8
|
+
"https://x.com/github",
|
|
9
|
+
"https://x.com/reactjs"
|
|
10
|
+
]
|
|
11
|
+
},
|
|
12
|
+
"domains": [
|
|
13
|
+
"x.com",
|
|
14
|
+
"twitter.com"
|
|
15
|
+
],
|
|
16
|
+
"keywords": [
|
|
17
|
+
"x",
|
|
18
|
+
"twitter",
|
|
19
|
+
"profile",
|
|
20
|
+
"tweets",
|
|
21
|
+
"user",
|
|
22
|
+
"posts",
|
|
23
|
+
"timeline",
|
|
24
|
+
"主页",
|
|
25
|
+
"推特主页",
|
|
26
|
+
"推特博主",
|
|
27
|
+
"用户推文",
|
|
28
|
+
"X主页"
|
|
29
|
+
],
|
|
30
|
+
"startUrl": "https://x.com/{{username}}",
|
|
31
|
+
"inputSchema": {
|
|
32
|
+
"type": "object",
|
|
33
|
+
"properties": {
|
|
34
|
+
"username": {
|
|
35
|
+
"type": "string",
|
|
36
|
+
"description": "X username without leading @",
|
|
37
|
+
"pattern": "^[A-Za-z0-9_]{1,15}$"
|
|
38
|
+
},
|
|
39
|
+
"limit": {
|
|
40
|
+
"type": "integer",
|
|
41
|
+
"minimum": 1,
|
|
42
|
+
"maximum": 20,
|
|
43
|
+
"default": 8
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
"required": [
|
|
47
|
+
"username"
|
|
48
|
+
],
|
|
49
|
+
"additionalProperties": false
|
|
50
|
+
},
|
|
51
|
+
"outputSchema": {
|
|
52
|
+
"oneOf": [
|
|
53
|
+
{
|
|
54
|
+
"type": "object",
|
|
55
|
+
"properties": {
|
|
56
|
+
"success": {
|
|
57
|
+
"const": true
|
|
58
|
+
},
|
|
59
|
+
"status": {
|
|
60
|
+
"const": "ok"
|
|
61
|
+
},
|
|
62
|
+
"coverage": {
|
|
63
|
+
"const": "visible_only"
|
|
64
|
+
},
|
|
65
|
+
"profile": {
|
|
66
|
+
"type": "object",
|
|
67
|
+
"properties": {
|
|
68
|
+
"username": {
|
|
69
|
+
"type": "string",
|
|
70
|
+
"minLength": 1
|
|
71
|
+
},
|
|
72
|
+
"displayName": {
|
|
73
|
+
"type": "string"
|
|
74
|
+
},
|
|
75
|
+
"bio": {
|
|
76
|
+
"type": "string"
|
|
77
|
+
},
|
|
78
|
+
"url": {
|
|
79
|
+
"type": "string",
|
|
80
|
+
"pattern": "^https://(?:x|twitter)\\.com/[A-Za-z0-9_]{1,15}$"
|
|
81
|
+
}
|
|
82
|
+
},
|
|
83
|
+
"required": [
|
|
84
|
+
"username",
|
|
85
|
+
"displayName",
|
|
86
|
+
"bio",
|
|
87
|
+
"url"
|
|
88
|
+
],
|
|
89
|
+
"additionalProperties": false
|
|
90
|
+
},
|
|
91
|
+
"posts": {
|
|
92
|
+
"type": "array",
|
|
93
|
+
"minItems": 1,
|
|
94
|
+
"maxItems": 20,
|
|
95
|
+
"items": {
|
|
96
|
+
"type": "object",
|
|
97
|
+
"properties": {
|
|
98
|
+
"text": {
|
|
99
|
+
"type": "string",
|
|
100
|
+
"minLength": 1
|
|
101
|
+
},
|
|
102
|
+
"author": {
|
|
103
|
+
"type": "string"
|
|
104
|
+
},
|
|
105
|
+
"url": {
|
|
106
|
+
"type": "string",
|
|
107
|
+
"pattern": "^https://(?:x|twitter)\\.com/.+/status/\\d+"
|
|
108
|
+
},
|
|
109
|
+
"publishedAt": {
|
|
110
|
+
"type": "string"
|
|
111
|
+
}
|
|
112
|
+
},
|
|
113
|
+
"required": [
|
|
114
|
+
"text",
|
|
115
|
+
"author",
|
|
116
|
+
"url",
|
|
117
|
+
"publishedAt"
|
|
118
|
+
],
|
|
119
|
+
"additionalProperties": false
|
|
120
|
+
}
|
|
121
|
+
},
|
|
122
|
+
"sources": {
|
|
123
|
+
"type": "object",
|
|
124
|
+
"properties": {
|
|
125
|
+
"page": {
|
|
126
|
+
"type": "string",
|
|
127
|
+
"pattern": "^https://(?:x|twitter)\\.com/"
|
|
128
|
+
}
|
|
129
|
+
},
|
|
130
|
+
"required": [
|
|
131
|
+
"page"
|
|
132
|
+
],
|
|
133
|
+
"additionalProperties": false
|
|
134
|
+
}
|
|
135
|
+
},
|
|
136
|
+
"required": [
|
|
137
|
+
"success",
|
|
138
|
+
"status",
|
|
139
|
+
"coverage",
|
|
140
|
+
"profile",
|
|
141
|
+
"posts",
|
|
142
|
+
"sources"
|
|
143
|
+
],
|
|
144
|
+
"additionalProperties": false
|
|
145
|
+
},
|
|
146
|
+
{
|
|
147
|
+
"type": "object",
|
|
148
|
+
"properties": {
|
|
149
|
+
"success": {
|
|
150
|
+
"const": true
|
|
151
|
+
},
|
|
152
|
+
"status": {
|
|
153
|
+
"const": "empty"
|
|
154
|
+
},
|
|
155
|
+
"coverage": {
|
|
156
|
+
"const": "visible_only"
|
|
157
|
+
},
|
|
158
|
+
"profile": {
|
|
159
|
+
"type": "object",
|
|
160
|
+
"properties": {
|
|
161
|
+
"username": {
|
|
162
|
+
"type": "string",
|
|
163
|
+
"minLength": 1
|
|
164
|
+
},
|
|
165
|
+
"displayName": {
|
|
166
|
+
"type": "string"
|
|
167
|
+
},
|
|
168
|
+
"bio": {
|
|
169
|
+
"type": "string"
|
|
170
|
+
},
|
|
171
|
+
"url": {
|
|
172
|
+
"type": "string",
|
|
173
|
+
"pattern": "^https://(?:x|twitter)\\.com/[A-Za-z0-9_]{1,15}$"
|
|
174
|
+
}
|
|
175
|
+
},
|
|
176
|
+
"required": [
|
|
177
|
+
"username",
|
|
178
|
+
"displayName",
|
|
179
|
+
"bio",
|
|
180
|
+
"url"
|
|
181
|
+
],
|
|
182
|
+
"additionalProperties": false
|
|
183
|
+
},
|
|
184
|
+
"posts": {
|
|
185
|
+
"type": "array",
|
|
186
|
+
"minItems": 0,
|
|
187
|
+
"maxItems": 0
|
|
188
|
+
},
|
|
189
|
+
"sources": {
|
|
190
|
+
"type": "object",
|
|
191
|
+
"properties": {
|
|
192
|
+
"page": {
|
|
193
|
+
"type": "string",
|
|
194
|
+
"pattern": "^https://(?:x|twitter)\\.com/"
|
|
195
|
+
}
|
|
196
|
+
},
|
|
197
|
+
"required": [
|
|
198
|
+
"page"
|
|
199
|
+
],
|
|
200
|
+
"additionalProperties": false
|
|
201
|
+
}
|
|
202
|
+
},
|
|
203
|
+
"required": [
|
|
204
|
+
"success",
|
|
205
|
+
"status",
|
|
206
|
+
"coverage",
|
|
207
|
+
"profile",
|
|
208
|
+
"posts",
|
|
209
|
+
"sources"
|
|
210
|
+
],
|
|
211
|
+
"additionalProperties": false
|
|
212
|
+
}
|
|
213
|
+
]
|
|
214
|
+
},
|
|
215
|
+
"steps": [
|
|
216
|
+
{
|
|
217
|
+
"tool": "chrome_javascript",
|
|
218
|
+
"args": {
|
|
219
|
+
"code": "const username = String(input.username || '').trim().replace(/^@/, '');\nconst limit = Math.max(1, Math.min(Number(input.limit) || 8, 20));\nconst canonicalPageUrl = 'https://x.com/' + encodeURIComponent(username);\nconst origin = typeof location !== 'undefined' && typeof location.origin === 'string' && /^https:\\/\\/(?:mobile\\.)?(?:x|twitter)\\.com$/i.test(location.origin) ? location.origin : '';\nif (!origin) {\n return { success: false, status: 'page_not_ready', requiresLogin: false, message: 'X profile page origin is not ready', username, source: canonicalPageUrl };\n}\nconst canonicalOrigin = origin.replace(/^https:\\/\\/mobile\\./i, 'https://');\nconst source = new URL('/' + encodeURIComponent(username), 'https://x.com');\nconst loginPath = /^\\/(?:i\\/flow\\/login|login)(?:\\/|$)/.test(String(location.pathname || ''));\nconst isVisible = element => {\n if (!element || !element.getBoundingClientRect) return false;\n if (element.hidden === true) return false;\n if (typeof element.getAttribute === 'function') {\n if (element.getAttribute('aria-hidden') === 'true') return false;\n const hiddenAttr = element.getAttribute('hidden');\n if (hiddenAttr !== null && hiddenAttr !== undefined) return false;\n }\n if (element.style && (element.style.display === 'none' || element.style.visibility === 'hidden')) return false;\n const rect = element.getBoundingClientRect();\n const style = typeof getComputedStyle === 'function' ? getComputedStyle(element) : null;\n return Boolean(rect) && rect.width > 0 && rect.height > 0 && (!style || (style.display !== 'none' && style.visibility !== 'hidden'));\n};\nconst isArticleVisible = element => {\n if (!element) return false;\n if (element.hidden === true) return false;\n if (typeof element.getAttribute === 'function') {\n if (element.getAttribute('aria-hidden') === 'true') return false;\n const hiddenAttr = element.getAttribute('hidden');\n if (hiddenAttr !== null && hiddenAttr !== undefined) return false;\n }\n if (element.style && (element.style.display === 'none' || element.style.visibility === 'hidden')) return false;\n const style = typeof getComputedStyle === 'function' ? getComputedStyle(element) : null;\n if (style && (style.display === 'none' || style.visibility === 'hidden')) return false;\n if (typeof element.getBoundingClientRect === 'function') {\n const rect = element.getBoundingClientRect();\n if (!rect || rect.width <= 0 || rect.height <= 0) return false;\n }\n return true;\n};\nconst hasVisibleLoginForm = () => {\n if (typeof document === 'undefined' || !document || typeof document.querySelectorAll !== 'function') return false;\n return Array.from(document.querySelectorAll('form')).some(form =>\n isVisible(form) && Array.from(form.querySelectorAll('input[autocomplete=\"username\"], input[name=\"text\"], input[type=\"password\"]')).some(isVisible)\n );\n};\nconst hasEmptyProfileState = () => {\n if (typeof document === 'undefined' || !document || typeof document.querySelector !== 'function') return false;\n const el = document.querySelector('main [data-testid=\"emptyState\"]') || document.querySelector('[data-testid=\"emptyState\"]');\n if (!isVisible(el)) return false;\n const text = String(el.innerText || el.textContent || '').replace(/\\s+/g, ' ').trim().toLowerCase();\n return text.includes(\"hasn't posted\") || text.includes(\"haven't posted\") || text.includes('还没有发帖') || text.includes('尚未发布');\n};\nconst hasMissingAccount = () => {\n if (typeof document === 'undefined' || !document || typeof document.querySelector !== 'function') return false;\n const el = document.querySelector('main [data-testid=\"emptyState\"]') || document.querySelector('[data-testid=\"emptyState\"]');\n if (!isVisible(el)) return false;\n const text = String(el.innerText || el.textContent || '').replace(/\\s+/g, ' ').trim().toLowerCase();\n return text.includes(\"account doesn't exist\") || text.includes('此账号不存在') || text.includes('account suspended');\n};\nconst queryArticles = () => {\n if (typeof document === 'undefined' || !document || typeof document.querySelectorAll !== 'function') return [];\n const primary = Array.from(document.querySelectorAll('article[data-testid=\"tweet\"]'));\n return primary.length ? primary : Array.from(document.querySelectorAll('article'));\n};\nconst isInsideQuote = (article, el) => {\n if (!el || typeof el.closest !== 'function') return false;\n const quoteWrap = el.closest('div[role=\"link\"], [data-testid=\"quoteTweet\"], [data-testid=\"card.wrapper\"]');\n if (quoteWrap && quoteWrap !== article && (typeof article.contains !== 'function' || article.contains(quoteWrap))) return true;\n const nestedArticle = el.closest('article');\n return Boolean(nestedArticle && nestedArticle !== article);\n};\nconst isPromoted = article => {\n if (!article) return false;\n if (typeof article.closest === 'function' && article.closest('[data-testid=\"placementTracking\"]')) return true;\n if (typeof article.querySelector === 'function') {\n if (article.querySelector('[data-testid=\"placementTracking\"]')) return true;\n const social = article.querySelector('[data-testid=\"socialContext\"], [data-testid=\"SocialContext\"]');\n if (social && !isInsideQuote(article, social)) {\n const sText = String(social.innerText || social.textContent || '').trim();\n if (/\\b(?:promoted|sponsored|ad)\\b|推广|广告/i.test(sText)) return true;\n }\n }\n if (typeof article.querySelectorAll === 'function') {\n const spans = Array.from(article.querySelectorAll('span'));\n if (spans.some(sp => {\n if (typeof sp.closest === 'function' && sp.closest('[data-testid=\"tweetText\"], [data-testid=\"User-Name\"]')) return false;\n if (isInsideQuote(article, sp)) return false;\n const t = String(sp.innerText || sp.textContent || '').trim();\n return /^(?:Ad|Promoted|Sponsored|广告|推广)$/i.test(t);\n })) return true;\n }\n return false;\n};\nconst isRepost = (article, statusAuthor) => {\n const social = article && typeof article.querySelector === 'function'\n ? article.querySelector('[data-testid=\"socialContext\"], [data-testid=\"SocialContext\"]')\n : null;\n if (social && !isInsideQuote(article, social)) {\n const sText = String(social.innerText || social.textContent || '').trim();\n if (/\\b(?:reposted|retweeted)\\b|转推|转帖/i.test(sText)) return true;\n if (/\\bpinned\\b|置顶/i.test(sText)) return Boolean(statusAuthor && statusAuthor.toLowerCase() !== username.toLowerCase());\n }\n return Boolean(statusAuthor && statusAuthor.toLowerCase() !== username.toLowerCase());\n};\nconst sleep = ms => new Promise(resolve => setTimeout(resolve, ms));\nlet articles = [];\nlet loginForm = false;\nlet emptyState = false;\nlet missingAccount = false;\nfor (let attempt = 0; attempt < 40; attempt += 1) {\n if (loginPath) break;\n articles = queryArticles().filter(article => isArticleVisible(article) && !isPromoted(article));\n if (articles.length) break;\n loginForm = hasVisibleLoginForm();\n if (loginForm) break;\n missingAccount = hasMissingAccount();\n if (missingAccount) break;\n emptyState = hasEmptyProfileState();\n if (emptyState) break;\n if (attempt < 39) await sleep(250);\n}\nif (loginPath || loginForm) {\n return { success: false, status: 'requires_auth', requiresLogin: true, message: 'X requires authentication to read this profile', username, source: source.href };\n}\nif (missingAccount) {\n return { success: false, status: 'not_found', requiresLogin: false, message: 'X account does not exist or is suspended', username, source: source.href };\n}\nconst nameEl = typeof document !== 'undefined' && document && typeof document.querySelector === 'function' ? document.querySelector('[data-testid=\"UserName\"]') : null;\nconst bioEl = typeof document !== 'undefined' && document && typeof document.querySelector === 'function' ? document.querySelector('[data-testid=\"UserDescription\"]') : null;\nconst displayName = String((nameEl && (nameEl.innerText || nameEl.textContent)) || '').split('\\n').map(v => v.trim()).find(Boolean) || username;\nconst bio = String((bioEl && (bioEl.innerText || bioEl.textContent)) || '').trim().slice(0, 600);\nconst profile = { username, displayName, bio, url: source.href };\nif (emptyState) {\n return { success: true, status: 'empty', coverage: 'visible_only', profile, posts: [], sources: { page: source.href } };\n}\nif (!articles.length) {\n return { success: false, status: 'loading_timeout', requiresLogin: false, message: 'X profile posts did not become visible within 10 seconds', username, source: source.href };\n}\nconst mainStatusLink = article => {\n const links = typeof article.querySelectorAll === 'function' ? Array.from(article.querySelectorAll('a:has(time)')) : [];\n const candidates = links.filter(link => !isInsideQuote(article, link));\n const pool = candidates.length ? candidates : links;\n return pool.find(link => {\n const href = link.getAttribute('href') || '';\n try {\n return /^\\/[^/]+\\/status\\/\\d+$/.test(new URL(href, canonicalOrigin).pathname);\n } catch {\n return false;\n }\n });\n};\nconst firstPrimaryEl = (article, selector) => {\n const list = typeof article.querySelectorAll === 'function' ? Array.from(article.querySelectorAll(selector)) : [];\n if (list.length) return list.find(el => !isInsideQuote(article, el)) || null;\n const single = typeof article.querySelector === 'function' ? article.querySelector(selector) : null;\n return single && !isInsideQuote(article, single) ? single : null;\n};\nconst posts = articles.map(article => {\n const statusLink = mainStatusLink(article);\n const href = statusLink ? statusLink.getAttribute('href') || '' : '';\n const statusUrl = href ? new URL(href, canonicalOrigin).href : '';\n const statusAuthorMatch = statusUrl ? new URL(statusUrl).pathname.match(/^\\/([^/]+)\\/status\\/\\d+$/) : null;\n const statusAuthor = statusAuthorMatch ? statusAuthorMatch[1] : '';\n if (isRepost(article, statusAuthor)) return null;\n const textEl = firstPrimaryEl(article, '[data-testid=\"tweetText\"]');\n const text = String((textEl && (textEl.innerText || textEl.textContent)) || '').trim();\n const userEl = firstPrimaryEl(article, '[data-testid=\"User-Name\"]');\n const nameBlock = String((userEl && (userEl.innerText || userEl.textContent)) || '').trim();\n const author = nameBlock.split('\\n').map(part => part.trim()).find(Boolean) || (statusAuthor ? '@' + statusAuthor : '');\n const time = statusLink && typeof statusLink.querySelector === 'function' ? statusLink.querySelector('time') : null;\n return {\n text,\n author,\n url: statusUrl,\n publishedAt: time ? String(time.getAttribute('datetime') || '') : ''\n };\n}).filter(post => post && post.text && post.url).slice(0, limit);\nif (!posts.length) {\n return { success: false, status: 'unreadable', requiresLogin: false, message: 'Visible X profile articles did not expose readable text and status links', username, source: source.href };\n}\nreturn { success: true, status: 'ok', coverage: 'visible_only', profile, posts, sources: { page: source.href } };",
|
|
220
|
+
"timeoutMs": 20000
|
|
221
|
+
},
|
|
222
|
+
"resultPath": "/result"
|
|
223
|
+
}
|
|
224
|
+
],
|
|
225
|
+
"verification": {
|
|
226
|
+
"tool": "chrome_read_dom",
|
|
227
|
+
"args": {
|
|
228
|
+
"format": "compact",
|
|
229
|
+
"selector": "main",
|
|
230
|
+
"activeViewportOnly": false,
|
|
231
|
+
"limit": 80,
|
|
232
|
+
"maxTextLength": 240
|
|
233
|
+
},
|
|
234
|
+
"resultPath": "/treeString"
|
|
235
|
+
},
|
|
236
|
+
"tests": [
|
|
237
|
+
{
|
|
238
|
+
"inputs": {
|
|
239
|
+
"username": "github",
|
|
240
|
+
"limit": 5
|
|
241
|
+
},
|
|
242
|
+
"expect": {
|
|
243
|
+
"type": "object",
|
|
244
|
+
"properties": {
|
|
245
|
+
"success": {
|
|
246
|
+
"const": true
|
|
247
|
+
},
|
|
248
|
+
"status": {
|
|
249
|
+
"const": "ok"
|
|
250
|
+
},
|
|
251
|
+
"coverage": {
|
|
252
|
+
"const": "visible_only"
|
|
253
|
+
},
|
|
254
|
+
"profile": {
|
|
255
|
+
"type": "object",
|
|
256
|
+
"properties": {
|
|
257
|
+
"username": {
|
|
258
|
+
"const": "github"
|
|
259
|
+
}
|
|
260
|
+
},
|
|
261
|
+
"required": [
|
|
262
|
+
"username"
|
|
263
|
+
]
|
|
264
|
+
},
|
|
265
|
+
"posts": {
|
|
266
|
+
"type": "array",
|
|
267
|
+
"minItems": 1
|
|
268
|
+
}
|
|
269
|
+
},
|
|
270
|
+
"required": [
|
|
271
|
+
"success",
|
|
272
|
+
"status",
|
|
273
|
+
"coverage",
|
|
274
|
+
"profile",
|
|
275
|
+
"posts",
|
|
276
|
+
"sources"
|
|
277
|
+
]
|
|
278
|
+
},
|
|
279
|
+
"observe": {
|
|
280
|
+
"type": "string",
|
|
281
|
+
"pattern": "github|GitHub|Posts|Log in|Sign in"
|
|
282
|
+
}
|
|
283
|
+
},
|
|
284
|
+
{
|
|
285
|
+
"inputs": {
|
|
286
|
+
"username": "reactjs",
|
|
287
|
+
"limit": 3
|
|
288
|
+
},
|
|
289
|
+
"expect": {
|
|
290
|
+
"type": "object",
|
|
291
|
+
"properties": {
|
|
292
|
+
"success": {
|
|
293
|
+
"const": true
|
|
294
|
+
},
|
|
295
|
+
"status": {
|
|
296
|
+
"const": "ok"
|
|
297
|
+
},
|
|
298
|
+
"coverage": {
|
|
299
|
+
"const": "visible_only"
|
|
300
|
+
},
|
|
301
|
+
"profile": {
|
|
302
|
+
"type": "object",
|
|
303
|
+
"properties": {
|
|
304
|
+
"username": {
|
|
305
|
+
"const": "reactjs"
|
|
306
|
+
}
|
|
307
|
+
},
|
|
308
|
+
"required": [
|
|
309
|
+
"username"
|
|
310
|
+
]
|
|
311
|
+
},
|
|
312
|
+
"posts": {
|
|
313
|
+
"type": "array",
|
|
314
|
+
"minItems": 1
|
|
315
|
+
}
|
|
316
|
+
},
|
|
317
|
+
"required": [
|
|
318
|
+
"success",
|
|
319
|
+
"status",
|
|
320
|
+
"coverage",
|
|
321
|
+
"profile",
|
|
322
|
+
"posts",
|
|
323
|
+
"sources"
|
|
324
|
+
]
|
|
325
|
+
},
|
|
326
|
+
"observe": {
|
|
327
|
+
"type": "string",
|
|
328
|
+
"pattern": "react|React|Posts|Log in|Sign in"
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
]
|
|
332
|
+
}
|