browser_handle_dialog
Answers JavaScript alert, confirm, prompt, or 'Leave site?' dialogs on the active tab, or arms automatic handling for the next dialog before a click opens it.
Instructions
Answer a JavaScript alert/confirm/prompt or "Leave site?" on the active tab. If a dialog this extension saw open is on screen and nobody is answering it, it is answered now, and the reply says what Chrome reports happened (action accept or dismiss). Otherwise this arms automatic handling of the next dialog on the tab and returns immediately - call it BEFORE the click that opens the dialog, because a dialog freezes the tab. Pass wait=true only when the dialog is already opening. An armed accept never answers "Leave site?" unless leave_page is true; the arming lasts at most 30 s. A "Leave site?" that is already open is accepted only with leave_page: true too (error leave-page-required). An extension older than 1.33.0 (its store update can lag a release) does not enforce leave_page when accepting dialogs, so the server does not send it an accept without leave_page: true (error extension-too-old-for-leave-page); an arming it is sent is capped at 30 s but survives a page or tab change. Errors: dialog-being-answered (browser_navigate or an earlier call is answering it - wait), dialog-unconfirmed (answered, but Chrome did not confirm it closed), tab-not-responding (a dialog that opened before anything listened, or a busy page; the note says what to do), page-changed (the page changed while arming; nothing was armed), session-changed (the session switched tabs while arming). With extension 1.33.0 or newer, an arming is dropped when a new document loads or becomes active in the tab (a reload or a prerendered page too; not an address change within the page) or the session moves to another tab.
Tool call template
This tool declares no required parameters. Add optional parameters from the input schema as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {},
"name": "browser_handle_dialog"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| text | No | Text to enter for prompt() dialogs | |
| wait | No | Block until a dialog appears instead of arming and returning (default: false). Only use when the dialog is already on its way. | |
| action | No | Accept or dismiss the dialog (default: accept) | |
| timeout | No | How long the arming stays active in ms (default and at most 30000) | |
| partition | No | Run this call in a partition from browser_partition (an id like "p1"). Leave it out for the default partition. An unknown or closed id is an error; the call is never sent to the default partition instead. | |
| leave_page | No | With action accept: also accept a "Leave site?" (beforeunload), which leaves the page and loses anything unsaved on it. Default false: an armed accept answers alerts, confirms and prompts only. Ask the user first. |