specific-ai-cli 0.0.0-stage → 0.1.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.
Files changed (277) hide show
  1. package/LICENSE +21 -0
  2. package/README.en.md +177 -0
  3. package/README.ja.md +177 -0
  4. package/README.ko.md +177 -0
  5. package/README.md +174 -2
  6. package/README.zh-TW.md +177 -0
  7. package/assets/banner.txt +3 -0
  8. package/dist/cli/argv.js +98 -0
  9. package/dist/cli/commands/auth.js +11 -0
  10. package/dist/cli/commands/config.js +23 -0
  11. package/dist/cli/commands/doctor.js +134 -0
  12. package/dist/cli/commands/platforms.js +24 -0
  13. package/dist/cli/commands/version.js +4 -0
  14. package/dist/cli/confirm.js +22 -0
  15. package/dist/cli/dispatch.js +440 -0
  16. package/dist/cli/help.js +223 -0
  17. package/dist/cli/hints.js +60 -0
  18. package/dist/cli/main.js +18 -0
  19. package/dist/cli/output.js +66 -0
  20. package/dist/core/auth-handlers.js +41 -0
  21. package/dist/core/auth-store.js +119 -0
  22. package/dist/core/capabilities.js +163 -0
  23. package/dist/core/config.js +121 -0
  24. package/dist/core/cookies.js +164 -0
  25. package/dist/core/errors.js +37 -0
  26. package/dist/core/files.js +89 -0
  27. package/dist/core/fsutil.js +52 -0
  28. package/dist/core/hash.js +4 -0
  29. package/dist/core/http.js +331 -0
  30. package/dist/core/image.js +280 -0
  31. package/dist/core/log.js +40 -0
  32. package/dist/core/login.js +191 -0
  33. package/dist/core/mp4.js +130 -0
  34. package/dist/core/normalize.js +207 -0
  35. package/dist/core/options.js +110 -0
  36. package/dist/core/paths.js +38 -0
  37. package/dist/core/pb.js +59 -0
  38. package/dist/core/py.js +181 -0
  39. package/dist/core/rand.js +131 -0
  40. package/dist/core/registry.js +129 -0
  41. package/dist/core/schemas.js +41 -0
  42. package/dist/core/stream.js +104 -0
  43. package/dist/core/toolkit.js +35 -0
  44. package/dist/core/vm.js +73 -0
  45. package/dist/core/vocab.js +157 -0
  46. package/dist/platforms/_shared/impaas.js +410 -0
  47. package/dist/platforms/bilibili/index.js +216 -0
  48. package/dist/platforms/bilibili/web/api.js +806 -0
  49. package/dist/platforms/bilibili/web/client.js +311 -0
  50. package/dist/platforms/bilibili/web/commands.js +783 -0
  51. package/dist/platforms/bilibili/web/ddddocr.js +342 -0
  52. package/dist/platforms/bilibili/web/gaia.js +130 -0
  53. package/dist/platforms/bilibili/web/geetest-manual.js +154 -0
  54. package/dist/platforms/bilibili/web/geetest-vision.js +232 -0
  55. package/dist/platforms/bilibili/web/geetest.js +450 -0
  56. package/dist/platforms/bilibili/web/normalize.js +234 -0
  57. package/dist/platforms/bilibili/web/profile.js +135 -0
  58. package/dist/platforms/bilibili/web/resolve.js +112 -0
  59. package/dist/platforms/bilibili/web/sign.js +223 -0
  60. package/dist/platforms/bilibili/web/upos.js +102 -0
  61. package/dist/platforms/douyin/index.js +142 -0
  62. package/dist/platforms/douyin/web/api.js +863 -0
  63. package/dist/platforms/douyin/web/client.js +413 -0
  64. package/dist/platforms/douyin/web/commands.js +712 -0
  65. package/dist/platforms/douyin/web/creator.js +601 -0
  66. package/dist/platforms/douyin/web/crypto.js +247 -0
  67. package/dist/platforms/douyin/web/dtrait.js +190 -0
  68. package/dist/platforms/douyin/web/im.js +502 -0
  69. package/dist/platforms/douyin/web/image.js +5 -0
  70. package/dist/platforms/douyin/web/live.js +225 -0
  71. package/dist/platforms/douyin/web/mssdk.js +148 -0
  72. package/dist/platforms/douyin/web/normalize.js +326 -0
  73. package/dist/platforms/douyin/web/passport.js +1247 -0
  74. package/dist/platforms/douyin/web/profile.js +221 -0
  75. package/dist/platforms/douyin/web/proto.js +26 -0
  76. package/dist/platforms/douyin/web/resolve.js +88 -0
  77. package/dist/platforms/douyin/web/sign.js +436 -0
  78. package/dist/platforms/douyin/web/tos.js +78 -0
  79. package/dist/platforms/index.js +17 -0
  80. package/dist/platforms/jd/index.js +67 -0
  81. package/dist/platforms/jd/web/aks.js +115 -0
  82. package/dist/platforms/jd/web/api.js +549 -0
  83. package/dist/platforms/jd/web/chat.js +132 -0
  84. package/dist/platforms/jd/web/client.js +470 -0
  85. package/dist/platforms/jd/web/commands.js +557 -0
  86. package/dist/platforms/jd/web/jcap/helper.js +90 -0
  87. package/dist/platforms/jd/web/jcap/host.js +107 -0
  88. package/dist/platforms/jd/web/jcap/lsd.js +300 -0
  89. package/dist/platforms/jd/web/jcap/solver.js +995 -0
  90. package/dist/platforms/jd/web/jcap.js +150 -0
  91. package/dist/platforms/jd/web/js.js +420 -0
  92. package/dist/platforms/jd/web/login.js +775 -0
  93. package/dist/platforms/jd/web/normalize.js +297 -0
  94. package/dist/platforms/jd/web/profile.js +256 -0
  95. package/dist/platforms/jd/web/util.js +175 -0
  96. package/dist/platforms/jd/web/webm.js +133 -0
  97. package/dist/platforms/kuaishou/index.js +98 -0
  98. package/dist/platforms/kuaishou/web/api.js +694 -0
  99. package/dist/platforms/kuaishou/web/captcha-crypto.js +134 -0
  100. package/dist/platforms/kuaishou/web/captcha-fp.js +180 -0
  101. package/dist/platforms/kuaishou/web/captcha.js +273 -0
  102. package/dist/platforms/kuaishou/web/client.js +487 -0
  103. package/dist/platforms/kuaishou/web/commands.js +863 -0
  104. package/dist/platforms/kuaishou/web/gap.js +144 -0
  105. package/dist/platforms/kuaishou/web/gdfp.js +376 -0
  106. package/dist/platforms/kuaishou/web/gql.js +11 -0
  107. package/dist/platforms/kuaishou/web/live.js +125 -0
  108. package/dist/platforms/kuaishou/web/normalize.js +241 -0
  109. package/dist/platforms/kuaishou/web/oracle.js +329 -0
  110. package/dist/platforms/kuaishou/web/profile.js +259 -0
  111. package/dist/platforms/kuaishou/web/resolve.js +84 -0
  112. package/dist/platforms/kuaishou/web/session.js +592 -0
  113. package/dist/platforms/kuaishou/web/sign.js +568 -0
  114. package/dist/platforms/taobao/index.js +56 -0
  115. package/dist/platforms/taobao/web/api.js +96 -0
  116. package/dist/platforms/taobao/web/client.js +102 -0
  117. package/dist/platforms/taobao/web/commands.js +172 -0
  118. package/dist/platforms/taobao/web/im.js +68 -0
  119. package/dist/platforms/taobao/web/normalize.js +103 -0
  120. package/dist/platforms/taobao/web/profile.js +85 -0
  121. package/dist/platforms/taobao/web/resolve.js +51 -0
  122. package/dist/platforms/taobao/web/sign.js +35 -0
  123. package/dist/platforms/tiktok/index.js +120 -0
  124. package/dist/platforms/tiktok/web/api.js +1234 -0
  125. package/dist/platforms/tiktok/web/client.js +362 -0
  126. package/dist/platforms/tiktok/web/commands.js +821 -0
  127. package/dist/platforms/tiktok/web/im.js +133 -0
  128. package/dist/platforms/tiktok/web/jsrun.js +126 -0
  129. package/dist/platforms/tiktok/web/normalize.js +286 -0
  130. package/dist/platforms/tiktok/web/profile.js +169 -0
  131. package/dist/platforms/tiktok/web/resolve.js +156 -0
  132. package/dist/platforms/tiktok/web/sign.js +585 -0
  133. package/dist/platforms/tiktok/web/upload.js +805 -0
  134. package/dist/platforms/tiktok/web/wire.js +490 -0
  135. package/dist/platforms/weibo/index.js +91 -0
  136. package/dist/platforms/weibo/web/api.js +206 -0
  137. package/dist/platforms/weibo/web/client.js +155 -0
  138. package/dist/platforms/weibo/web/commands.js +202 -0
  139. package/dist/platforms/weibo/web/normalize.js +137 -0
  140. package/dist/platforms/weibo/web/profile.js +246 -0
  141. package/dist/platforms/weibo/web/resolve.js +60 -0
  142. package/dist/platforms/weibo/web/sign.js +85 -0
  143. package/dist/platforms/x/index.js +107 -0
  144. package/dist/platforms/x/web/api.js +443 -0
  145. package/dist/platforms/x/web/article.js +212 -0
  146. package/dist/platforms/x/web/client.js +202 -0
  147. package/dist/platforms/x/web/commands.js +363 -0
  148. package/dist/platforms/x/web/graphql.js +108 -0
  149. package/dist/platforms/x/web/normalize.js +235 -0
  150. package/dist/platforms/x/web/profile.js +99 -0
  151. package/dist/platforms/x/web/resolve.js +44 -0
  152. package/dist/platforms/x/web/transaction.js +171 -0
  153. package/dist/platforms/xhs/index.js +101 -0
  154. package/dist/platforms/xhs/web/api.js +278 -0
  155. package/dist/platforms/xhs/web/client.js +540 -0
  156. package/dist/platforms/xhs/web/commands.js +1046 -0
  157. package/dist/platforms/xhs/web/creator-api.js +609 -0
  158. package/dist/platforms/xhs/web/creator.js +203 -0
  159. package/dist/platforms/xhs/web/js.js +194 -0
  160. package/dist/platforms/xhs/web/login.js +230 -0
  161. package/dist/platforms/xhs/web/normalize.js +166 -0
  162. package/dist/platforms/xhs/web/profile.js +127 -0
  163. package/dist/platforms/xhs/web/push.js +361 -0
  164. package/dist/platforms/xhs/web/resolve.js +69 -0
  165. package/dist/platforms/xhs/web/state.js +368 -0
  166. package/dist/platforms/xianyu/index.js +59 -0
  167. package/dist/platforms/xianyu/web/api.js +312 -0
  168. package/dist/platforms/xianyu/web/client.js +134 -0
  169. package/dist/platforms/xianyu/web/commands.js +305 -0
  170. package/dist/platforms/xianyu/web/im.js +73 -0
  171. package/dist/platforms/xianyu/web/normalize.js +123 -0
  172. package/dist/platforms/xianyu/web/profile.js +146 -0
  173. package/dist/platforms/xianyu/web/resolve.js +48 -0
  174. package/dist/platforms/xianyu/web/sign.js +79 -0
  175. package/package.json +77 -4
  176. package/static/douyin/Live.proto +194 -0
  177. package/static/douyin/Request.proto +89 -0
  178. package/static/douyin/Response.proto +46 -0
  179. package/static/douyin/acrawler_runtime/ac_vm.js +2 -0
  180. package/static/douyin/acrawler_runtime/browser_window_shape.json +1 -0
  181. package/static/douyin/acrawler_runtime/canvas_actual_exact.json +1 -0
  182. package/static/douyin/acrawler_runtime/run_ac_node.js +1005 -0
  183. package/static/douyin/acrawler_runtime/runner_window_keys_baseline.txt +240 -0
  184. package/static/douyin/challenge_profile.json +801 -0
  185. package/static/douyin/challenge_template_runner.js +217 -0
  186. package/static/douyin/dtrait_profile.json +66 -0
  187. package/static/douyin/mstoken_common_profile.json +1 -0
  188. package/static/douyin/mstoken_profile.json +214 -0
  189. package/static/jd/h5st5_env.js +750 -0
  190. package/static/jd/h5st5_lib.js +5 -0
  191. package/static/jd/h5st5_server.js +49 -0
  192. package/static/jd/jcap/env/env_core.js +512 -0
  193. package/static/jd/jcap/env/run.js +1307 -0
  194. package/static/jd/jcap/run/jcap_ujb96b.js +39 -0
  195. package/static/jd/package.json +4 -0
  196. package/static/jd/pc_tk_lib.js +1 -0
  197. package/static/jd/pc_tk_server.js +63 -0
  198. package/static/jd/summer_cryptico_runner.js +50 -0
  199. package/static/jd/webm/env/run.js +453 -0
  200. package/static/jd/webm/run/jdwebm-riskhandle.js +49 -0
  201. package/static/kuaishou/bundles/weapon/kwf-0.0.2.2cee19b4b7dec496.js +1 -0
  202. package/static/kuaishou/bundles/weapon/kws-0-0.0.1-obfuscated.4b7f3de1ab0ddcc2.js +1 -0
  203. package/static/kuaishou/bundles/weapon/kws-1-0.0.1-obfuscated.346ebdb1c78df316.js +1 -0
  204. package/static/kuaishou/bundles/weapon/kws-10-0.0.1-obfuscated.a33db41897b983af.js +1 -0
  205. package/static/kuaishou/bundles/weapon/kws-11-0.0.1-obfuscated.5e0a90af726d8a7e.js +1 -0
  206. package/static/kuaishou/bundles/weapon/kws-12-0.0.1-obfuscated.20ea29345706ec8c.js +1 -0
  207. package/static/kuaishou/bundles/weapon/kws-13-0.0.1-obfuscated.6b74e9640ff18648.js +1 -0
  208. package/static/kuaishou/bundles/weapon/kws-14-0.0.1-obfuscated.551e4429d156bf66.js +1 -0
  209. package/static/kuaishou/bundles/weapon/kws-15-0.0.1-obfuscated.8625b087aaba4a60.js +1 -0
  210. package/static/kuaishou/bundles/weapon/kws-16-0.0.1-obfuscated.d5ffa4020f3be99a.js +1 -0
  211. package/static/kuaishou/bundles/weapon/kws-17-0.0.1-obfuscated.6d13e19b22f50a80.js +1 -0
  212. package/static/kuaishou/bundles/weapon/kws-18-0.0.1-obfuscated.6d31405044166289.js +1 -0
  213. package/static/kuaishou/bundles/weapon/kws-19-0.0.1-obfuscated.a9a8d925942f19e4.js +1 -0
  214. package/static/kuaishou/bundles/weapon/kws-2-0.0.1-obfuscated.b849a136ae4a6b3e.js +1 -0
  215. package/static/kuaishou/bundles/weapon/kws-3-0.0.1-obfuscated.f9e77ebf6186e2ac.js +1 -0
  216. package/static/kuaishou/bundles/weapon/kws-4-0.0.1-obfuscated.2c3c155aa52ceb0e.js +1 -0
  217. package/static/kuaishou/bundles/weapon/kws-5-0.0.1-obfuscated.4e553d17691b3c5a.js +1 -0
  218. package/static/kuaishou/bundles/weapon/kws-6-0.0.1-obfuscated.f73ddd3ff13e1217.js +1 -0
  219. package/static/kuaishou/bundles/weapon/kws-7-0.0.1-obfuscated.1628b8729beaab7e.js +1 -0
  220. package/static/kuaishou/bundles/weapon/kws-8-0.0.1-obfuscated.6da6baef7aa81fff.js +1 -0
  221. package/static/kuaishou/bundles/weapon/kws-9-0.0.1-obfuscated.8645d55e5323b743.js +1 -0
  222. package/static/kuaishou/fixtures/current_follow_script_813.network-response +2 -0
  223. package/static/kuaishou/fixtures/live_ws_maps.json +61 -0
  224. package/static/kuaishou/fixtures/live_ws_proto.json +1342 -0
  225. package/static/kuaishou/js/cp-kwf.js +1 -0
  226. package/static/kuaishou/tools/kwf_oracle.js +799 -0
  227. package/static/kuaishou/tools/kws_oracle.js +885 -0
  228. package/static/kuaishou/tools/like_token_oracle.js +70 -0
  229. package/static/taobao/taobao_js_20260407.js +570 -0
  230. package/static/tiktok/Tiktok_Request.json +597 -0
  231. package/static/tiktok/package.json +3 -0
  232. package/static/tiktok/shop_bsid/core.js +1 -0
  233. package/static/tiktok/shop_bsid/env_core.js +512 -0
  234. package/static/tiktok/shop_bsid/loader.js +1 -0
  235. package/static/tiktok/shop_bsid/run.js +753 -0
  236. package/static/tiktok/shop_bsid/sign.js +100 -0
  237. package/static/tiktok/shop_bsid/webmssdk.js +1 -0
  238. package/static/tiktok/shop_bsid/webmssdk_ex.js +1 -0
  239. package/static/tiktok/signing/env/env_core.js +512 -0
  240. package/static/tiktok/signing/env/sign.js +455 -0
  241. package/static/tiktok/signing/sdk_config.json +230 -0
  242. package/static/tiktok/signing/source/webmssdk.js +1 -0
  243. package/static/tiktok/signing/source/webmssdk_ex.js +1 -0
  244. package/static/tiktok/signing/source/webmssdk_legacy.js +1 -0
  245. package/static/x/graphql.json +7777 -0
  246. package/static/x/transaction_l1.json +12 -0
  247. package/static/xhs/package.json +3 -0
  248. package/static/xhs/xhs_core/js/b1.js +210 -0
  249. package/static/xhs/xhs_core/js/mns.js +340 -0
  250. package/static/xhs/xhs_core/js/mns_0101_keystream.json +5 -0
  251. package/static/xhs/xhs_core/js/mns_keystreams.json +1 -0
  252. package/static/xhs/xhs_core/js/sign.js +225 -0
  253. package/static/xhs/xhs_core/js/websectiga_cli.js +220 -0
  254. package/static/xhs/xhs_core/js/websectiga_env.js +512 -0
  255. package/static/xhs/xhs_core/js/xs_common.js +79 -0
  256. package/static/xhs/xhs_creator/js/profile.js +115 -0
  257. package/static/xhs/xhs_creator/js/rap_fingerprint_creator.json +6 -0
  258. package/static/xhs/xhs_creator/js/reference_profile.json +282 -0
  259. package/static/xhs/xhs_creator/js/xhs_creator_sign.js +29 -0
  260. package/static/xhs/xhs_creator/js/xhs_creator_signature.js +23 -0
  261. package/static/xhs/xhs_pc/js/aes_decrypt.js +22 -0
  262. package/static/xhs/xhs_pc/js/aes_encrypt.js +30 -0
  263. package/static/xhs/xhs_pc/js/b1.js +9 -0
  264. package/static/xhs/xhs_pc/js/deflate.js +320 -0
  265. package/static/xhs/xhs_pc/js/mns.js +4 -0
  266. package/static/xhs/xhs_pc/js/profile.js +141 -0
  267. package/static/xhs/xhs_pc/js/rap.js +173 -0
  268. package/static/xhs/xhs_pc/js/rap_cli.js +30 -0
  269. package/static/xhs/xhs_pc/js/rap_crypto.js +73 -0
  270. package/static/xhs/xhs_pc/js/rap_fingerprint_template.json +8 -0
  271. package/static/xhs/xhs_pc/js/reference_profile.json +262 -0
  272. package/static/xhs/xhs_pc/js/sign.js +6 -0
  273. package/static/xhs/xhs_pc/js/web_ssk.js +82 -0
  274. package/static/xhs/xhs_pc/js/xs_common.js +4 -0
  275. package/static/xianyu/et_f.js +2 -0
  276. package/static/xianyu/gen_tfstk.js +410 -0
  277. package/static/xianyu/goofish_js_version_2.js +568 -0
