pi-chrome 0.10.0 → 0.10.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.
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"manifest_version": 3,
|
|
3
3
|
"name": "Pi Existing Chrome Profile Bridge",
|
|
4
|
-
"version": "0.10.
|
|
4
|
+
"version": "0.10.1",
|
|
5
5
|
"description": "Lets Pi control tabs in this existing Chrome profile via a local bridge at 127.0.0.1.",
|
|
6
6
|
"permissions": ["tabs", "scripting", "storage", "activeTab", "alarms", "webNavigation", "debugger"],
|
|
7
7
|
"host_permissions": ["<all_urls>", "http://127.0.0.1:17318/*"],
|
|
@@ -236,18 +236,36 @@ async function trustedKey(params) {
|
|
|
236
236
|
await attachDebugger(tab.id);
|
|
237
237
|
const key = String(params.key || "");
|
|
238
238
|
if (!key) throw new Error("trusted.key: missing key");
|
|
239
|
+
const mods = params.modifiers || {};
|
|
240
|
+
const modBits = cdpModifiersFor(mods);
|
|
241
|
+
// Press modifiers in standard order, then key, then release in reverse.
|
|
242
|
+
const modOrder = [];
|
|
243
|
+
if (mods.metaKey) modOrder.push({ key: "Meta", code: "MetaLeft", vk: 91 });
|
|
244
|
+
if (mods.ctrlKey) modOrder.push({ key: "Control", code: "ControlLeft", vk: 17 });
|
|
245
|
+
if (mods.altKey) modOrder.push({ key: "Alt", code: "AltLeft", vk: 18 });
|
|
246
|
+
if (mods.shiftKey) modOrder.push({ key: "Shift", code: "ShiftLeft", vk: 16 });
|
|
247
|
+
for (const m of modOrder) {
|
|
248
|
+
await cdp(tab.id, "Input.dispatchKeyEvent", { type: "keyDown", key: m.key, code: m.code, windowsVirtualKeyCode: m.vk, modifiers: modBits });
|
|
249
|
+
await sleep(rng(6, 18));
|
|
250
|
+
}
|
|
239
251
|
const info = cdpKeyInfo(key);
|
|
252
|
+
// When modifiers are active, browsers usually emit "rawKeyDown" (no text) so chords like Cmd+V don't insert the literal char.
|
|
253
|
+
const downType = modBits ? "rawKeyDown" : "keyDown";
|
|
240
254
|
await cdp(tab.id, "Input.dispatchKeyEvent", {
|
|
241
|
-
type:
|
|
255
|
+
type: downType, key: info.key, code: info.code,
|
|
242
256
|
windowsVirtualKeyCode: info.windowsVirtualKeyCode, nativeVirtualKeyCode: info.windowsVirtualKeyCode,
|
|
243
|
-
text: info.text, unmodifiedText: info.text,
|
|
257
|
+
text: modBits ? "" : info.text, unmodifiedText: modBits ? "" : info.text, modifiers: modBits,
|
|
244
258
|
});
|
|
245
259
|
await sleep(rng(25, 90));
|
|
246
260
|
await cdp(tab.id, "Input.dispatchKeyEvent", {
|
|
247
261
|
type: "keyUp", key: info.key, code: info.code,
|
|
248
|
-
windowsVirtualKeyCode: info.windowsVirtualKeyCode,
|
|
262
|
+
windowsVirtualKeyCode: info.windowsVirtualKeyCode, modifiers: modBits,
|
|
249
263
|
});
|
|
250
|
-
|
|
264
|
+
for (const m of modOrder.reverse()) {
|
|
265
|
+
await sleep(rng(5, 18));
|
|
266
|
+
await cdp(tab.id, "Input.dispatchKeyEvent", { type: "keyUp", key: m.key, code: m.code, windowsVirtualKeyCode: m.vk, modifiers: 0 });
|
|
267
|
+
}
|
|
268
|
+
return { trusted: true, key: info.key, modifiers: mods };
|
|
251
269
|
}
|
|
252
270
|
|
|
253
271
|
async function trustedType(params) {
|
|
@@ -882,6 +882,12 @@ Usage rules:
|
|
|
882
882
|
promptSnippet: "Press keys in Chrome through the companion extension.",
|
|
883
883
|
parameters: Type.Object({
|
|
884
884
|
key: Type.String(),
|
|
885
|
+
modifiers: Type.Optional(Type.Object({
|
|
886
|
+
shiftKey: Type.Optional(Type.Boolean()),
|
|
887
|
+
ctrlKey: Type.Optional(Type.Boolean()),
|
|
888
|
+
altKey: Type.Optional(Type.Boolean()),
|
|
889
|
+
metaKey: Type.Optional(Type.Boolean()),
|
|
890
|
+
}, { description: "Modifier keys to hold while pressing the key (chord). Only honoured for trusted-mode presses; synthetic path ignores." })),
|
|
885
891
|
includeSnapshot: Type.Optional(Type.Boolean({ description: "If true, include a fresh chrome_snapshot result after the keypress." })),
|
|
886
892
|
maxElements: Type.Optional(Type.Number({ default: MAX_ELEMENTS, description: "Max elements in the included snapshot." })),
|
|
887
893
|
targetId: Type.Optional(Type.String()),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-chrome",
|
|
3
|
-
"version": "0.10.
|
|
3
|
+
"version": "0.10.1",
|
|
4
4
|
"description": "Drive your existing logged-in Chrome from Pi — no re-login, no throwaway profile, watch the agent work in real time (or toggle quiet background mode).",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"pi-package",
|