@adelie/wechat-miniprogram 0.0.0-stage → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +201 -0
- package/icon.svg +7 -0
- package/package.json +17 -3
- package/plugin.json +9 -0
- package/skills/wechat-miniprogram/SKILL.md +148 -0
- package/skills/wechat-miniprogram/scripts/add-ip2.mjs +358 -0
- package/skills/wechat-miniprogram/scripts/auto-submit.mjs +170 -0
- package/skills/wechat-miniprogram/scripts/check-session.mjs +40 -0
- package/skills/wechat-miniprogram/scripts/login2.mjs +226 -0
- package/skills/wechat-miniprogram/scripts/miniapp-info.mjs +67 -0
- package/skills/wechat-miniprogram/scripts/miniapp-nav.mjs +56 -0
- package/skills/wechat-miniprogram/scripts/package.json +12 -0
- package/skills/wechat-miniprogram/scripts/privacy-fill2.mjs +302 -0
- package/skills/wechat-miniprogram/scripts/probe-key-qr.mjs +147 -0
- package/skills/wechat-miniprogram/scripts/probe-privacy.mjs +73 -0
- package/skills/wechat-miniprogram/scripts/probe-privcheck.mjs +129 -0
- package/skills/wechat-miniprogram/scripts/probe-switch3.mjs +104 -0
- package/skills/wechat-miniprogram/scripts/reset-key2.mjs +259 -0
- package/skills/wechat-miniprogram/scripts/stealth.mjs +92 -0
- package/skills/wechat-miniprogram/scripts/submit-review4.mjs +186 -0
- package/skills/wechat-miniprogram/scripts/to-miniapp.mjs +136 -0
- package/skills/wechat-miniprogram/scripts/withdraw2.mjs +229 -0
- package/skills/wechat-miniprogram/templates/miniprogram-todo/README.md +46 -0
- package/skills/wechat-miniprogram/templates/miniprogram-todo/app.js +14 -0
- package/skills/wechat-miniprogram/templates/miniprogram-todo/app.json +12 -0
- package/skills/wechat-miniprogram/templates/miniprogram-todo/app.wxss +13 -0
- package/skills/wechat-miniprogram/templates/miniprogram-todo/package.json +14 -0
- package/skills/wechat-miniprogram/templates/miniprogram-todo/pages/about/about.js +33 -0
- package/skills/wechat-miniprogram/templates/miniprogram-todo/pages/about/about.json +4 -0
- package/skills/wechat-miniprogram/templates/miniprogram-todo/pages/about/about.wxml +24 -0
- package/skills/wechat-miniprogram/templates/miniprogram-todo/pages/about/about.wxss +49 -0
- package/skills/wechat-miniprogram/templates/miniprogram-todo/pages/index/index.js +145 -0
- package/skills/wechat-miniprogram/templates/miniprogram-todo/pages/index/index.json +4 -0
- package/skills/wechat-miniprogram/templates/miniprogram-todo/pages/index/index.wxml +55 -0
- package/skills/wechat-miniprogram/templates/miniprogram-todo/pages/index/index.wxss +173 -0
- package/skills/wechat-miniprogram/templates/miniprogram-todo/preview.js +53 -0
- package/skills/wechat-miniprogram/templates/miniprogram-todo/project.config.json +25 -0
- package/skills/wechat-miniprogram/templates/miniprogram-todo/sitemap.json +9 -0
- package/skills/wechat-miniprogram/templates/miniprogram-todo/tools/test-page.js +123 -0
- package/skills/wechat-miniprogram/templates/miniprogram-todo/tools/validate.js +103 -0
- package/skills/wechat-miniprogram/templates/miniprogram-todo/upload.js +49 -0
- package/README.md +0 -3
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
// 探明「重置代码上传密钥」弹窗里二维码的元素类型与原始分辨率
|
|
2
|
+
import { launchStealth } from "./stealth.mjs";
|
|
3
|
+
import fs from "node:fs";
|
|
4
|
+
import path from "node:path";
|
|
5
|
+
import { fileURLToPath } from "node:url";
|
|
6
|
+
import { PNG } from "pngjs";
|
|
7
|
+
import jsQR from "jsqr";
|
|
8
|
+
|
|
9
|
+
const here = path.dirname(fileURLToPath(import.meta.url));
|
|
10
|
+
const outDir = process.argv[2] || here;
|
|
11
|
+
const ctx = await launchStealth(path.join(here, "profile"), { headless: false });
|
|
12
|
+
const page = ctx.pages()[0] || (await ctx.newPage());
|
|
13
|
+
await page.goto("https://mp.weixin.qq.com/", { waitUntil: "domcontentloaded", timeout: 60000 });
|
|
14
|
+
await page.waitForTimeout(10000);
|
|
15
|
+
const token = (page.url().match(/token=(\d+)/) || [])[1];
|
|
16
|
+
await page.goto(`https://mp.weixin.qq.com/wxamp/devprofile/get_profile?token=${token}&lang=zh_CN`, {
|
|
17
|
+
waitUntil: "domcontentloaded",
|
|
18
|
+
timeout: 60000,
|
|
19
|
+
});
|
|
20
|
+
await page.waitForTimeout(9000);
|
|
21
|
+
|
|
22
|
+
const btn = await page.evaluate(() => {
|
|
23
|
+
const label = Array.from(document.querySelectorAll("*")).find(
|
|
24
|
+
(e) => e.children.length === 0 && (e.innerText || "").trim() === "小程序代码上传密钥",
|
|
25
|
+
);
|
|
26
|
+
let n = label;
|
|
27
|
+
for (let i = 0; i < 8 && n; i++) {
|
|
28
|
+
n = n.parentElement;
|
|
29
|
+
if (!n) break;
|
|
30
|
+
const c = Array.from(n.querySelectorAll("a,button,span,div")).filter(
|
|
31
|
+
(e) => e.children.length === 0 && (e.innerText || "").trim() === "重置",
|
|
32
|
+
);
|
|
33
|
+
if (c[0]) {
|
|
34
|
+
const r = c[0].getBoundingClientRect();
|
|
35
|
+
return { x: r.x + r.width / 2, y: r.y + r.height / 2 };
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
return null;
|
|
39
|
+
});
|
|
40
|
+
await page.mouse.click(btn.x, btn.y);
|
|
41
|
+
await page.waitForTimeout(4000);
|
|
42
|
+
|
|
43
|
+
const info = await page.evaluate(() => {
|
|
44
|
+
const dlg = document.querySelector(".weui-desktop-dialog") || document.body;
|
|
45
|
+
const out = { imgs: [], canvases: [], divs: [] };
|
|
46
|
+
for (const img of dlg.querySelectorAll("img")) {
|
|
47
|
+
const r = img.getBoundingClientRect();
|
|
48
|
+
out.imgs.push({
|
|
49
|
+
srcKind: (img.src || "").slice(0, 40),
|
|
50
|
+
dataUrl: (img.src || "").startsWith("data:"),
|
|
51
|
+
nat: `${img.naturalWidth}x${img.naturalHeight}`,
|
|
52
|
+
rect: `${Math.round(r.width)}x${Math.round(r.height)}`,
|
|
53
|
+
cls: (img.className || "").toString(),
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
for (const cv of dlg.querySelectorAll("canvas")) {
|
|
57
|
+
const r = cv.getBoundingClientRect();
|
|
58
|
+
out.canvases.push({
|
|
59
|
+
size: `${cv.width}x${cv.height}`,
|
|
60
|
+
rect: `${Math.round(r.width)}x${Math.round(r.height)}`,
|
|
61
|
+
cls: (cv.className || "").toString(),
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
for (const d of dlg.querySelectorAll("div,span")) {
|
|
65
|
+
const r = d.getBoundingClientRect();
|
|
66
|
+
const bg = getComputedStyle(d).backgroundImage;
|
|
67
|
+
if (bg && bg !== "none" && r.width > 80)
|
|
68
|
+
out.divs.push({
|
|
69
|
+
bg: bg.slice(0, 80),
|
|
70
|
+
rect: `${Math.round(r.width)}x${Math.round(r.height)}`,
|
|
71
|
+
cls: (d.className || "").toString().slice(0, 60),
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
return out;
|
|
75
|
+
});
|
|
76
|
+
console.log(JSON.stringify(info, null, 2));
|
|
77
|
+
|
|
78
|
+
// 尝试从 img(data URL)或 canvas 取原始位图
|
|
79
|
+
const raw = await page.evaluate(() => {
|
|
80
|
+
const dlg = document.querySelector(".weui-desktop-dialog") || document.body;
|
|
81
|
+
const toPng = (src, w, h) => {
|
|
82
|
+
const c = document.createElement("canvas");
|
|
83
|
+
c.width = w;
|
|
84
|
+
c.height = h;
|
|
85
|
+
const g = c.getContext("2d");
|
|
86
|
+
g.fillStyle = "#fff";
|
|
87
|
+
g.fillRect(0, 0, w, h);
|
|
88
|
+
g.drawImage(src, 0, 0, w, h);
|
|
89
|
+
return c.toDataURL("image/png").split(",")[1];
|
|
90
|
+
};
|
|
91
|
+
for (const img of dlg.querySelectorAll("img"))
|
|
92
|
+
if (img.naturalWidth >= 100)
|
|
93
|
+
return {
|
|
94
|
+
kind: "img",
|
|
95
|
+
w: img.naturalWidth,
|
|
96
|
+
h: img.naturalHeight,
|
|
97
|
+
png: toPng(img, img.naturalWidth, img.naturalHeight),
|
|
98
|
+
};
|
|
99
|
+
for (const cv of dlg.querySelectorAll("canvas"))
|
|
100
|
+
if (cv.width >= 100)
|
|
101
|
+
return {
|
|
102
|
+
kind: "canvas",
|
|
103
|
+
w: cv.width,
|
|
104
|
+
h: cv.height,
|
|
105
|
+
png: cv.toDataURL("image/png").split(",")[1],
|
|
106
|
+
};
|
|
107
|
+
return null;
|
|
108
|
+
});
|
|
109
|
+
if (raw) {
|
|
110
|
+
const buf = Buffer.from(raw.png, "base64");
|
|
111
|
+
fs.writeFileSync(path.join(outDir, "probe-key-qr-native.png"), buf);
|
|
112
|
+
const png = PNG.sync.read(buf);
|
|
113
|
+
const dec = jsQR(new Uint8Array(png.data), png.width, png.height);
|
|
114
|
+
console.log(
|
|
115
|
+
"RAW kind",
|
|
116
|
+
raw.kind,
|
|
117
|
+
png.width + "x" + png.height,
|
|
118
|
+
"jsQR:",
|
|
119
|
+
dec ? dec.data.slice(0, 90) : "FAIL",
|
|
120
|
+
);
|
|
121
|
+
// 3 倍最近邻放大再试
|
|
122
|
+
const s = 3;
|
|
123
|
+
const big = new PNG({ width: png.width * s, height: png.height * s });
|
|
124
|
+
for (let y = 0; y < big.height; y++)
|
|
125
|
+
for (let x = 0; x < big.width; x++) {
|
|
126
|
+
const si = (((y / s) | 0) * png.width + ((x / s) | 0)) << 2,
|
|
127
|
+
di = (y * big.width + x) << 2;
|
|
128
|
+
big.data[di] = png.data[si];
|
|
129
|
+
big.data[di + 1] = png.data[si + 1];
|
|
130
|
+
big.data[di + 2] = png.data[si + 2];
|
|
131
|
+
big.data[di + 3] = 255;
|
|
132
|
+
}
|
|
133
|
+
const bigBuf = PNG.sync.write(big);
|
|
134
|
+
fs.writeFileSync(path.join(outDir, "probe-key-qr-3x.png"), bigBuf);
|
|
135
|
+
const dec2 = jsQR(new Uint8Array(big.data), big.width, big.height);
|
|
136
|
+
console.log("3x", big.width + "x" + big.height, "jsQR:", dec2 ? dec2.data.slice(0, 90) : "FAIL");
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
// 元素截图对比
|
|
140
|
+
const el = page.locator(".weui-desktop-dialog canvas, .weui-desktop-dialog img").first();
|
|
141
|
+
if (await el.count().catch(() => 0)) {
|
|
142
|
+
await el.screenshot({ path: path.join(outDir, "probe-key-qr-el.png") }).catch(() => {});
|
|
143
|
+
console.log("element shot saved");
|
|
144
|
+
}
|
|
145
|
+
await page.screenshot({ path: path.join(outDir, "probe-key-qr-page.png") }).catch(() => {});
|
|
146
|
+
await ctx.close().catch(() => {});
|
|
147
|
+
process.exit(0);
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
// 探查隐私保护指引页:iframe / 网络失败原因
|
|
2
|
+
import { launchStealth } from "./stealth.mjs";
|
|
3
|
+
import fs from "node:fs";
|
|
4
|
+
import path from "node:path";
|
|
5
|
+
import { fileURLToPath } from "node:url";
|
|
6
|
+
|
|
7
|
+
const here = path.dirname(fileURLToPath(import.meta.url));
|
|
8
|
+
const outDir = process.argv[2] || here;
|
|
9
|
+
const log = (...a) => console.log(new Date().toISOString(), ...a);
|
|
10
|
+
|
|
11
|
+
const ctx = await launchStealth(path.join(here, "profile"), { headless: false });
|
|
12
|
+
const page = ctx.pages()[0] || (await ctx.newPage());
|
|
13
|
+
const errs = [];
|
|
14
|
+
page.on("requestfailed", (r) =>
|
|
15
|
+
errs.push(`FAIL ${r.failure()?.errorText || ""} ${r.url().slice(0, 160)}`),
|
|
16
|
+
);
|
|
17
|
+
page.on("response", (r) => {
|
|
18
|
+
const u = r.url();
|
|
19
|
+
if (r.status() >= 400) errs.push(`HTTP ${r.status()} ${u.slice(0, 160)}`);
|
|
20
|
+
});
|
|
21
|
+
page.on("pageerror", (e) => errs.push(`PAGEERR ${String(e.message).slice(0, 200)}`));
|
|
22
|
+
page.on("framenavigated", (f) => log("frame nav", f.url().slice(0, 160)));
|
|
23
|
+
|
|
24
|
+
await page
|
|
25
|
+
.goto("https://mp.weixin.qq.com/", { waitUntil: "commit", timeout: 60000 })
|
|
26
|
+
.catch(() => {});
|
|
27
|
+
await page.waitForTimeout(15000);
|
|
28
|
+
const token = (page.url().match(/token=(\d+)/) || [])[1];
|
|
29
|
+
await page
|
|
30
|
+
.goto(`https://mp.weixin.qq.com/wxamp/wadevelopcode/privacy?token=${token}&lang=zh_CN`, {
|
|
31
|
+
waitUntil: "commit",
|
|
32
|
+
timeout: 60000,
|
|
33
|
+
})
|
|
34
|
+
.catch(() => {});
|
|
35
|
+
await page.waitForTimeout(25000);
|
|
36
|
+
|
|
37
|
+
const info = await page.evaluate(() => {
|
|
38
|
+
const vis = (e) => !!(e.offsetWidth || e.offsetHeight);
|
|
39
|
+
const frames = Array.from(document.querySelectorAll("iframe")).map((f) => ({
|
|
40
|
+
src: (f.src || "").slice(0, 160),
|
|
41
|
+
w: f.offsetWidth,
|
|
42
|
+
h: f.offsetHeight,
|
|
43
|
+
}));
|
|
44
|
+
const btns = [
|
|
45
|
+
...new Set(
|
|
46
|
+
Array.from(document.querySelectorAll('button,a,[role="button"],div,span'))
|
|
47
|
+
.filter((e) => vis(e) && e.children.length === 0)
|
|
48
|
+
.map((e) => (e.innerText || "").replace(/\s+/g, " ").trim())
|
|
49
|
+
.filter((t) => t && t.length <= 12),
|
|
50
|
+
),
|
|
51
|
+
];
|
|
52
|
+
const inputs = Array.from(document.querySelectorAll("input,textarea,select"))
|
|
53
|
+
.filter(vis)
|
|
54
|
+
.map((e) => ({ tag: e.tagName, ph: e.placeholder || "", val: (e.value || "").slice(0, 30) }));
|
|
55
|
+
return {
|
|
56
|
+
url: location.href,
|
|
57
|
+
frames,
|
|
58
|
+
btns,
|
|
59
|
+
inputs,
|
|
60
|
+
text: (document.body.innerText || "").replace(/\s+/g, " ").slice(0, 1500),
|
|
61
|
+
};
|
|
62
|
+
});
|
|
63
|
+
log("frames", JSON.stringify(info.frames));
|
|
64
|
+
log("btns", JSON.stringify(info.btns));
|
|
65
|
+
log("inputs", JSON.stringify(info.inputs));
|
|
66
|
+
log("text", info.text.slice(0, 900));
|
|
67
|
+
log("--- errors ---");
|
|
68
|
+
for (const e of [...new Set(errs)].slice(0, 40)) log(e);
|
|
69
|
+
await page
|
|
70
|
+
.screenshot({ path: path.join(outDir, "probe-privacy.png"), fullPage: true })
|
|
71
|
+
.catch(() => {});
|
|
72
|
+
await ctx.close().catch(() => {});
|
|
73
|
+
process.exit(0);
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
// 提交审核流程中抓 CheckPrivacyApiAuth 的响应体,确认卡点
|
|
2
|
+
import { launchStealth } from "./stealth.mjs";
|
|
3
|
+
import fs from "node:fs";
|
|
4
|
+
import path from "node:path";
|
|
5
|
+
import { fileURLToPath } from "node:url";
|
|
6
|
+
|
|
7
|
+
const here = path.dirname(fileURLToPath(import.meta.url));
|
|
8
|
+
const outDir = process.argv[2] || here;
|
|
9
|
+
const keyword = process.argv[3] || "待办清单";
|
|
10
|
+
const log = (...a) => console.log(new Date().toISOString(), ...a);
|
|
11
|
+
|
|
12
|
+
const ctx = await launchStealth(path.join(here, "profile"), { headless: false });
|
|
13
|
+
const page = ctx.pages()[0] || (await ctx.newPage());
|
|
14
|
+
const bodies = [];
|
|
15
|
+
page.on("response", async (r) => {
|
|
16
|
+
const u = r.url();
|
|
17
|
+
if (/privacy|Privacy|submit|audit/i.test(u) && !/aegis|res\.wx\.qq\.com/.test(u)) {
|
|
18
|
+
let body = "";
|
|
19
|
+
try {
|
|
20
|
+
body = (await r.text()).slice(0, 600);
|
|
21
|
+
} catch {}
|
|
22
|
+
bodies.push(`[${r.status()}] ${u.slice(0, 140)}\n ${body}`);
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
page.on("pageerror", (e) => bodies.push("PAGEERR " + String(e.message).slice(0, 200)));
|
|
26
|
+
|
|
27
|
+
await page
|
|
28
|
+
.goto("https://mp.weixin.qq.com/", { waitUntil: "commit", timeout: 60000 })
|
|
29
|
+
.catch(() => {});
|
|
30
|
+
await page.waitForTimeout(15000);
|
|
31
|
+
const token = (page.url().match(/token=(\d+)/) || [])[1];
|
|
32
|
+
if (!token) {
|
|
33
|
+
log("NOT LOGGED IN");
|
|
34
|
+
await ctx.close().catch(() => {});
|
|
35
|
+
process.exit(2);
|
|
36
|
+
}
|
|
37
|
+
await page
|
|
38
|
+
.goto(`https://mp.weixin.qq.com/wxamp/wacodepage/getcodepage?token=${token}&lang=zh_CN`, {
|
|
39
|
+
waitUntil: "commit",
|
|
40
|
+
timeout: 60000,
|
|
41
|
+
})
|
|
42
|
+
.catch(() => {});
|
|
43
|
+
await page.waitForTimeout(15000);
|
|
44
|
+
|
|
45
|
+
const bodyText = () => page.evaluate(() => (document.body.innerText || "").replace(/\s+/g, " "));
|
|
46
|
+
const findBtn = () =>
|
|
47
|
+
page.evaluate((kw) => {
|
|
48
|
+
const marker = Array.from(document.querySelectorAll("*")).find(
|
|
49
|
+
(e) => e.children.length === 0 && (e.innerText || "").includes(kw),
|
|
50
|
+
);
|
|
51
|
+
const btns = Array.from(document.querySelectorAll("button,a")).filter(
|
|
52
|
+
(e) => e.offsetWidth && (e.innerText || "").trim() === "提交审核",
|
|
53
|
+
);
|
|
54
|
+
if (!btns.length) return null;
|
|
55
|
+
const my = marker ? marker.getBoundingClientRect().y : 0;
|
|
56
|
+
const chosen = btns
|
|
57
|
+
.map((b) => ({ b, y: b.getBoundingClientRect().y }))
|
|
58
|
+
.filter((o) => o.y > my - 40)
|
|
59
|
+
.sort((a, b) => a.y - b.y)[0];
|
|
60
|
+
const b = chosen ? chosen.b : btns[0];
|
|
61
|
+
b.scrollIntoView({ block: "center" });
|
|
62
|
+
const r = b.getBoundingClientRect();
|
|
63
|
+
return { x: r.x + r.width / 2, y: r.y + r.height / 2 };
|
|
64
|
+
}, keyword);
|
|
65
|
+
|
|
66
|
+
let opened = false;
|
|
67
|
+
for (let i = 0; i < 3 && !opened; i++) {
|
|
68
|
+
const p = await findBtn();
|
|
69
|
+
if (!p) break;
|
|
70
|
+
await page.mouse.click(p.x, p.y);
|
|
71
|
+
for (let w = 0; w < 12; w++) {
|
|
72
|
+
await page.waitForTimeout(1000);
|
|
73
|
+
if (/确认提交审核/.test(await bodyText())) {
|
|
74
|
+
opened = true;
|
|
75
|
+
break;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
log("notice opened", opened);
|
|
80
|
+
if (!opened) {
|
|
81
|
+
await ctx.close().catch(() => {});
|
|
82
|
+
process.exit(4);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
for (const t of ["已仔细阅读", "已阅读并了解平台审核规则"]) {
|
|
86
|
+
const c = await page.evaluate((t) => {
|
|
87
|
+
const el = Array.from(document.querySelectorAll("label,span,div,p"))
|
|
88
|
+
.filter(
|
|
89
|
+
(e) => e.offsetWidth && (e.innerText || "").includes(t) && (e.innerText || "").length < 120,
|
|
90
|
+
)
|
|
91
|
+
.pop();
|
|
92
|
+
if (!el) return null;
|
|
93
|
+
const r = el.getBoundingClientRect();
|
|
94
|
+
return { x: r.x + 12, y: r.y + r.height / 2 };
|
|
95
|
+
}, t);
|
|
96
|
+
if (c) {
|
|
97
|
+
await page.mouse.click(c.x, c.y);
|
|
98
|
+
await page.waitForTimeout(700);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
const clickText = async (txt) => {
|
|
102
|
+
const p = await page.evaluate((txt) => {
|
|
103
|
+
const e = Array.from(document.querySelectorAll("button,a,span,div,label"))
|
|
104
|
+
.filter((x) => x.offsetWidth && x.children.length === 0 && (x.innerText || "").trim() === txt)
|
|
105
|
+
.pop();
|
|
106
|
+
if (!e) return null;
|
|
107
|
+
e.scrollIntoView({ block: "center" });
|
|
108
|
+
const r = e.getBoundingClientRect();
|
|
109
|
+
return { x: r.x + r.width / 2, y: r.y + r.height / 2 };
|
|
110
|
+
}, txt);
|
|
111
|
+
if (!p) {
|
|
112
|
+
log("no btn", txt);
|
|
113
|
+
return false;
|
|
114
|
+
}
|
|
115
|
+
await page.mouse.click(p.x, p.y);
|
|
116
|
+
await page.waitForTimeout(4000);
|
|
117
|
+
return true;
|
|
118
|
+
};
|
|
119
|
+
await clickText("下一步");
|
|
120
|
+
await clickText("继续提交");
|
|
121
|
+
await page.waitForTimeout(12000);
|
|
122
|
+
|
|
123
|
+
log("final url", page.url());
|
|
124
|
+
log("--- privacy/submit responses ---");
|
|
125
|
+
for (const b of bodies.slice(-20)) log(b);
|
|
126
|
+
fs.writeFileSync(path.join(outDir, "privcheck.log"), bodies.join("\n\n"));
|
|
127
|
+
await page.screenshot({ path: path.join(outDir, "privcheck.png"), fullPage: true }).catch(() => {});
|
|
128
|
+
await ctx.close().catch(() => {});
|
|
129
|
+
process.exit(0);
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
// 正确姿势点「切换账号」:先点开左下角账号面板,再点菜单项,观察结果
|
|
2
|
+
import { launchStealth } from "./stealth.mjs";
|
|
3
|
+
import fs from "node:fs";
|
|
4
|
+
import path from "node:path";
|
|
5
|
+
import { fileURLToPath } from "node:url";
|
|
6
|
+
|
|
7
|
+
const here = path.dirname(fileURLToPath(import.meta.url));
|
|
8
|
+
const out = process.argv[2] || "/tmp/probe-switch3.json";
|
|
9
|
+
const shotPrefix = process.argv[3] || "/tmp/probe-switch3";
|
|
10
|
+
const ctx = await launchStealth(path.join(here, "profile"), { headless: false });
|
|
11
|
+
const page = ctx.pages()[0] || (await ctx.newPage());
|
|
12
|
+
page.on("dialog", (d) => {
|
|
13
|
+
console.log("DIALOG", d.type(), d.message());
|
|
14
|
+
d.dismiss().catch(() => {});
|
|
15
|
+
});
|
|
16
|
+
page.on("framenavigated", (f) => {
|
|
17
|
+
if (f === page.mainFrame()) console.log("NAV", f.url());
|
|
18
|
+
});
|
|
19
|
+
await page.goto("https://mp.weixin.qq.com/", { waitUntil: "domcontentloaded", timeout: 60000 });
|
|
20
|
+
await page.waitForTimeout(8000);
|
|
21
|
+
|
|
22
|
+
const items = page.locator("li.account_box-panel-item");
|
|
23
|
+
console.log(
|
|
24
|
+
"panel items",
|
|
25
|
+
await items.count(),
|
|
26
|
+
"visible0",
|
|
27
|
+
await items
|
|
28
|
+
.first()
|
|
29
|
+
.isVisible()
|
|
30
|
+
.catch(() => null),
|
|
31
|
+
);
|
|
32
|
+
await page
|
|
33
|
+
.click(".mp_account_box", { timeout: 5000 })
|
|
34
|
+
.catch((e) => console.log("open err", e.message.split("\n")[0]));
|
|
35
|
+
await page.waitForTimeout(1500);
|
|
36
|
+
console.log(
|
|
37
|
+
"visible after open",
|
|
38
|
+
await items
|
|
39
|
+
.first()
|
|
40
|
+
.isVisible()
|
|
41
|
+
.catch(() => null),
|
|
42
|
+
);
|
|
43
|
+
await page.screenshot({ path: `${shotPrefix}-a.png` }).catch(() => {});
|
|
44
|
+
|
|
45
|
+
const target = page.locator("li.account_box-panel-item", { hasText: "切换账号" }).first();
|
|
46
|
+
const box = await target.boundingBox().catch(() => null);
|
|
47
|
+
console.log("box", JSON.stringify(box));
|
|
48
|
+
if (box) await page.mouse.click(box.x + box.width / 2, box.y + box.height / 2);
|
|
49
|
+
else
|
|
50
|
+
await target
|
|
51
|
+
.click({ timeout: 5000, force: true })
|
|
52
|
+
.catch((e) => console.log("click err", e.message.split("\n")[0]));
|
|
53
|
+
await page.waitForTimeout(7000);
|
|
54
|
+
console.log("url after", page.url());
|
|
55
|
+
|
|
56
|
+
// 收集可能的 toast / 弹窗文字
|
|
57
|
+
const info = await page.evaluate(() => {
|
|
58
|
+
const vis = (e) => !!(e.offsetWidth || e.offsetHeight);
|
|
59
|
+
const dialogs = [];
|
|
60
|
+
for (const e of document.querySelectorAll(
|
|
61
|
+
'[class*="dialog"],[class*="toast"],[class*="modal"],[class*="message_box"],[class*="weui-desktop-dialog"]',
|
|
62
|
+
)) {
|
|
63
|
+
if (!vis(e)) continue;
|
|
64
|
+
const t = (e.innerText || "").replace(/\s+/g, " ").trim();
|
|
65
|
+
if (t)
|
|
66
|
+
dialogs.push({
|
|
67
|
+
cls: (e.className || "").toString().slice(0, 100),
|
|
68
|
+
t: t.slice(0, 300),
|
|
69
|
+
html: e.outerHTML.slice(0, 500),
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
const qrs = Array.from(document.querySelectorAll("img"))
|
|
73
|
+
.filter(vis)
|
|
74
|
+
.map((i) => ({
|
|
75
|
+
src: (i.src || "").slice(0, 60),
|
|
76
|
+
w: i.naturalWidth,
|
|
77
|
+
h: i.naturalHeight,
|
|
78
|
+
cls: (i.className || "").toString().slice(0, 60),
|
|
79
|
+
}))
|
|
80
|
+
.filter((i) => i.w > 100 && i.h > 100);
|
|
81
|
+
const clickableTexts = [];
|
|
82
|
+
for (const e of document.querySelectorAll("a,li,div,section,button")) {
|
|
83
|
+
if (!vis(e)) continue;
|
|
84
|
+
const t = (e.innerText || "").replace(/\s+/g, " ").trim();
|
|
85
|
+
if (!t || t.length > 30) continue;
|
|
86
|
+
const cls = (e.className || "").toString();
|
|
87
|
+
if (/account|item|card|select|choose|login__type|dialog/i.test(cls))
|
|
88
|
+
clickableTexts.push({ tag: e.tagName, cls: cls.slice(0, 90), t });
|
|
89
|
+
}
|
|
90
|
+
return {
|
|
91
|
+
url: location.href,
|
|
92
|
+
text: (document.body.innerText || "").replace(/\n{2,}/g, "\n").slice(0, 900),
|
|
93
|
+
dialogs: dialogs.slice(0, 8),
|
|
94
|
+
qrs,
|
|
95
|
+
clickableTexts: clickableTexts.slice(0, 30),
|
|
96
|
+
};
|
|
97
|
+
});
|
|
98
|
+
await page.screenshot({ path: `${shotPrefix}-b.png` }).catch(() => {});
|
|
99
|
+
fs.writeFileSync(out, JSON.stringify(info, null, 2));
|
|
100
|
+
console.log("dialogs", JSON.stringify(info.dialogs.slice(0, 3)));
|
|
101
|
+
console.log("qrs", JSON.stringify(info.qrs));
|
|
102
|
+
console.log("clickable", JSON.stringify(info.clickableTexts.slice(0, 20)));
|
|
103
|
+
console.log("text:", info.text.replace(/\n/g, " | ").slice(0, 600));
|
|
104
|
+
await ctx.close();
|