safari-mcp 2.5.0 → 2.5.1
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.
- package/extension/background.js +31 -1
- package/package.json +1 -1
package/extension/background.js
CHANGED
|
@@ -405,7 +405,7 @@ async function handleCommand(type, payload) {
|
|
|
405
405
|
|
|
406
406
|
// --- Click & Input ---
|
|
407
407
|
case "click": {
|
|
408
|
-
|
|
408
|
+
const result = await execInTab((selector, text, x, y, ref) => {
|
|
409
409
|
// Use shared deep query (defined by ensureHelpers / _deepQueryScript)
|
|
410
410
|
const dq = window.__mcpDeepQuery || document.querySelector.bind(document);
|
|
411
411
|
|
|
@@ -633,6 +633,36 @@ async function handleCommand(type, payload) {
|
|
|
633
633
|
|
|
634
634
|
return "Clicked: " + el.tagName + (el.textContent ? ' "' + el.textContent.trim().substring(0, 50) + '"' : "");
|
|
635
635
|
}, [payload.selector, payload.text, payload.x, payload.y, payload.ref], tabId);
|
|
636
|
+
|
|
637
|
+
// Fallback: if element not found in main frame, try all frames (cross-origin iframes)
|
|
638
|
+
if (result && (result.startsWith("Element not found") || result === "No click target")) {
|
|
639
|
+
const iframeResult = await execInAllFrames((selector, text) => {
|
|
640
|
+
let el = null;
|
|
641
|
+
if (selector) {
|
|
642
|
+
el = document.querySelector(selector);
|
|
643
|
+
} else if (text) {
|
|
644
|
+
// Search interactive elements by text
|
|
645
|
+
const candidates = document.querySelectorAll("button, a, [role='button'], input[type='submit']");
|
|
646
|
+
for (let i = 0; i < candidates.length; i++) {
|
|
647
|
+
const t = (candidates[i].innerText || candidates[i].textContent || "").trim();
|
|
648
|
+
if (t === text) { el = candidates[i]; break; }
|
|
649
|
+
}
|
|
650
|
+
// Fuzzy: contains match
|
|
651
|
+
if (!el) {
|
|
652
|
+
for (let i = 0; i < candidates.length; i++) {
|
|
653
|
+
const t = (candidates[i].innerText || candidates[i].textContent || "").trim();
|
|
654
|
+
if (t.includes(text) || text.includes(t)) { el = candidates[i]; break; }
|
|
655
|
+
}
|
|
656
|
+
}
|
|
657
|
+
}
|
|
658
|
+
if (!el) return null;
|
|
659
|
+
el.scrollIntoView({ block: "center", behavior: "instant" });
|
|
660
|
+
el.click();
|
|
661
|
+
return "Clicked (iframe): " + el.tagName + (el.textContent ? ' "' + el.textContent.trim().substring(0, 50) + '"' : "");
|
|
662
|
+
}, [payload.selector, payload.text], tabId);
|
|
663
|
+
if (iframeResult) return iframeResult;
|
|
664
|
+
}
|
|
665
|
+
return result;
|
|
636
666
|
}
|
|
637
667
|
|
|
638
668
|
// --- Click + Read (combo — saves 1 full MCP round-trip) ---
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "safari-mcp",
|
|
3
|
-
"version": "2.5.
|
|
3
|
+
"version": "2.5.1",
|
|
4
4
|
"mcpName": "io.github.achiya-automation/safari-mcp",
|
|
5
5
|
"description": "Safari browser automation for AI agents — native macOS, zero Chrome overhead. 80 tools via AppleScript + JavaScript.",
|
|
6
6
|
"type": "module",
|