| 123456789101112131415161718192021 |
- // 临时诊断 #13:截取新版打包画面验证壁纸。
- import { writeFileSync } from "node:fs";
- const pageId = process.argv[2] ?? "69C993FC0E070AF03D3352EB5507E7CB";
- const ws = new WebSocket(`ws://127.0.0.1:9223/devtools/page/${pageId}`);
- ws.onopen = () => {
- ws.send(JSON.stringify({ id: 1, method: "Page.enable", params: {} }));
- setTimeout(() => {
- ws.send(JSON.stringify({ id: 2, method: "Page.captureScreenshot", params: { format: "png" } }));
- }, 1500);
- };
- ws.onmessage = (event) => {
- const msg = JSON.parse(event.data);
- if (msg.id === 2) {
- writeFileSync("D:\\agenttool\\zcode\\tmp-packaged-shot.png", Buffer.from(msg.result.data, "base64"));
- console.log("SCREENSHOT saved");
- ws.close();
- process.exit(0);
- }
- };
- ws.onerror = () => process.exit(1);
- setTimeout(() => { console.log("TIMEOUT"); process.exit(1); }, 20000);
|