feat: 添加 Cookie 获取功能

This commit is contained in:
foxhui
2025-12-12 00:15:28 +08:00
Unverified
parent 02e6cf0142
commit 2b7d298753
4 changed files with 99 additions and 2 deletions
+11
View File
@@ -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();
}