@@ -0,0 +1,453 @@
1
+ const fs = require('fs');
2
+ const path = require('path');
3
+ const vm = require('vm');
4
+ const { createRequire } = require('module');
5
+
6
+ const inputText = fs.readFileSync(0, 'utf8').trim();
7
+ const runtimeInput = inputText ? JSON.parse(inputText) : {};
8
+ const projectRoot = path.resolve(__dirname, '..', '..', '..');
9
+ const repoRequire = createRequire(path.join(projectRoot, 'package.json'));
10
+ const { JSDOM } = repoRequire('jsdom');
11
+ const { createCanvas } = repoRequire('@napi-rs/canvas');
12
+ const bundlePath = path.resolve(__dirname, '..', 'run', 'jdwebm-riskhandle.js');
13
+ const bundleUrl = 'https://storage.360buyimg.com/webcontainer/js_security_v3/jdwebm.js?v=riskhandle';
14
+ const resultPrefix = '__WEBM_RESULT__';
15
+
16
+ function emit(payload) {
17
+ process.stdout.write(`${resultPrefix}${JSON.stringify(payload)}\n`);
18
+ }
19
+
20
+ function nativeLike(fn, name, length) {
21
+ try { Object.defineProperty(fn, 'name', { configurable: true, value: name }); } catch (_) {}
22
+ if (Number.isInteger(length)) {
23
+ try { Object.defineProperty(fn, 'length', { configurable: true, value: length }); } catch (_) {}
24
+ }
25
+ try {
26
+ Object.defineProperty(fn, 'toString', {
27
+ configurable: true,
28
+ value: () => `function ${name}() { [native code] }`,
29
+ });
30
+ } catch (_) {}
31
+ return fn;
32
+ }
33
+
34
+ function defineValue(target, name, value, enumerable = true) {
35
+ try {
36
+ Object.defineProperty(target, name, {
37
+ configurable: true,
38
+ enumerable,
39
+ value,
40
+ });
41
+ } catch (_) {}
42
+ }
43
+
44
+ function snapshotStorage(storage) {
45
+ const result = Object.create(null);
46
+ for (let index = 0; index < storage.length; index++) {
47
+ const key = storage.key(index);
48
+ if (key != null) result[String(key)] = String(storage.getItem(key) || '');
49
+ }
50
+ return result;
51
+ }
52
+
53
+ function snapshotCookies(document) {
54
+ const result = Object.create(null);
55
+ for (const part of String(document.cookie || '').split(';')) {
56
+ const separator = part.indexOf('=');
57
+ if (separator <= 0) continue;
58
+ const name = part.slice(0, separator).trim();
59
+ const value = part.slice(separator + 1).trim();
60
+ if (name) result[name] = value;
61
+ }
62
+ return result;
63
+ }
64
+
65
+ function makePlugin(name) {
66
+ const plugin = [];
67
+ const pdf = {
68
+ type: 'application/pdf',
69
+ suffixes: 'pdf',
70
+ description: 'Portable Document Format',
71
+ };
72
+ const textPdf = {
73
+ type: 'text/pdf',
74
+ suffixes: 'pdf',
75
+ description: 'Portable Document Format',
76
+ };
77
+ plugin.push(pdf, textPdf);
78
+ Object.assign(plugin, {
79
+ name,
80
+ filename: 'internal-pdf-viewer',
81
+ description: 'Portable Document Format',
82
+ item: index => plugin[index] || null,
83
+ namedItem: type => plugin.find(item => item.type === type) || null,
84
+ });
85
+ pdf.enabledPlugin = plugin;
86
+ textPdf.enabledPlugin = plugin;
87
+ return plugin;
88
+ }
89
+
90
+ function installBrowserProfile(window) {
91
+ const navigator = window.navigator;
92
+ const ua = String(runtimeInput.userAgent ||
93
+ 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 ' +
94
+ '(KHTML, like Gecko) Chrome/152.0.0.0 Safari/537.36');
95
+ for (const [name, value] of Object.entries({
96
+ userAgent: ua,
97
+ appVersion: ua.replace(/^Mozilla\//, ''),
98
+ platform: 'Win32',
99
+ vendor: 'Google Inc.',
100
+ language: 'zh-CN',
101
+ languages: Object.freeze(['zh-CN', 'zh', 'en', 'zh-TW', 'ja']),
102
+ hardwareConcurrency: 32,
103
+ deviceMemory: 8,
104
+ maxTouchPoints: 0,
105
+ webdriver: false,
106
+ pdfViewerEnabled: true,
107
+ })) defineValue(navigator, name, value);
108
+
109
+ for (const [name, value] of Object.entries({
110
+ width: 2560,
111
+ height: 1440,
112
+ availWidth: 2560,
113
+ availHeight: 1392,
114
+ colorDepth: 24,
115
+ pixelDepth: 24,
116
+ })) defineValue(window.screen, name, value);
117
+ defineValue(window.screen, 'orientation', {
118
+ angle: 0,
119
+ type: 'landscape-primary',
120
+ });
121
+ for (const [name, value] of Object.entries({
122
+ innerWidth: 2560,
123
+ innerHeight: 1297,
124
+ outerWidth: 2560,
125
+ outerHeight: 1392,
126
+ screenX: 0,
127
+ screenY: 0,
128
+ screenLeft: 0,
129
+ screenTop: 0,
130
+ devicePixelRatio: 1,
131
+ })) defineValue(window, name, value);
132
+
133
+ const plugins = [
134
+ 'PDF Viewer',
135
+ 'Chrome PDF Viewer',
136
+ 'Chromium PDF Viewer',
137
+ 'Microsoft Edge PDF Viewer',
138
+ 'WebKit built-in PDF',
139
+ ].map(makePlugin);
140
+ plugins.item = index => plugins[index] || null;
141
+ plugins.namedItem = name => plugins.find(item => item.name === name) || null;
142
+ plugins.refresh = () => {};
143
+ const mimeTypes = [plugins[0][0], plugins[0][1]];
144
+ mimeTypes.item = index => mimeTypes[index] || null;
145
+ mimeTypes.namedItem = type => mimeTypes.find(item => item.type === type) || null;
146
+ defineValue(navigator, 'plugins', plugins);
147
+ defineValue(navigator, 'mimeTypes', mimeTypes);
148
+
149
+ const connection = Object.freeze({
150
+ downlink: 10,
151
+ effectiveType: '4g',
152
+ rtt: 50,
153
+ saveData: false,
154
+ type: 'wifi',
155
+ });
156
+ defineValue(navigator, 'connection', connection);
157
+ defineValue(navigator, 'mozConnection', connection);
158
+ defineValue(navigator, 'webkitConnection', connection);
159
+ defineValue(navigator, 'permissions', {
160
+ query: nativeLike(async descriptor => ({
161
+ state: descriptor && descriptor.name === 'geolocation' ? 'prompt' : 'prompt',
162
+ }), 'query', 1),
163
+ });
164
+ defineValue(navigator, 'getInterestGroupAdAuctionData',
165
+ nativeLike(async () => [], 'getInterestGroupAdAuctionData', 0));
166
+ defineValue(navigator, 'webkitTemporaryStorage', {
167
+ queryUsageAndQuota: nativeLike(success => success(0, 120000000000),
168
+ 'queryUsageAndQuota', 2),
169
+ });
170
+ defineValue(window, 'indexedDB', {});
171
+ defineValue(window, 'chrome', { runtime: {} });
172
+ defineValue(window.performance, 'memory', { jsHeapSizeLimit: 4294705152 });
173
+ defineValue(window, 'Notification', { permission: 'default' });
174
+ defineValue(window, 'speechSynthesis', {
175
+ getVoices: nativeLike(() => [], 'getVoices', 0),
176
+ onvoiceschanged: null,
177
+ });
178
+ defineValue(window, 'AudioContext', nativeLike(function AudioContext() {
179
+ this.sampleRate = 48000;
180
+ this.destination = {
181
+ maxChannelCount: 2,
182
+ numberOfInputs: 1,
183
+ numberOfOutputs: 0,
184
+ channelCount: 2,
185
+ channelCountMode: 'explicit',
186
+ channelInterpretation: 'speakers',
187
+ };
188
+ }, 'AudioContext', 0));
189
+ defineValue(window, 'matchMedia', nativeLike(query => ({
190
+ matches: /prefers-color-scheme:\s*light/.test(String(query)),
191
+ media: String(query),
192
+ onchange: null,
193
+ addListener: nativeLike(() => {}, 'addListener', 1),
194
+ removeListener: nativeLike(() => {}, 'removeListener', 1),
195
+ addEventListener: nativeLike(() => {}, 'addEventListener', 2),
196
+ removeEventListener: nativeLike(() => {}, 'removeEventListener', 2),
197
+ dispatchEvent: nativeLike(() => false, 'dispatchEvent', 1),
198
+ }), 'matchMedia', 1));
199
+
200
+ const fetchStub = nativeLike(async () => {
201
+ throw new Error('WebM payload runner does not perform network requests');
202
+ }, 'fetch', 1);
203
+ defineValue(window, 'fetch', fetchStub);
204
+ const XMLHttpRequest = nativeLike(function XMLHttpRequest() {}, 'XMLHttpRequest', 0);
205
+ XMLHttpRequest.prototype.open = nativeLike(() => {}, 'open', 2);
206
+ XMLHttpRequest.prototype.setRequestHeader = nativeLike(() => {}, 'setRequestHeader', 2);
207
+ XMLHttpRequest.prototype.send = nativeLike(() => {
208
+ throw new Error('WebM payload runner does not perform network requests');
209
+ }, 'send', 0);
210
+ defineValue(window, 'XMLHttpRequest', XMLHttpRequest);
211
+ }
212
+
213
+ function installLayout(window) {
214
+ const fonts = new Set([
215
+ 'Arial', 'Arial Black', 'Book Antiqua', 'Calibri', 'Cambria', 'Century',
216
+ 'Century Gothic', 'Comic Sans MS', 'Consolas', 'Courier', 'Courier New',
217
+ 'Georgia', 'Lucida Console', 'Lucida Sans Unicode', 'Microsoft Sans Serif',
218
+ 'Microsoft YaHei', 'MS Gothic', 'Segoe UI', 'SimSun', 'Tahoma',
219
+ 'Times New Roman', 'Trebuchet MS', 'Verdana',
220
+ ]);
221
+ function metric(node, dimension) {
222
+ const family = String(node && node.style && node.style.fontFamily || '');
223
+ if (family) {
224
+ const names = family.split(',').map(value => value.trim().replace(/^['"]|['"]$/g, ''));
225
+ const fallback = names[names.length - 1].toLowerCase();
226
+ const base = fallback.includes('monospace') ? 128
227
+ : fallback.includes('serif') && !fallback.includes('sans') ? 124 : 126;
228
+ const candidate = names[0] || '';
229
+ const installed = names.length > 1 && fonts.has(candidate);
230
+ if (dimension === 'height') return installed ? 21 + candidate.length % 2 : 20;
231
+ return installed ? base + 3 + candidate.length % 11 : base;
232
+ }
233
+ if (String(node && node.className || '').toLowerCase().includes('adsbox')) return 1;
234
+ const styleValue = Number.parseInt(String(node && node.style && node.style[dimension] || ''), 10);
235
+ return Number.isFinite(styleValue) ? styleValue : 1;
236
+ }
237
+ for (const [name, dimension] of [['offsetWidth', 'width'], ['offsetHeight', 'height']]) {
238
+ Object.defineProperty(window.HTMLElement.prototype, name, {
239
+ configurable: true,
240
+ get() { return metric(this, dimension); },
241
+ });
242
+ }
243
+ }
244
+
245
+ function installCanvas(window) {
246
+ const contexts = new WeakMap();
247
+ function ensure2d(node) {
248
+ let state = contexts.get(node);
249
+ const width = Math.max(1, Number(node.width) || 300);
250
+ const height = Math.max(1, Number(node.height) || 150);
251
+ if (!state || state.kind !== '2d' || state.canvas.width !== width || state.canvas.height !== height) {
252
+ const canvas = createCanvas(width, height);
253
+ state = { kind: '2d', canvas, context: canvas.getContext('2d') };
254
+ contexts.set(node, state);
255
+ }
256
+ return state;
257
+ }
258
+ function WebGLRenderingContext(canvas) {
259
+ this.canvas = canvas;
260
+ Object.assign(this, {
261
+ ARRAY_BUFFER: 34962,
262
+ STATIC_DRAW: 35044,
263
+ FLOAT: 5126,
264
+ TRIANGLE_STRIP: 5,
265
+ VERTEX_SHADER: 35633,
266
+ FRAGMENT_SHADER: 35632,
267
+ VENDOR: 7936,
268
+ VERSION: 7938,
269
+ });
270
+ }
271
+ for (const [name, implementation] of Object.entries({
272
+ createBuffer() { return {}; },
273
+ bindBuffer() {},
274
+ bufferData(_target, data) {
275
+ this.__vertices = Array.from({ length: Number(data && data.length) || 0 },
276
+ (_value, index) => Number(data[index]));
277
+ },
278
+ createProgram() { return {}; },
279
+ createShader() { return {}; },
280
+ shaderSource() {},
281
+ compileShader() {},
282
+ attachShader() {},
283
+ linkProgram() {},
284
+ useProgram() {},
285
+ getAttribLocation() { return 0; },
286
+ getUniformLocation() { return {}; },
287
+ enableVertexAttribArray() {},
288
+ vertexAttribPointer() {},
289
+ uniform2f() {},
290
+ drawArrays() {},
291
+ getExtension(name) {
292
+ if (name === 'WEBGL_debug_renderer_info') {
293
+ return { UNMASKED_VENDOR_WEBGL: 37445, UNMASKED_RENDERER_WEBGL: 37446 };
294
+ }
295
+ return null;
296
+ },
297
+ getParameter(parameter) {
298
+ if (parameter === 7936) return 'WebKit';
299
+ if (parameter === 7938) return 'WebGL 1.0 (OpenGL ES 2.0 Chromium)';
300
+ if (parameter === 37445) return 'Google Inc. (NVIDIA)';
301
+ if (parameter === 37446) {
302
+ return 'ANGLE (NVIDIA, NVIDIA GeForce RTX 5060 Ti (0x00002D04) ' +
303
+ 'Direct3D11 vs_5_0 ps_5_0, D3D11)';
304
+ }
305
+ return null;
306
+ },
307
+ getShaderPrecisionFormat() { return {}; },
308
+ })) WebGLRenderingContext.prototype[name] = nativeLike(
309
+ implementation, name, implementation.length);
310
+ defineValue(window, 'WebGLRenderingContext', WebGLRenderingContext);
311
+
312
+ function webglDataUrl(node, context) {
313
+ const width = Math.max(1, Number(node.width) || 300);
314
+ const height = Math.max(1, Number(node.height) || 150);
315
+ const canvas = createCanvas(width, height);
316
+ const drawing = canvas.getContext('2d');
317
+ const vertices = context && context.__vertices && context.__vertices.length >= 9
318
+ ? context.__vertices : [-0.2, -0.9, 0, 0.4, -0.26, 0, 0, 0.732134444, 0];
319
+ const point = index => [
320
+ (vertices[index] + 1) * width / 2,
321
+ (1 - vertices[index + 1]) * height / 2,
322
+ ];
323
+ const gradient = drawing.createLinearGradient(0, 0, width, height);
324
+ gradient.addColorStop(0, 'rgba(204, 242, 0, 1)');
325
+ gradient.addColorStop(1, 'rgba(255, 255, 0, 1)');
326
+ drawing.fillStyle = gradient;
327
+ drawing.beginPath();
328
+ const first = point(0);
329
+ drawing.moveTo(first[0], first[1]);
330
+ for (const index of [3, 6]) {
331
+ const next = point(index);
332
+ drawing.lineTo(next[0], next[1]);
333
+ }
334
+ drawing.closePath();
335
+ drawing.fill();
336
+ return canvas.toDataURL('image/png');
337
+ }
338
+
339
+ window.HTMLCanvasElement.prototype.getContext = nativeLike(function getContext(kind) {
340
+ if (kind === '2d') return ensure2d(this).context;
341
+ if (kind === 'webgl' || kind === 'experimental-webgl') {
342
+ let state = contexts.get(this);
343
+ if (!state || state.kind !== 'webgl') {
344
+ state = { kind: 'webgl', context: new WebGLRenderingContext(this) };
345
+ contexts.set(this, state);
346
+ }
347
+ return state.context;
348
+ }
349
+ return null;
350
+ }, 'getContext', 1);
351
+ window.HTMLCanvasElement.prototype.toDataURL = nativeLike(function toDataURL() {
352
+ const state = contexts.get(this);
353
+ if (state && state.kind === 'webgl') return webglDataUrl(this, state.context);
354
+ return ensure2d(this).canvas.toDataURL('image/png');
355
+ }, 'toDataURL', 0);
356
+ }
357
+
358
+ async function main() {
359
+ if (!fs.existsSync(bundlePath)) throw new Error('missing WebM bundle');
360
+ const pageUrl = String(runtimeInput.pageUrl ||
361
+ 'https://search.jd.com/Search?keyword=%E6%89%8B%E6%9C%BA');
362
+ const dom = new JSDOM('<!doctype html><html><head></head><body></body></html>', {
363
+ url: pageUrl,
364
+ pretendToBeVisual: true,
365
+ runScripts: 'outside-only',
366
+ });
367
+ const { window } = dom;
368
+ installBrowserProfile(window);
369
+ installLayout(window);
370
+ installCanvas(window);
371
+ window.console = console;
372
+
373
+ const initialCookies = runtimeInput.cookies && typeof runtimeInput.cookies === 'object'
374
+ ? runtimeInput.cookies : {};
375
+ for (const [name, value] of Object.entries(initialCookies)) {
376
+ if (!/^[!#$%&'*+.^_`|~0-9A-Za-z-]+$/.test(name) || value == null) continue;
377
+ try { window.document.cookie = `${name}=${String(value)}; path=/`; } catch (_) {}
378
+ }
379
+ const initialStorage = runtimeInput.localStorage && typeof runtimeInput.localStorage === 'object'
380
+ ? runtimeInput.localStorage : {};
381
+ for (const [name, value] of Object.entries(initialStorage)) {
382
+ if (value == null) continue;
383
+ try { window.localStorage.setItem(String(name), String(value)); } catch (_) {}
384
+ }
385
+
386
+ const scriptElement = window.document.createElement('script');
387
+ scriptElement.src = bundleUrl;
388
+ window.document.head.appendChild(scriptElement);
389
+ try {
390
+ Object.defineProperty(window.document, 'currentScript', {
391
+ configurable: true,
392
+ get() { return scriptElement; },
393
+ });
394
+ } catch (_) {}
395
+
396
+ let source = fs.readFileSync(bundlePath, 'utf8');
397
+ const entry = 'r(r.s=15)';
398
+ if (!source.includes(entry)) throw new Error('unsupported WebM bundle entry');
399
+ source = source.replace(entry, '(globalThis.__webm_require=r)');
400
+ vm.runInContext(source, dom.getInternalVMContext(), { filename: bundleUrl });
401
+ const req = window.__webm_require;
402
+ if (!req) throw new Error('WebM module loader unavailable');
403
+ const common = req(0);
404
+ const util = req(1);
405
+ util.initPolyfill();
406
+ util.currentScript();
407
+ const encryptedConfig = String(runtimeInput.configData || '');
408
+ if (encryptedConfig) util.isDowngrade(common.decryptConfig(encryptedConfig));
409
+ req(53).default();
410
+ const fp = new window.WebmBrowser();
411
+ const keyList = fp.keyArray();
412
+ const fingerprint = fp.get(keyList);
413
+ util.rewriteFingerPrintFunc(fp, keyList);
414
+ util.doJosRandomId();
415
+ req(8).queryNotifications();
416
+ req(6).queryGeolocation();
417
+ await Promise.resolve();
418
+
419
+ const strategy = new (req(52).HfStrategy)(fp, keyList, fingerprint);
420
+ let payload = null;
421
+ strategy.send = value => {
422
+ payload = typeof value === 'string' ? JSON.parse(value) : value;
423
+ };
424
+ await strategy.report();
425
+ if (!payload || typeof payload !== 'object') throw new Error('WebM payload was not produced');
426
+
427
+ const currentCookies = snapshotCookies(window.document);
428
+ const cookieUpdates = Object.create(null);
429
+ for (const [name, value] of Object.entries(currentCookies)) {
430
+ if (String(initialCookies[name] ?? '') !== value) cookieUpdates[name] = value;
431
+ }
432
+ emit({
433
+ ok: true,
434
+ payload,
435
+ cookies: cookieUpdates,
436
+ localStorage: snapshotStorage(window.localStorage),
437
+ diagnostics: {
438
+ bodyFields: Object.keys(payload.body || {}).length,
439
+ fingerprintLength: String(fingerprint || '').length,
440
+ keyCount: keyList.length,
441
+ },
442
+ });
443
+ dom.window.close();
444
+ }
445
+
446
+ main().catch(error => {
447
+ emit({
448
+ ok: false,
449
+ error: String(error && error.name || 'Error'),
450
+ errorMessage: String(error && error.message || '').slice(0, 240),
451
+ });
452
+ process.exitCode = 1;
453
+ });