Skip to content

Commit 78127e2

Browse files
committed
Add initScript capability
1 parent c42d81a commit 78127e2

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
@@ -116,6 +116,9 @@ export const navigatePage = defineTool({
116116
.boolean()
117117
.optional()
118118
.describe('Whether to ignore cache on reload.'),
119+
initScript: zod.string().optional().describe(
120+
`(optional) A JavaScript function declaration to be executed by the tool on new document for every page load.
121+
`),
119122
...timeoutSchema,
120123
},
121124
handler: async (request, response, context) => {
@@ -132,6 +135,10 @@ export const navigatePage = defineTool({
132135
request.params.type = 'url';
133136
}
134137

138+
if(request.params.initScript){
139+
page.evaluateOnNewDocument(request.params.initScript);
140+
}
141+
135142
await context.waitForEventsAfterAction(async () => {
136143
switch (request.params.type) {
137144
case 'url':

0 commit comments

Comments
 (0)