原文
import { mochi } from "@mochi.js/core";
// boot a stealth browser in three lines
const session = await mochi.launch({
profile: "linux-chrome-stable",
seed: "user-12345",
});
const page = await session.newPage();
await page.goto("https://target.example/checkout");
console.log("UA:", session.profile.userAgent);
await session.close(); import { mochi } from "@mochi.js/core";
// auto-click visible-checkbox Turnstile. Other variants → onEscalation.
const session = await mochi.launch({
profile: "mac-m4-chrome-stable",
seed: "warm-session-001",
challenges: {
turnstile: {
autoClick: true,
onEscalation: (reason) => {
console.warn("Turnstile escalated:", reason);
},
},
},
});
const page = await session.newPage();
await page.goto("https://protected.example/login"); import { mochi } from "@mochi.js/core";
const session = await mochi.launch({ profile: "win11-chrome-stable", seed: "abc" });
const page = await session.newPage();
// Run a custom inject before any page script. JIT-friendly proxy traps.
const installed = await page.addInitScript(`
Object.defineProperty(window, "__site_marker", { value: "mochi", configurable: false });
`);
await page.goto("https://example.com");
// ...later: remove the inject from future navigations.
await page.removeInitScript(installed);