Skip to content

Commit effbe56

Browse files
gernbergOrKoN
authored andcommitted
Add initScript capability
1 parent 7e279f1 commit effbe56

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

src/tools/pages.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,9 @@ export const navigatePage = defineTool({
133133
.describe(
134134
'Whether to auto accept or beforeunload dialogs triggered by this navigation. Default is accept.',
135135
),
136+
initScript: zod.string().optional().describe(
137+
`(optional) A JavaScript function declaration to be executed by the tool on new document for every page load.
138+
`),
136139
...timeoutSchema,
137140
},
138141
handler: async (request, response, context) => {
@@ -163,6 +166,10 @@ export const navigatePage = defineTool({
163166
context.clearDialog();
164167
}
165168
};
169+
170+
if (request.params.initScript) {
171+
await page.evaluateOnNewDocument(request.params.initScript);
172+
}
166173
page.on('dialog', dialogHandler);
167174

168175
try {

0 commit comments

Comments
 (0)