safari-mcp 2.5.1 → 2.5.2
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 +27 -1
- package/package.json +1 -1
package/extension/background.js
CHANGED
|
@@ -850,7 +850,7 @@ async function handleCommand(type, payload) {
|
|
|
850
850
|
}
|
|
851
851
|
|
|
852
852
|
case "type_text": {
|
|
853
|
-
|
|
853
|
+
const result = await execInTab((text, selector) => {
|
|
854
854
|
if (selector) { const el = (window.__mcpDeepQuery || document.querySelector.bind(document))(selector); if (el) el.focus(); }
|
|
855
855
|
|
|
856
856
|
// === Strategy 1: ProseMirror native API ===
|
|
@@ -943,6 +943,32 @@ async function handleCommand(type, payload) {
|
|
|
943
943
|
}
|
|
944
944
|
return "Typed " + text.length + " chars";
|
|
945
945
|
}, [payload.text, payload.selector], tabId);
|
|
946
|
+
|
|
947
|
+
// Fallback: if typing failed in main frame, try all frames (cross-origin iframes)
|
|
948
|
+
if (result === "Typed 0 chars" || !result) {
|
|
949
|
+
const iframeResult = await execInAllFrames((text) => {
|
|
950
|
+
const el = document.activeElement;
|
|
951
|
+
if (!el || el === document.body) return null;
|
|
952
|
+
// Try execCommand insert
|
|
953
|
+
const ok = document.execCommand("insertText", false, text);
|
|
954
|
+
if (ok) return "Typed " + text.length + " chars (iframe execCommand)";
|
|
955
|
+
// Fallback: contenteditable or input
|
|
956
|
+
if (el.isContentEditable) {
|
|
957
|
+
el.textContent = text;
|
|
958
|
+
el.dispatchEvent(new Event("input", { bubbles: true }));
|
|
959
|
+
return "Typed " + text.length + " chars (iframe contenteditable)";
|
|
960
|
+
}
|
|
961
|
+
if ("value" in el) {
|
|
962
|
+
el.value = text;
|
|
963
|
+
el.dispatchEvent(new Event("input", { bubbles: true }));
|
|
964
|
+
el.dispatchEvent(new Event("change", { bubbles: true }));
|
|
965
|
+
return "Typed " + text.length + " chars (iframe input)";
|
|
966
|
+
}
|
|
967
|
+
return null;
|
|
968
|
+
}, [payload.text], tabId);
|
|
969
|
+
if (iframeResult) return iframeResult;
|
|
970
|
+
}
|
|
971
|
+
return result;
|
|
946
972
|
}
|
|
947
973
|
|
|
948
974
|
case "press_key": {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "safari-mcp",
|
|
3
|
-
"version": "2.5.
|
|
3
|
+
"version": "2.5.2",
|
|
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",
|