@web-auto/camo 0.1.20 → 0.1.21
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/package.json +1 -1
- package/src/commands/browser.mjs +5 -22
package/package.json
CHANGED
package/src/commands/browser.mjs
CHANGED
|
@@ -1081,7 +1081,6 @@ export async function handleTypeCommand(args) {
|
|
|
1081
1081
|
|
|
1082
1082
|
export async function handleHighlightCommand(args) {
|
|
1083
1083
|
await ensureBrowserService();
|
|
1084
|
-
ensureJsExecutionEnabled('highlight command');
|
|
1085
1084
|
const positionals = getPositionals(args);
|
|
1086
1085
|
let profileId;
|
|
1087
1086
|
let selector;
|
|
@@ -1097,38 +1096,22 @@ export async function handleHighlightCommand(args) {
|
|
|
1097
1096
|
if (!profileId) throw new Error('Usage: camo highlight [profileId] <selector>');
|
|
1098
1097
|
if (!selector) throw new Error('Usage: camo highlight [profileId] <selector>');
|
|
1099
1098
|
|
|
1100
|
-
const result = await callAPI('
|
|
1099
|
+
const result = await callAPI('browser:highlight', {
|
|
1100
|
+
profile: profileId,
|
|
1101
1101
|
profileId,
|
|
1102
|
-
|
|
1103
|
-
const el = document.querySelector(${JSON.stringify(selector)});
|
|
1104
|
-
if (!el) throw new Error('Element not found: ' + ${JSON.stringify(selector)});
|
|
1105
|
-
const prev = el.style.outline;
|
|
1106
|
-
el.style.outline = '3px solid #ff4444';
|
|
1107
|
-
setTimeout(() => { el.style.outline = prev; }, 2000);
|
|
1108
|
-
const rect = el.getBoundingClientRect();
|
|
1109
|
-
return { highlighted: true, selector: ${JSON.stringify(selector)}, rect: { x: rect.x, y: rect.y, width: rect.width, height: rect.height } };
|
|
1110
|
-
})()`
|
|
1102
|
+
selector,
|
|
1111
1103
|
});
|
|
1112
1104
|
console.log(JSON.stringify(result, null, 2));
|
|
1113
1105
|
}
|
|
1114
1106
|
|
|
1115
1107
|
export async function handleClearHighlightCommand(args) {
|
|
1116
1108
|
await ensureBrowserService();
|
|
1117
|
-
ensureJsExecutionEnabled('clear-highlight command');
|
|
1118
1109
|
const profileId = resolveProfileId(args, 1, getDefaultProfile);
|
|
1119
1110
|
if (!profileId) throw new Error('Usage: camo clear-highlight [profileId]');
|
|
1120
1111
|
|
|
1121
|
-
const result = await callAPI('
|
|
1112
|
+
const result = await callAPI('browser:clear-highlight', {
|
|
1113
|
+
profile: profileId,
|
|
1122
1114
|
profileId,
|
|
1123
|
-
script: `(() => {
|
|
1124
|
-
const overlay = document.getElementById('camo-highlight-overlay');
|
|
1125
|
-
if (overlay) overlay.remove();
|
|
1126
|
-
document.querySelectorAll('[data-camo-highlight]').forEach(el => {
|
|
1127
|
-
el.style.outline = el.dataset.camoHighlight || '';
|
|
1128
|
-
delete el.dataset.camoHighlight;
|
|
1129
|
-
});
|
|
1130
|
-
return { cleared: true };
|
|
1131
|
-
})()`
|
|
1132
1115
|
});
|
|
1133
1116
|
console.log(JSON.stringify(result, null, 2));
|
|
1134
1117
|
}
|