feat: 初步支持 Gemini 网页版

This commit is contained in:
foxhui
2025-12-12 23:45:19 +08:00
Unverified
parent a0b0936c46
commit dffb209dac
8 changed files with 214 additions and 6 deletions
+9 -3
View File
@@ -131,9 +131,9 @@ export function getHumanClickPoint(box, type = 'random') {
/**
* 安全点击元素 (包含拟人化移动和点击)
* 支持 CSS selectorElementHandle 种输入
* 支持 CSS selectorElementHandle 和 Locator 三种输入
* @param {import('playwright-core').Page} page - Playwright 页面对象
* @param {string|import('playwright-core').ElementHandle} target - CSS 选择器元素句柄
* @param {string|import('playwright-core').ElementHandle|import('playwright-core').Locator} target - CSS 选择器元素句柄或 Locator
* @param {object} [options] - 点击选项
* @param {string} [options.bias='random'] - 偏移偏好: 'input' 或 'random'
* @returns {Promise<void>}
@@ -142,11 +142,17 @@ export async function safeClick(page, target, options = {}) {
try {
let el;
// 判断是 selector 还是 ElementHandle
// 判断输入类型
if (typeof target === 'string') {
// CSS selector
el = await page.$(target);
if (!el) throw new Error(`未找到: ${target}`);
} else if (typeof target.elementHandle === 'function') {
// Locator (来自 page.getByRole, page.getByText 等)
el = await target.elementHandle();
if (!el) throw new Error(`Locator 未匹配到元素`);
} else {
// ElementHandle
el = target;
if (!el || !el.asElement()) throw new Error(`Element handle invalid`);
}