2026-04-24 09:39:03 +08:00
|
|
|
export interface CDPTargetDescriptor {
|
2026-05-01 20:39:09 +08:00
|
|
|
id?: string
|
|
|
|
|
type?: string
|
|
|
|
|
title?: string
|
|
|
|
|
url?: string
|
2026-04-24 09:39:03 +08:00
|
|
|
}
|
|
|
|
|
|
2026-05-01 20:39:09 +08:00
|
|
|
const hiddenPlaywrightTargetMarkers = ['hidden-playwright', 'geo-hidden-playwright-token'] as const
|
2026-04-24 09:39:03 +08:00
|
|
|
|
|
|
|
|
export function isReclaimableHiddenPlaywrightTarget(target: CDPTargetDescriptor): boolean {
|
2026-05-01 20:39:09 +08:00
|
|
|
if ((target.type ?? '').trim() !== 'page') {
|
|
|
|
|
return false
|
2026-04-24 09:39:03 +08:00
|
|
|
}
|
2026-05-01 20:39:09 +08:00
|
|
|
if (!(target.id ?? '').trim()) {
|
|
|
|
|
return false
|
2026-04-24 09:39:03 +08:00
|
|
|
}
|
|
|
|
|
|
2026-05-01 20:39:09 +08:00
|
|
|
const title = target.title ?? ''
|
|
|
|
|
const url = target.url ?? ''
|
|
|
|
|
const haystack = `${title}\n${url}`.toLowerCase()
|
2026-04-24 09:39:03 +08:00
|
|
|
|
|
|
|
|
// Blank Electron page targets can belong to visible BrowserWindow shells.
|
|
|
|
|
// Only reclaim targets that we can prove were created by the hidden
|
|
|
|
|
// Playwright bootstrap flow.
|
2026-05-01 20:39:09 +08:00
|
|
|
return hiddenPlaywrightTargetMarkers.some((marker) => haystack.includes(marker))
|
2026-04-24 09:39:03 +08:00
|
|
|
}
|