mirror of
https://github.com/foxhui/WebAI2API.git
synced 2026-06-16 21:03:59 +08:00
feat: 添加 Cookie 获取功能
This commit is contained in:
@@ -434,3 +434,14 @@ export function createPageCloseWatcher(page) {
|
||||
|
||||
return { promise, cleanup };
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前页面的所有 Cookies (实时从浏览器获取)
|
||||
* @param {import('playwright-core').Page} page - Playwright 页面实例
|
||||
* @returns {Promise<object[]>} Cookies 数组 (JSON 格式)
|
||||
*/
|
||||
export async function getCookies(page) {
|
||||
const context = page.context();
|
||||
return await context.cookies();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user