chromeflow 0.1.17 → 0.1.18

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -77,17 +77,26 @@ Use these exact x/y values in highlight_region.` }]
77
77
  `Execute JavaScript in the current page's context and return the result as a string.
78
78
  Use this to read framework state, check DOM properties, or interact with page APIs that aren't reachable via text.
79
79
  Prefer get_page_text for reading visible content. Use this for programmatic DOM queries (e.g. checking an element's attribute, reading a value not visible in text).
80
+ Top-level return statements are supported (e.g. multi-statement scripts with \`return value;\`).
81
+ If the page called alert()/confirm()/prompt() since the last check, the message will appear as PAGE ALERT in the result \u2014 read it and act on it.
80
82
  NOTE: Pages with strict Content Security Policy (e.g. Stripe, GitHub) will block eval and return a CSP error \u2014 do not retry, use get_page_text or fill_input instead.`,
81
83
  {
82
84
  code: z.string().describe(
83
- `JavaScript expression to evaluate in the page (e.g. 'document.title', 'document.querySelector(".price")?.textContent')`
85
+ "JavaScript expression or multi-statement script to evaluate in the page. Top-level `return` is supported."
84
86
  )
85
87
  },
86
88
  async ({ code }) => {
87
89
  const response = await bridge.request({ type: "execute_script", code });
88
90
  if (response.type !== "script_response") throw new Error("Unexpected response");
91
+ const { result, alert } = response;
92
+ let text = `Result: ${result}`;
93
+ if (alert) {
94
+ text += `
95
+
96
+ PAGE ALERT: "${alert}" \u2014 the page showed a dialog with this message. Read it and act on it before proceeding (e.g. fill a missing field, uncheck a checkbox).`;
97
+ }
89
98
  return {
90
- content: [{ type: "text", text: `Result: ${response.result}` }]
99
+ content: [{ type: "text", text }]
91
100
  };
92
101
  }
93
102
  );
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "chromeflow",
3
- "version": "0.1.17",
3
+ "version": "0.1.18",
4
4
  "description": "Browser guidance MCP server for Claude Code — highlights, clicks, fills, and captures from the web so you don't have to.",
5
5
  "type": "module",
6
6
  "bin": {