mirror of
https://github.com/JimLiu/baoyu-skills.git
synced 2026-07-12 05:51:44 +08:00
Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| b791ee5dc7 | |||
| 450c76d955 | |||
| db33da26e7 | |||
| c7c98ba034 | |||
| 60ab574559 |
@@ -6,7 +6,7 @@
|
|||||||
},
|
},
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"description": "Skills shared by Baoyu for improving daily work efficiency",
|
"description": "Skills shared by Baoyu for improving daily work efficiency",
|
||||||
"version": "1.89.0"
|
"version": "1.89.1"
|
||||||
},
|
},
|
||||||
"plugins": [
|
"plugins": [
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -2,6 +2,16 @@
|
|||||||
|
|
||||||
English | [中文](./CHANGELOG.zh.md)
|
English | [中文](./CHANGELOG.zh.md)
|
||||||
|
|
||||||
|
## 1.89.1 - 2026-04-01
|
||||||
|
|
||||||
|
### Features
|
||||||
|
- `baoyu-chrome-cdp`: add `gracefulKillChrome` that waits for Chrome to exit and release its port; fix `killChrome` to use `exitCode`/`signalCode` instead of `.killed` for reliable process state detection
|
||||||
|
- `baoyu-fetch`: auto-detect login state before extraction in interaction wait mode
|
||||||
|
|
||||||
|
### Maintenance
|
||||||
|
- Sync vendor baoyu-chrome-cdp across CDP skills
|
||||||
|
- `baoyu-url-to-markdown`: sync vendor baoyu-fetch with login auto-detect
|
||||||
|
|
||||||
## 1.89.0 - 2026-03-31
|
## 1.89.0 - 2026-03-31
|
||||||
|
|
||||||
### Features
|
### Features
|
||||||
|
|||||||
@@ -2,6 +2,16 @@
|
|||||||
|
|
||||||
[English](./CHANGELOG.md) | 中文
|
[English](./CHANGELOG.md) | 中文
|
||||||
|
|
||||||
|
## 1.89.1 - 2026-04-01
|
||||||
|
|
||||||
|
### 新功能
|
||||||
|
- `baoyu-chrome-cdp`:新增 `gracefulKillChrome`,等待 Chrome 进程退出并释放端口;修复 `killChrome` 使用 `exitCode`/`signalCode` 替代 `.killed` 以更可靠地检测进程状态
|
||||||
|
- `baoyu-fetch`:在交互等待模式下自动检测登录状态,未登录时提示用户先登录再提取内容
|
||||||
|
|
||||||
|
### 维护
|
||||||
|
- 同步 vendor baoyu-chrome-cdp 至所有 CDP 技能
|
||||||
|
- `baoyu-url-to-markdown`:同步 vendor baoyu-fetch 的登录自动检测功能
|
||||||
|
|
||||||
## 1.89.0 - 2026-03-31
|
## 1.89.0 - 2026-03-31
|
||||||
|
|
||||||
### 新功能
|
### 新功能
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
# CLAUDE.md
|
# CLAUDE.md
|
||||||
|
|
||||||
Claude Code marketplace plugin providing AI-powered content generation skills. Version: **1.89.0**.
|
Claude Code marketplace plugin providing AI-powered content generation skills. Version: **1.89.1**.
|
||||||
|
|
||||||
## Architecture
|
## Architecture
|
||||||
|
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import {
|
|||||||
discoverRunningChromeDebugPort,
|
discoverRunningChromeDebugPort,
|
||||||
findChromeExecutable,
|
findChromeExecutable,
|
||||||
findExistingChromeDebugPort,
|
findExistingChromeDebugPort,
|
||||||
|
gracefulKillChrome,
|
||||||
getFreePort,
|
getFreePort,
|
||||||
openPageSession,
|
openPageSession,
|
||||||
resolveSharedChromeProfileDir,
|
resolveSharedChromeProfileDir,
|
||||||
@@ -110,6 +111,44 @@ async function stopProcess(child: ChildProcess | null): Promise<void> {
|
|||||||
await new Promise((resolve) => child.once("exit", resolve));
|
await new Promise((resolve) => child.once("exit", resolve));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function startPortHoldingProcess(port: number): Promise<ChildProcess> {
|
||||||
|
const child = spawn(
|
||||||
|
process.execPath,
|
||||||
|
[
|
||||||
|
"-e",
|
||||||
|
`
|
||||||
|
const http = require("node:http");
|
||||||
|
const port = Number(process.argv[1]);
|
||||||
|
const server = http.createServer((_req, res) => res.end("ok"));
|
||||||
|
server.listen(port, "127.0.0.1", () => process.stdout.write("ready\\n"));
|
||||||
|
setInterval(() => {}, 1000);
|
||||||
|
`,
|
||||||
|
String(port),
|
||||||
|
],
|
||||||
|
{
|
||||||
|
stdio: ["ignore", "pipe", "ignore"],
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
await new Promise<void>((resolve, reject) => {
|
||||||
|
const timer = setTimeout(() => reject(new Error("Timed out waiting for child server to start.")), 3_000);
|
||||||
|
child.once("error", (error) => {
|
||||||
|
clearTimeout(timer);
|
||||||
|
reject(error);
|
||||||
|
});
|
||||||
|
child.stdout?.once("data", () => {
|
||||||
|
clearTimeout(timer);
|
||||||
|
resolve();
|
||||||
|
});
|
||||||
|
child.once("exit", () => {
|
||||||
|
clearTimeout(timer);
|
||||||
|
reject(new Error("Child server exited before becoming ready."));
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
return child;
|
||||||
|
}
|
||||||
|
|
||||||
test("getFreePort honors a fixed environment override and otherwise allocates a TCP port", async (t) => {
|
test("getFreePort honors a fixed environment override and otherwise allocates a TCP port", async (t) => {
|
||||||
useEnv(t, { TEST_FIXED_PORT: "45678" });
|
useEnv(t, { TEST_FIXED_PORT: "45678" });
|
||||||
assert.equal(await getFreePort("TEST_FIXED_PORT"), 45678);
|
assert.equal(await getFreePort("TEST_FIXED_PORT"), 45678);
|
||||||
@@ -305,3 +344,19 @@ test("waitForChromeDebugPort retries until the debug endpoint becomes available"
|
|||||||
|
|
||||||
assert.equal(websocketUrl, `ws://127.0.0.1:${port}/devtools/browser/demo`);
|
assert.equal(websocketUrl, `ws://127.0.0.1:${port}/devtools/browser/demo`);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test("gracefulKillChrome waits for the Chrome process to exit and release its port", async (t) => {
|
||||||
|
const port = await getFreePort();
|
||||||
|
const child = await startPortHoldingProcess(port);
|
||||||
|
t.after(async () => { await stopProcess(child); });
|
||||||
|
|
||||||
|
assert.equal(await waitForChromeDebugPort(port, 1_000).catch(() => null), null);
|
||||||
|
|
||||||
|
await gracefulKillChrome(child, port, 4_000);
|
||||||
|
|
||||||
|
assert.ok(child.exitCode !== null || child.signalCode !== null);
|
||||||
|
assert.equal(
|
||||||
|
await fetch(`http://127.0.0.1:${port}`).then(() => true).catch(() => false),
|
||||||
|
false,
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|||||||
@@ -478,7 +478,7 @@ export function killChrome(chrome: ChildProcess): void {
|
|||||||
chrome.kill("SIGTERM");
|
chrome.kill("SIGTERM");
|
||||||
} catch {}
|
} catch {}
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
if (!chrome.killed) {
|
if (chrome.exitCode === null && chrome.signalCode === null) {
|
||||||
try {
|
try {
|
||||||
chrome.kill("SIGKILL");
|
chrome.kill("SIGKILL");
|
||||||
} catch {}
|
} catch {}
|
||||||
@@ -486,6 +486,37 @@ export function killChrome(chrome: ChildProcess): void {
|
|||||||
}, 2_000).unref?.();
|
}, 2_000).unref?.();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function gracefulKillChrome(
|
||||||
|
chrome: ChildProcess,
|
||||||
|
port?: number,
|
||||||
|
timeoutMs = 6_000,
|
||||||
|
): Promise<void> {
|
||||||
|
if (chrome.exitCode !== null || chrome.signalCode !== null) return;
|
||||||
|
|
||||||
|
const exitPromise = new Promise<void>((resolve) => {
|
||||||
|
chrome.once("exit", () => resolve());
|
||||||
|
});
|
||||||
|
|
||||||
|
killChrome(chrome);
|
||||||
|
|
||||||
|
const start = Date.now();
|
||||||
|
while (Date.now() - start < timeoutMs) {
|
||||||
|
if (chrome.exitCode !== null || chrome.signalCode !== null) return;
|
||||||
|
if (port !== undefined && !await isPortListening(port, 250)) return;
|
||||||
|
|
||||||
|
const exited = await Promise.race([
|
||||||
|
exitPromise.then(() => true),
|
||||||
|
sleep(100).then(() => false),
|
||||||
|
]);
|
||||||
|
if (exited) return;
|
||||||
|
}
|
||||||
|
|
||||||
|
await Promise.race([
|
||||||
|
exitPromise,
|
||||||
|
sleep(250),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
export async function openPageSession(options: OpenPageSessionOptions): Promise<PageSession> {
|
export async function openPageSession(options: OpenPageSessionOptions): Promise<PageSession> {
|
||||||
let targetId: string;
|
let targetId: string;
|
||||||
let createdTarget = false;
|
let createdTarget = false;
|
||||||
|
|||||||
@@ -399,6 +399,22 @@ export async function runConvertCommand(options: ConvertCommandOptions): Promise
|
|||||||
if (restored) logger.info(`Restored ${adapter.name} session cookies from sidecar.`);
|
if (restored) logger.info(`Restored ${adapter.name} session cookies from sidecar.`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (options.waitMode === "interaction" && adapter.checkLogin) {
|
||||||
|
await context.browser.goto(url.toString(), options.timeoutMs).catch(() => {});
|
||||||
|
const preLogin = await adapter.checkLogin(context);
|
||||||
|
if (preLogin.state !== "logged_in") {
|
||||||
|
didLogin = true;
|
||||||
|
await waitForInteraction(adapter, context, {
|
||||||
|
type: "wait_for_interaction",
|
||||||
|
kind: "login",
|
||||||
|
provider: preLogin.provider ?? adapter.name,
|
||||||
|
prompt: `Please sign in to ${adapter.name === "x" ? "X" : adapter.name} in the opened Chrome window. Extraction will continue automatically once login is detected.`,
|
||||||
|
reason: preLogin.reason ?? `Not logged in to ${adapter.name}`,
|
||||||
|
requiresVisibleBrowser: true,
|
||||||
|
}, options);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (options.waitMode === "force") {
|
if (options.waitMode === "force") {
|
||||||
await context.browser.goto(url.toString(), options.timeoutMs).catch(() => {});
|
await context.browser.goto(url.toString(), options.timeoutMs).catch(() => {});
|
||||||
await waitForForceResume(adapter, context, options);
|
await waitForForceResume(adapter, context, options);
|
||||||
|
|||||||
+32
-1
@@ -478,7 +478,7 @@ export function killChrome(chrome: ChildProcess): void {
|
|||||||
chrome.kill("SIGTERM");
|
chrome.kill("SIGTERM");
|
||||||
} catch {}
|
} catch {}
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
if (!chrome.killed) {
|
if (chrome.exitCode === null && chrome.signalCode === null) {
|
||||||
try {
|
try {
|
||||||
chrome.kill("SIGKILL");
|
chrome.kill("SIGKILL");
|
||||||
} catch {}
|
} catch {}
|
||||||
@@ -486,6 +486,37 @@ export function killChrome(chrome: ChildProcess): void {
|
|||||||
}, 2_000).unref?.();
|
}, 2_000).unref?.();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function gracefulKillChrome(
|
||||||
|
chrome: ChildProcess,
|
||||||
|
port?: number,
|
||||||
|
timeoutMs = 6_000,
|
||||||
|
): Promise<void> {
|
||||||
|
if (chrome.exitCode !== null || chrome.signalCode !== null) return;
|
||||||
|
|
||||||
|
const exitPromise = new Promise<void>((resolve) => {
|
||||||
|
chrome.once("exit", () => resolve());
|
||||||
|
});
|
||||||
|
|
||||||
|
killChrome(chrome);
|
||||||
|
|
||||||
|
const start = Date.now();
|
||||||
|
while (Date.now() - start < timeoutMs) {
|
||||||
|
if (chrome.exitCode !== null || chrome.signalCode !== null) return;
|
||||||
|
if (port !== undefined && !await isPortListening(port, 250)) return;
|
||||||
|
|
||||||
|
const exited = await Promise.race([
|
||||||
|
exitPromise.then(() => true),
|
||||||
|
sleep(100).then(() => false),
|
||||||
|
]);
|
||||||
|
if (exited) return;
|
||||||
|
}
|
||||||
|
|
||||||
|
await Promise.race([
|
||||||
|
exitPromise,
|
||||||
|
sleep(250),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
export async function openPageSession(options: OpenPageSessionOptions): Promise<PageSession> {
|
export async function openPageSession(options: OpenPageSessionOptions): Promise<PageSession> {
|
||||||
let targetId: string;
|
let targetId: string;
|
||||||
let createdTarget = false;
|
let createdTarget = false;
|
||||||
|
|||||||
+32
-1
@@ -478,7 +478,7 @@ export function killChrome(chrome: ChildProcess): void {
|
|||||||
chrome.kill("SIGTERM");
|
chrome.kill("SIGTERM");
|
||||||
} catch {}
|
} catch {}
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
if (!chrome.killed) {
|
if (chrome.exitCode === null && chrome.signalCode === null) {
|
||||||
try {
|
try {
|
||||||
chrome.kill("SIGKILL");
|
chrome.kill("SIGKILL");
|
||||||
} catch {}
|
} catch {}
|
||||||
@@ -486,6 +486,37 @@ export function killChrome(chrome: ChildProcess): void {
|
|||||||
}, 2_000).unref?.();
|
}, 2_000).unref?.();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function gracefulKillChrome(
|
||||||
|
chrome: ChildProcess,
|
||||||
|
port?: number,
|
||||||
|
timeoutMs = 6_000,
|
||||||
|
): Promise<void> {
|
||||||
|
if (chrome.exitCode !== null || chrome.signalCode !== null) return;
|
||||||
|
|
||||||
|
const exitPromise = new Promise<void>((resolve) => {
|
||||||
|
chrome.once("exit", () => resolve());
|
||||||
|
});
|
||||||
|
|
||||||
|
killChrome(chrome);
|
||||||
|
|
||||||
|
const start = Date.now();
|
||||||
|
while (Date.now() - start < timeoutMs) {
|
||||||
|
if (chrome.exitCode !== null || chrome.signalCode !== null) return;
|
||||||
|
if (port !== undefined && !await isPortListening(port, 250)) return;
|
||||||
|
|
||||||
|
const exited = await Promise.race([
|
||||||
|
exitPromise.then(() => true),
|
||||||
|
sleep(100).then(() => false),
|
||||||
|
]);
|
||||||
|
if (exited) return;
|
||||||
|
}
|
||||||
|
|
||||||
|
await Promise.race([
|
||||||
|
exitPromise,
|
||||||
|
sleep(250),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
export async function openPageSession(options: OpenPageSessionOptions): Promise<PageSession> {
|
export async function openPageSession(options: OpenPageSessionOptions): Promise<PageSession> {
|
||||||
let targetId: string;
|
let targetId: string;
|
||||||
let createdTarget = false;
|
let createdTarget = false;
|
||||||
|
|||||||
@@ -478,7 +478,7 @@ export function killChrome(chrome: ChildProcess): void {
|
|||||||
chrome.kill("SIGTERM");
|
chrome.kill("SIGTERM");
|
||||||
} catch {}
|
} catch {}
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
if (!chrome.killed) {
|
if (chrome.exitCode === null && chrome.signalCode === null) {
|
||||||
try {
|
try {
|
||||||
chrome.kill("SIGKILL");
|
chrome.kill("SIGKILL");
|
||||||
} catch {}
|
} catch {}
|
||||||
@@ -486,6 +486,37 @@ export function killChrome(chrome: ChildProcess): void {
|
|||||||
}, 2_000).unref?.();
|
}, 2_000).unref?.();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function gracefulKillChrome(
|
||||||
|
chrome: ChildProcess,
|
||||||
|
port?: number,
|
||||||
|
timeoutMs = 6_000,
|
||||||
|
): Promise<void> {
|
||||||
|
if (chrome.exitCode !== null || chrome.signalCode !== null) return;
|
||||||
|
|
||||||
|
const exitPromise = new Promise<void>((resolve) => {
|
||||||
|
chrome.once("exit", () => resolve());
|
||||||
|
});
|
||||||
|
|
||||||
|
killChrome(chrome);
|
||||||
|
|
||||||
|
const start = Date.now();
|
||||||
|
while (Date.now() - start < timeoutMs) {
|
||||||
|
if (chrome.exitCode !== null || chrome.signalCode !== null) return;
|
||||||
|
if (port !== undefined && !await isPortListening(port, 250)) return;
|
||||||
|
|
||||||
|
const exited = await Promise.race([
|
||||||
|
exitPromise.then(() => true),
|
||||||
|
sleep(100).then(() => false),
|
||||||
|
]);
|
||||||
|
if (exited) return;
|
||||||
|
}
|
||||||
|
|
||||||
|
await Promise.race([
|
||||||
|
exitPromise,
|
||||||
|
sleep(250),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
export async function openPageSession(options: OpenPageSessionOptions): Promise<PageSession> {
|
export async function openPageSession(options: OpenPageSessionOptions): Promise<PageSession> {
|
||||||
let targetId: string;
|
let targetId: string;
|
||||||
let createdTarget = false;
|
let createdTarget = false;
|
||||||
|
|||||||
@@ -478,7 +478,7 @@ export function killChrome(chrome: ChildProcess): void {
|
|||||||
chrome.kill("SIGTERM");
|
chrome.kill("SIGTERM");
|
||||||
} catch {}
|
} catch {}
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
if (!chrome.killed) {
|
if (chrome.exitCode === null && chrome.signalCode === null) {
|
||||||
try {
|
try {
|
||||||
chrome.kill("SIGKILL");
|
chrome.kill("SIGKILL");
|
||||||
} catch {}
|
} catch {}
|
||||||
@@ -486,6 +486,37 @@ export function killChrome(chrome: ChildProcess): void {
|
|||||||
}, 2_000).unref?.();
|
}, 2_000).unref?.();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function gracefulKillChrome(
|
||||||
|
chrome: ChildProcess,
|
||||||
|
port?: number,
|
||||||
|
timeoutMs = 6_000,
|
||||||
|
): Promise<void> {
|
||||||
|
if (chrome.exitCode !== null || chrome.signalCode !== null) return;
|
||||||
|
|
||||||
|
const exitPromise = new Promise<void>((resolve) => {
|
||||||
|
chrome.once("exit", () => resolve());
|
||||||
|
});
|
||||||
|
|
||||||
|
killChrome(chrome);
|
||||||
|
|
||||||
|
const start = Date.now();
|
||||||
|
while (Date.now() - start < timeoutMs) {
|
||||||
|
if (chrome.exitCode !== null || chrome.signalCode !== null) return;
|
||||||
|
if (port !== undefined && !await isPortListening(port, 250)) return;
|
||||||
|
|
||||||
|
const exited = await Promise.race([
|
||||||
|
exitPromise.then(() => true),
|
||||||
|
sleep(100).then(() => false),
|
||||||
|
]);
|
||||||
|
if (exited) return;
|
||||||
|
}
|
||||||
|
|
||||||
|
await Promise.race([
|
||||||
|
exitPromise,
|
||||||
|
sleep(250),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
export async function openPageSession(options: OpenPageSessionOptions): Promise<PageSession> {
|
export async function openPageSession(options: OpenPageSessionOptions): Promise<PageSession> {
|
||||||
let targetId: string;
|
let targetId: string;
|
||||||
let createdTarget = false;
|
let createdTarget = false;
|
||||||
|
|||||||
@@ -478,7 +478,7 @@ export function killChrome(chrome: ChildProcess): void {
|
|||||||
chrome.kill("SIGTERM");
|
chrome.kill("SIGTERM");
|
||||||
} catch {}
|
} catch {}
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
if (!chrome.killed) {
|
if (chrome.exitCode === null && chrome.signalCode === null) {
|
||||||
try {
|
try {
|
||||||
chrome.kill("SIGKILL");
|
chrome.kill("SIGKILL");
|
||||||
} catch {}
|
} catch {}
|
||||||
@@ -486,6 +486,37 @@ export function killChrome(chrome: ChildProcess): void {
|
|||||||
}, 2_000).unref?.();
|
}, 2_000).unref?.();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function gracefulKillChrome(
|
||||||
|
chrome: ChildProcess,
|
||||||
|
port?: number,
|
||||||
|
timeoutMs = 6_000,
|
||||||
|
): Promise<void> {
|
||||||
|
if (chrome.exitCode !== null || chrome.signalCode !== null) return;
|
||||||
|
|
||||||
|
const exitPromise = new Promise<void>((resolve) => {
|
||||||
|
chrome.once("exit", () => resolve());
|
||||||
|
});
|
||||||
|
|
||||||
|
killChrome(chrome);
|
||||||
|
|
||||||
|
const start = Date.now();
|
||||||
|
while (Date.now() - start < timeoutMs) {
|
||||||
|
if (chrome.exitCode !== null || chrome.signalCode !== null) return;
|
||||||
|
if (port !== undefined && !await isPortListening(port, 250)) return;
|
||||||
|
|
||||||
|
const exited = await Promise.race([
|
||||||
|
exitPromise.then(() => true),
|
||||||
|
sleep(100).then(() => false),
|
||||||
|
]);
|
||||||
|
if (exited) return;
|
||||||
|
}
|
||||||
|
|
||||||
|
await Promise.race([
|
||||||
|
exitPromise,
|
||||||
|
sleep(250),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
export async function openPageSession(options: OpenPageSessionOptions): Promise<PageSession> {
|
export async function openPageSession(options: OpenPageSessionOptions): Promise<PageSession> {
|
||||||
let targetId: string;
|
let targetId: string;
|
||||||
let createdTarget = false;
|
let createdTarget = false;
|
||||||
|
|||||||
+16
@@ -399,6 +399,22 @@ export async function runConvertCommand(options: ConvertCommandOptions): Promise
|
|||||||
if (restored) logger.info(`Restored ${adapter.name} session cookies from sidecar.`);
|
if (restored) logger.info(`Restored ${adapter.name} session cookies from sidecar.`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (options.waitMode === "interaction" && adapter.checkLogin) {
|
||||||
|
await context.browser.goto(url.toString(), options.timeoutMs).catch(() => {});
|
||||||
|
const preLogin = await adapter.checkLogin(context);
|
||||||
|
if (preLogin.state !== "logged_in") {
|
||||||
|
didLogin = true;
|
||||||
|
await waitForInteraction(adapter, context, {
|
||||||
|
type: "wait_for_interaction",
|
||||||
|
kind: "login",
|
||||||
|
provider: preLogin.provider ?? adapter.name,
|
||||||
|
prompt: `Please sign in to ${adapter.name === "x" ? "X" : adapter.name} in the opened Chrome window. Extraction will continue automatically once login is detected.`,
|
||||||
|
reason: preLogin.reason ?? `Not logged in to ${adapter.name}`,
|
||||||
|
requiresVisibleBrowser: true,
|
||||||
|
}, options);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (options.waitMode === "force") {
|
if (options.waitMode === "force") {
|
||||||
await context.browser.goto(url.toString(), options.timeoutMs).catch(() => {});
|
await context.browser.goto(url.toString(), options.timeoutMs).catch(() => {});
|
||||||
await waitForForceResume(adapter, context, options);
|
await waitForForceResume(adapter, context, options);
|
||||||
|
|||||||
Reference in New Issue
Block a user