MCPcopy Index your code
hub / github.com/scriptscat/scriptcat / autoApprovePermissions

Function autoApprovePermissions

e2e/utils.ts:17–37  ·  view source on GitHub ↗
(context: BrowserContext)

Source from the content-addressed store, hash-verified

15 * "permanent allow all" button (type=4, allow=true).
16 */
17export function autoApprovePermissions(context: BrowserContext): void {
18 context.on("page", async (page) => {
19 const url = page.url();
20 if (!url.includes("confirm.html")) return;
21
22 try {
23 await page.waitForLoadState("domcontentloaded");
24 const successButtons = page.locator("button.arco-btn-status-success");
25 await successButtons.first().waitFor({ timeout: 5_000 });
26 const count = await successButtons.count();
27 if (count >= 3) {
28 await successButtons.nth(2).click();
29 } else {
30 await successButtons.last().click();
31 }
32 console.log("[autoApprove] Permission approved on confirm page");
33 } catch (e) {
34 console.log("[autoApprove] Failed to approve:", e);
35 }
36 });
37}
38
39/** Run a test script from example/tests/ on the target page and collect console results */
40export async function runTestScript(

Callers 1

runInlineTestScriptFunction · 0.70

Calls 5

countMethod · 0.80
logMethod · 0.80
waitForMethod · 0.65
clickMethod · 0.65
onMethod · 0.45

Tested by

no test coverage detected