mcp-browser-extension 0.9.30 → 0.9.32
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/README.md +77 -14
- package/SETUP.md +40 -7
- package/dist/shared/activity.d.ts +25 -0
- package/dist/shared/activity.js +72 -0
- package/dist/shared/browser-permissions.d.ts +20 -0
- package/dist/shared/browser-permissions.js +40 -0
- package/dist/shared/client-auth.d.ts +28 -0
- package/dist/shared/client-auth.js +38 -0
- package/dist/shared/observers.d.ts +1 -1
- package/dist/shared/observers.js +1 -3
- package/dist/shared/policy.d.ts +5 -7
- package/dist/shared/policy.js +11 -26
- package/dist/shared/protocol.d.ts +4 -0
- package/dist/shared/protocol.js +3 -3
- package/dist/shared/screenshot.d.ts +4 -2
- package/dist/shared/screenshot.js +13 -8
- package/dist/src/access-browser.d.ts +15 -0
- package/dist/src/access-browser.js +202 -0
- package/dist/src/access.d.ts +2 -0
- package/dist/src/access.js +92 -18
- package/dist/src/bridge/client-identity.d.ts +10 -0
- package/dist/src/bridge/client-identity.js +28 -0
- package/dist/src/bridge/connection.d.ts +5 -0
- package/dist/src/bridge/connection.js +4 -12
- package/dist/src/bridge/peer.d.ts +4 -19
- package/dist/src/bridge/peer.js +17 -8
- package/dist/src/bridge/server.d.ts +7 -16
- package/dist/src/bridge/server.js +64 -17
- package/dist/src/bridge/site-grants.d.ts +1 -2
- package/dist/src/bridge/site-grants.js +4 -3
- package/dist/src/cli.js +1 -3
- package/dist/src/config.js +16 -5
- package/dist/src/executor/cdp-executor.d.ts +3 -0
- package/dist/src/executor/cdp-executor.js +69 -25
- package/dist/src/mcp/server.js +5 -3
- package/dist/src/mcp/tools.d.ts +0 -12
- package/dist/src/mcp/tools.js +48 -22
- package/dist/src/remote/key.js +12 -2
- package/dist/src/security/policy.d.ts +4 -0
- package/dist/src/security/policy.js +3 -1
- package/docs/BLUEPRINT.md +6 -1
- package/docs/CLIENT-APPROVAL.md +150 -0
- package/extension-dist/activity-dashboard.css +43 -0
- package/extension-dist/background.js +1036 -73
- package/extension-dist/manifest.json +10 -9
- package/extension-dist/options.html +101 -32
- package/extension-dist/options.js +558 -70
- package/extension-dist/popup.html +164 -90
- package/extension-dist/popup.js +576 -79
- package/package.json +3 -2
package/extension-dist/popup.js
CHANGED
|
@@ -1,5 +1,416 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
(() => {
|
|
3
|
+
// shared/client-auth.ts
|
|
4
|
+
var CLIENT_GRANT_MS = 8 * 60 * 60 * 1e3;
|
|
5
|
+
var CLIENT_CLOCK_SKEW_MS = 2 * 60 * 1e3;
|
|
6
|
+
var CLIENT_REQUEST_MS = 10 * 60 * 1e3;
|
|
7
|
+
var CLIENT_STORAGE_KEY = "clientConnections";
|
|
8
|
+
|
|
9
|
+
// shared/protocol.ts
|
|
10
|
+
var STORE_EXTENSION_URL = "https://chromewebstore.google.com/detail/mcp-browser-extension/jelfhdlkhbfmlpbghoeaepijllcnplgh";
|
|
11
|
+
|
|
12
|
+
// shared/activity.ts
|
|
13
|
+
var ACCESS_STOPPED_KEY = "accessStopped";
|
|
14
|
+
var ACTIVITY_KEY = "recentActivity";
|
|
15
|
+
function activityRows(entries) {
|
|
16
|
+
const rows = [];
|
|
17
|
+
const opens = /* @__PURE__ */ new Map();
|
|
18
|
+
for (const entry of entries) {
|
|
19
|
+
const key = entry.tabId !== void 0 && entry.key ? `${entry.key}:${entry.tabId}` : "";
|
|
20
|
+
if (key && entry.method === "tab_new" && entry.outcome === "done") opens.set(key, entry);
|
|
21
|
+
const opened = key && entry.method === "tab_close" && entry.outcome === "done" ? opens.get(key) : void 0;
|
|
22
|
+
if (opened) {
|
|
23
|
+
const index = rows.findIndex((row2) => row2.id === opened.id);
|
|
24
|
+
if (index !== -1) rows.splice(index, 1);
|
|
25
|
+
rows.push({ ...entry, host: entry.host || opened.host, opened });
|
|
26
|
+
opens.delete(key);
|
|
27
|
+
} else rows.push(entry);
|
|
28
|
+
}
|
|
29
|
+
return rows;
|
|
30
|
+
}
|
|
31
|
+
var LABELS = {
|
|
32
|
+
tabs_list: "List tabs",
|
|
33
|
+
tab_select: "Select tab",
|
|
34
|
+
tab_new: "Open tab",
|
|
35
|
+
tab_close: "Close tab",
|
|
36
|
+
navigate: "Navigate",
|
|
37
|
+
back: "Go back",
|
|
38
|
+
forward: "Go forward",
|
|
39
|
+
reload: "Reload page",
|
|
40
|
+
click: "Click",
|
|
41
|
+
draw: "Draw",
|
|
42
|
+
type: "Type text",
|
|
43
|
+
press: "Press key",
|
|
44
|
+
hover: "Hover",
|
|
45
|
+
scroll: "Scroll",
|
|
46
|
+
screenshot: "Take screenshot",
|
|
47
|
+
get_text: "Read text",
|
|
48
|
+
get_html: "Read HTML",
|
|
49
|
+
eval: "Run page script",
|
|
50
|
+
snapshot: "Read page structure",
|
|
51
|
+
fill_form: "Fill form",
|
|
52
|
+
get_cookies: "Read cookies",
|
|
53
|
+
storage: "Access site storage",
|
|
54
|
+
download_file: "Download file",
|
|
55
|
+
upload_file: "Upload file",
|
|
56
|
+
print_pdf: "Print PDF",
|
|
57
|
+
select_option: "Choose option",
|
|
58
|
+
observers: "Read page observations",
|
|
59
|
+
proxy_status: "Check proxy",
|
|
60
|
+
frames: "List frames"
|
|
61
|
+
};
|
|
62
|
+
var activityLabel = (method) => LABELS[method] ?? method.replaceAll("_", " ");
|
|
63
|
+
|
|
64
|
+
// extension/src/ui-controls.ts
|
|
65
|
+
var lists = /* @__PURE__ */ new WeakMap();
|
|
66
|
+
var pending = /* @__PURE__ */ new Map();
|
|
67
|
+
var pressing = false;
|
|
68
|
+
var pressGeneration = 0;
|
|
69
|
+
document.addEventListener("pointerdown", () => {
|
|
70
|
+
pressing = true;
|
|
71
|
+
pressGeneration++;
|
|
72
|
+
}, true);
|
|
73
|
+
function release() {
|
|
74
|
+
const generation = pressGeneration;
|
|
75
|
+
setTimeout(() => {
|
|
76
|
+
if (generation !== pressGeneration) return;
|
|
77
|
+
pressing = false;
|
|
78
|
+
const updates = [...pending.values()];
|
|
79
|
+
pending.clear();
|
|
80
|
+
for (const update of updates) update();
|
|
81
|
+
}, 0);
|
|
82
|
+
}
|
|
83
|
+
window.addEventListener("pointerup", release, true);
|
|
84
|
+
window.addEventListener("pointercancel", release, true);
|
|
85
|
+
window.addEventListener("blur", release);
|
|
86
|
+
function renderList(list4, items, key, signature, create) {
|
|
87
|
+
if (pressing) {
|
|
88
|
+
pending.set(list4, () => renderList(list4, items, key, signature, create));
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
pending.delete(list4);
|
|
92
|
+
const previous = lists.get(list4) ?? /* @__PURE__ */ new Map();
|
|
93
|
+
const next = /* @__PURE__ */ new Map();
|
|
94
|
+
const scrollTop = list4.scrollTop;
|
|
95
|
+
let cursor = list4.firstElementChild;
|
|
96
|
+
for (const item of items) {
|
|
97
|
+
const id = key(item), version = signature(item), old = previous.get(id);
|
|
98
|
+
const element = old?.signature === version ? old.element : create(item);
|
|
99
|
+
if (old && element !== old.element) {
|
|
100
|
+
const details = element.querySelector("details");
|
|
101
|
+
if (details) details.open = old.element.querySelector("details")?.open ?? false;
|
|
102
|
+
if (old.element.parentElement === list4) {
|
|
103
|
+
if (cursor === old.element) cursor = element;
|
|
104
|
+
old.element.replaceWith(element);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
if (element === cursor) cursor = cursor.nextElementSibling;
|
|
108
|
+
else list4.insertBefore(element, cursor);
|
|
109
|
+
next.set(id, { signature: version, element });
|
|
110
|
+
}
|
|
111
|
+
const keep = new Set([...next.values()].map((row2) => row2.element));
|
|
112
|
+
for (const child of Array.from(list4.children)) if (!keep.has(child)) child.remove();
|
|
113
|
+
list4.scrollTop = scrollTop;
|
|
114
|
+
lists.set(list4, next);
|
|
115
|
+
}
|
|
116
|
+
async function busyButton(button2, operation) {
|
|
117
|
+
if (button2.disabled) return;
|
|
118
|
+
button2.disabled = true;
|
|
119
|
+
button2.setAttribute("aria-busy", "true");
|
|
120
|
+
try {
|
|
121
|
+
await operation();
|
|
122
|
+
} finally {
|
|
123
|
+
button2.disabled = false;
|
|
124
|
+
button2.removeAttribute("aria-busy");
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
// extension/src/client-connections.ts
|
|
129
|
+
var list = document.getElementById("client-connections");
|
|
130
|
+
var note = document.getElementById("client-note");
|
|
131
|
+
var count = document.getElementById("client-count");
|
|
132
|
+
function appName(reported) {
|
|
133
|
+
const name = reported.replace(/\s+v?\d+\.\d+\.\d+(?:-[\w.-]+)?(?:\+[\w.-]+)?$/, "");
|
|
134
|
+
return name === "codex-mcp-client" ? "Codex" : name;
|
|
135
|
+
}
|
|
136
|
+
function accessStatus(client, now) {
|
|
137
|
+
if (client.state === "revoked") return "Access removed";
|
|
138
|
+
if (client.expiresAt <= now) return "Access expired";
|
|
139
|
+
if (client.state === "pending") return "Waiting for your approval";
|
|
140
|
+
const minutes = Math.ceil((client.expiresAt - now) / 6e4);
|
|
141
|
+
const hours = Math.floor(minutes / 60);
|
|
142
|
+
const remaining = hours > 0 ? `${hours} ${hours === 1 ? "hour" : "hours"}` : `${minutes} ${minutes === 1 ? "minute" : "minutes"}`;
|
|
143
|
+
return `Access allowed \xB7 ${remaining} left`;
|
|
144
|
+
}
|
|
145
|
+
function action(label, id, allow) {
|
|
146
|
+
const button2 = document.createElement("button");
|
|
147
|
+
button2.textContent = label;
|
|
148
|
+
button2.addEventListener("click", async (event) => {
|
|
149
|
+
if (!event.isTrusted) return;
|
|
150
|
+
button2.disabled = true;
|
|
151
|
+
try {
|
|
152
|
+
const result = await chrome.runtime.sendMessage({ type: "client_decision", id, allow });
|
|
153
|
+
note.textContent = result?.ok ? "" : result?.error ?? "Could not save the decision.";
|
|
154
|
+
note.dataset.error = String(!result?.ok);
|
|
155
|
+
} catch {
|
|
156
|
+
note.textContent = "Could not reach the extension. Reopen this page and try again.";
|
|
157
|
+
note.dataset.error = "true";
|
|
158
|
+
} finally {
|
|
159
|
+
button2.disabled = false;
|
|
160
|
+
}
|
|
161
|
+
await render();
|
|
162
|
+
});
|
|
163
|
+
return button2;
|
|
164
|
+
}
|
|
165
|
+
var renderGeneration = 0;
|
|
166
|
+
async function render() {
|
|
167
|
+
const generation = ++renderGeneration;
|
|
168
|
+
const state = await chrome.storage.local.get([CLIENT_STORAGE_KEY, ACCESS_STOPPED_KEY]);
|
|
169
|
+
if (generation !== renderGeneration) return;
|
|
170
|
+
const saved = state[CLIENT_STORAGE_KEY];
|
|
171
|
+
const stopped = state[ACCESS_STOPPED_KEY] !== void 0 && state[ACCESS_STOPPED_KEY] !== false;
|
|
172
|
+
const clients = Array.isArray(saved) ? saved : [];
|
|
173
|
+
const now = Date.now();
|
|
174
|
+
const pending2 = (client) => client.state === "pending" && client.expiresAt > now;
|
|
175
|
+
const waiting = clients.filter(pending2).length;
|
|
176
|
+
for (const id of ["client-help", "client-limits"]) {
|
|
177
|
+
const hint = document.getElementById(id);
|
|
178
|
+
if (hint) hint.hidden = clients.length === 0 || id === "client-help" && document.body.dataset.view === "popup" && waiting === 0;
|
|
179
|
+
}
|
|
180
|
+
if (count) {
|
|
181
|
+
count.textContent = waiting ? `${waiting} waiting` : `${clients.length} ${clients.length === 1 ? "connection" : "connections"}`;
|
|
182
|
+
count.dataset.pending = String(waiting > 0);
|
|
183
|
+
}
|
|
184
|
+
const sorted = clients.slice().sort(
|
|
185
|
+
(a, b) => Number(pending2(b)) - Number(pending2(a)) || b.requestedAt - a.requestedAt
|
|
186
|
+
);
|
|
187
|
+
renderList(
|
|
188
|
+
list,
|
|
189
|
+
sorted,
|
|
190
|
+
(client) => client.id,
|
|
191
|
+
(client) => JSON.stringify([client.name, client.state, client.expiresAt, client.expiresAt <= now, stopped]),
|
|
192
|
+
(client) => {
|
|
193
|
+
const li = document.createElement("li");
|
|
194
|
+
li.dataset.clientId = client.id;
|
|
195
|
+
const name = document.createElement("strong");
|
|
196
|
+
name.textContent = appName(client.name);
|
|
197
|
+
const key = document.createElement("code");
|
|
198
|
+
key.textContent = `Key ${client.id.slice(0, 12)}`;
|
|
199
|
+
key.title = client.id;
|
|
200
|
+
const status = document.createElement("span");
|
|
201
|
+
status.className = "client-status";
|
|
202
|
+
const expired = client.expiresAt <= now;
|
|
203
|
+
li.dataset.state = client.state === "revoked" ? "revoked" : expired ? "expired" : client.state;
|
|
204
|
+
status.textContent = accessStatus(client, Date.now());
|
|
205
|
+
const info = document.createElement("div");
|
|
206
|
+
info.className = "client-info";
|
|
207
|
+
info.append(name, status);
|
|
208
|
+
const needsApproval = client.state === "revoked" || client.state === "pending" && !expired;
|
|
209
|
+
if (needsApproval) info.append(key);
|
|
210
|
+
const details = document.createElement("details");
|
|
211
|
+
details.className = "client-details";
|
|
212
|
+
const summary = document.createElement("summary");
|
|
213
|
+
summary.textContent = "Details";
|
|
214
|
+
details.append(summary);
|
|
215
|
+
for (const [field, text] of [
|
|
216
|
+
["app", `Reported app: ${client.name}`],
|
|
217
|
+
["requested", `Requested: ${new Date(client.requestedAt).toLocaleString()}`],
|
|
218
|
+
...client.state === "approved" ? [["expires", `Access ends: ${new Date(client.expiresAt).toLocaleString()}`]] : []
|
|
219
|
+
]) {
|
|
220
|
+
const line = document.createElement("p");
|
|
221
|
+
line.className = `client-${field}`;
|
|
222
|
+
line.textContent = text;
|
|
223
|
+
details.append(line);
|
|
224
|
+
}
|
|
225
|
+
if (!needsApproval) details.append(key);
|
|
226
|
+
const controls = document.createElement("div");
|
|
227
|
+
controls.className = "client-actions";
|
|
228
|
+
if (client.state === "revoked") controls.append(action("Approve again for 8 hours", client.id, true));
|
|
229
|
+
else if (client.state === "pending" && !expired) {
|
|
230
|
+
const approve = action("Approve for 8 hours", client.id, true);
|
|
231
|
+
approve.className = "primary";
|
|
232
|
+
controls.append(approve, action("Deny", client.id, false));
|
|
233
|
+
} else if (client.state === "approved" && !expired) controls.append(action("Remove access", client.id, false));
|
|
234
|
+
if (stopped) controls.querySelectorAll("button").forEach((button2) => {
|
|
235
|
+
button2.disabled = true;
|
|
236
|
+
});
|
|
237
|
+
li.append(info, controls, details);
|
|
238
|
+
return li;
|
|
239
|
+
}
|
|
240
|
+
);
|
|
241
|
+
const byId = new Map(clients.map((client) => [client.id, client]));
|
|
242
|
+
for (const row2 of Array.from(list.querySelectorAll("[data-client-id]"))) {
|
|
243
|
+
const client = byId.get(row2.dataset.clientId);
|
|
244
|
+
const status = row2.querySelector(".client-status");
|
|
245
|
+
if (client && status) {
|
|
246
|
+
const label = accessStatus(client, now);
|
|
247
|
+
if (status.textContent !== label) status.textContent = label;
|
|
248
|
+
const requested = row2.querySelector(".client-requested");
|
|
249
|
+
const requestTime = `Requested: ${new Date(client.requestedAt).toLocaleString()}`;
|
|
250
|
+
if (requested && requested.textContent !== requestTime) requested.textContent = requestTime;
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
if (clients.length && note.textContent?.startsWith("No requests yet.")) note.textContent = "";
|
|
254
|
+
if (!clients.length) note.textContent = "No requests yet. Ask your app to use Chrome. Its request will appear here.";
|
|
255
|
+
if (stopped) note.textContent = "Resume connection above to approve apps.";
|
|
256
|
+
else if (note.textContent === "Resume connection above to approve apps.") note.textContent = "";
|
|
257
|
+
}
|
|
258
|
+
chrome.storage.onChanged.addListener((changes, area) => {
|
|
259
|
+
if (area === "local" && (changes[CLIENT_STORAGE_KEY] || changes[ACCESS_STOPPED_KEY])) void render();
|
|
260
|
+
});
|
|
261
|
+
void render();
|
|
262
|
+
setInterval(() => void render(), 3e4);
|
|
263
|
+
|
|
264
|
+
// extension/src/popup/access-lists.ts
|
|
265
|
+
for (const list4 of Array.from(document.querySelectorAll(".access-list"))) {
|
|
266
|
+
let measure2 = function() {
|
|
267
|
+
frame = 0;
|
|
268
|
+
const items = Array.from(list4.children);
|
|
269
|
+
if (items.length <= visibleCount) {
|
|
270
|
+
delete list4.dataset.overflow;
|
|
271
|
+
list4.style.removeProperty("--list-height");
|
|
272
|
+
list4.removeAttribute("tabindex");
|
|
273
|
+
return;
|
|
274
|
+
}
|
|
275
|
+
list4.dataset.overflow = "true";
|
|
276
|
+
list4.tabIndex = 0;
|
|
277
|
+
const height = items[visibleCount - 1].getBoundingClientRect().bottom - items[0].getBoundingClientRect().top;
|
|
278
|
+
if (height > 0) list4.style.setProperty("--list-height", `${height}px`);
|
|
279
|
+
}, schedule2 = function() {
|
|
280
|
+
if (!frame) frame = requestAnimationFrame(measure2);
|
|
281
|
+
}, observeEntries2 = function() {
|
|
282
|
+
sizes.disconnect();
|
|
283
|
+
for (const item of Array.from(list4.children).slice(0, visibleCount)) sizes.observe(item);
|
|
284
|
+
schedule2();
|
|
285
|
+
};
|
|
286
|
+
measure = measure2, schedule = schedule2, observeEntries = observeEntries2;
|
|
287
|
+
const visibleCount = list4.id === "client-connections" ? 2 : 3;
|
|
288
|
+
let frame = 0;
|
|
289
|
+
const sizes = new ResizeObserver(schedule2);
|
|
290
|
+
new MutationObserver(observeEntries2).observe(list4, { childList: true });
|
|
291
|
+
observeEntries2();
|
|
292
|
+
}
|
|
293
|
+
var measure;
|
|
294
|
+
var schedule;
|
|
295
|
+
var observeEntries;
|
|
296
|
+
|
|
297
|
+
// extension/src/activity-dashboard.ts
|
|
298
|
+
var stop = document.getElementById("access-stop");
|
|
299
|
+
var resume = document.getElementById("access-resume");
|
|
300
|
+
var accessNote = document.getElementById("access-note");
|
|
301
|
+
var historyNote = document.getElementById("activity-note");
|
|
302
|
+
var list2 = document.getElementById("activity-list");
|
|
303
|
+
var filter = document.getElementById("activity-filter");
|
|
304
|
+
var popup = document.body.dataset.view === "popup";
|
|
305
|
+
var accessGeneration = 0;
|
|
306
|
+
var historyGeneration = 0;
|
|
307
|
+
async function renderAccess() {
|
|
308
|
+
const generation = ++accessGeneration;
|
|
309
|
+
try {
|
|
310
|
+
const saved = await chrome.storage.local.get(ACCESS_STOPPED_KEY);
|
|
311
|
+
if (generation !== accessGeneration) return;
|
|
312
|
+
const stopped = saved[ACCESS_STOPPED_KEY] !== void 0 && saved[ACCESS_STOPPED_KEY] !== false;
|
|
313
|
+
stop.hidden = stopped && accessNote.dataset.error !== "true";
|
|
314
|
+
resume.hidden = !stopped;
|
|
315
|
+
document.getElementById("connect").hidden = stopped;
|
|
316
|
+
if (accessNote.dataset.error !== "true") accessNote.textContent = stopped ? "All apps are disconnected. Resume, then approve your app again." : "Stop disconnects all apps. An action already running may finish.";
|
|
317
|
+
} catch {
|
|
318
|
+
accessNote.textContent = "Could not read access settings. Reopen this page to try again.";
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
var OUTCOMES = {
|
|
322
|
+
running: "Running",
|
|
323
|
+
done: "Done",
|
|
324
|
+
blocked: "Blocked",
|
|
325
|
+
failed: "Failed",
|
|
326
|
+
interrupted: "Interrupted"
|
|
327
|
+
};
|
|
328
|
+
async function renderHistory() {
|
|
329
|
+
const generation = ++historyGeneration;
|
|
330
|
+
try {
|
|
331
|
+
const saved = await chrome.storage.session.get([ACTIVITY_KEY, "activityError"]);
|
|
332
|
+
if (generation !== historyGeneration) return;
|
|
333
|
+
const entries = Array.isArray(saved[ACTIVITY_KEY]) ? saved[ACTIVITY_KEY] : [];
|
|
334
|
+
const selected = filter?.value ?? "all";
|
|
335
|
+
const visible = activityRows(entries).filter((e) => selected === "all" || e.outcome === selected).reverse().slice(0, popup ? 5 : 100);
|
|
336
|
+
renderList(list2, visible, (entry) => entry.opened?.id ?? entry.id, (entry) => JSON.stringify(entry), (entry) => {
|
|
337
|
+
const item = document.createElement("li");
|
|
338
|
+
item.className = "activity-item";
|
|
339
|
+
item.dataset.outcome = entry.outcome;
|
|
340
|
+
const details = document.createElement("details");
|
|
341
|
+
const heading = document.createElement("summary");
|
|
342
|
+
heading.className = "activity-row";
|
|
343
|
+
const host = document.createElement("span");
|
|
344
|
+
host.className = "activity-host";
|
|
345
|
+
host.textContent = entry.host || (entry.method === "tabs_list" ? "All tabs" : entry.method === "proxy_status" ? "Proxy" : "No website");
|
|
346
|
+
host.title = host.textContent;
|
|
347
|
+
const label = document.createElement("span");
|
|
348
|
+
label.className = "activity-label";
|
|
349
|
+
const completedTab = entry.outcome === "done" && (entry.method === "tab_new" || entry.method === "tab_close");
|
|
350
|
+
label.textContent = entry.opened ? "Opened \u2192 Closed" : completedTab ? entry.method === "tab_new" ? "Opened" : "Closed" : activityLabel(entry.method);
|
|
351
|
+
const outcome = document.createElement("span");
|
|
352
|
+
outcome.className = "activity-outcome";
|
|
353
|
+
outcome.textContent = OUTCOMES[entry.outcome] ?? "Unknown";
|
|
354
|
+
outcome.hidden = completedTab;
|
|
355
|
+
heading.append(host, label, outcome);
|
|
356
|
+
const meta = document.createElement("div");
|
|
357
|
+
meta.className = "activity-meta";
|
|
358
|
+
const app = document.createElement("span");
|
|
359
|
+
app.textContent = entry.key ? `${entry.app} \xB7 ${entry.key.slice(0, 12)}` : "Unverified app";
|
|
360
|
+
const time = document.createElement("time");
|
|
361
|
+
time.dateTime = new Date(entry.at).toISOString();
|
|
362
|
+
time.textContent = new Date(entry.at).toLocaleTimeString([], { hour: "2-digit", minute: "2-digit", second: "2-digit" });
|
|
363
|
+
time.title = new Date(entry.at).toLocaleString();
|
|
364
|
+
meta.append(app, time);
|
|
365
|
+
if (entry.opened) {
|
|
366
|
+
const opened = document.createElement("span");
|
|
367
|
+
opened.className = "activity-opened";
|
|
368
|
+
opened.textContent = `Opened ${new Date(entry.opened.at).toLocaleString()} \xB7 Closed ${new Date(entry.at).toLocaleString()}`;
|
|
369
|
+
meta.append(opened);
|
|
370
|
+
}
|
|
371
|
+
details.append(heading, meta);
|
|
372
|
+
item.append(details);
|
|
373
|
+
return item;
|
|
374
|
+
});
|
|
375
|
+
historyNote.textContent = saved.activityError ? "Some activity could not be saved. This history may be incomplete." : visible.length ? popup ? `Latest ${visible.length} ${visible.length === 1 ? "activity" : "activities"}.` : `${visible.length} activities shown.` : selected === "all" ? "No activity yet." : "No matching requests.";
|
|
376
|
+
document.getElementById("activity-clear").disabled = entries.length === 0 && !saved.activityError;
|
|
377
|
+
} catch {
|
|
378
|
+
historyNote.textContent = "Activity is unavailable. Reopen this page to try again.";
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
function control(id, type, note3) {
|
|
382
|
+
const button2 = document.getElementById(id);
|
|
383
|
+
button2.addEventListener("click", async (event) => {
|
|
384
|
+
if (!event.isTrusted) return;
|
|
385
|
+
button2.disabled = true;
|
|
386
|
+
try {
|
|
387
|
+
const result = await chrome.runtime.sendMessage({ type });
|
|
388
|
+
note3.dataset.error = String(!result?.ok);
|
|
389
|
+
note3.textContent = result?.ok ? "" : result?.error ?? "Could not save this change. Please try again.";
|
|
390
|
+
} catch {
|
|
391
|
+
note3.dataset.error = "true";
|
|
392
|
+
note3.textContent = "Could not reach the extension. Reopen this page and try again.";
|
|
393
|
+
} finally {
|
|
394
|
+
button2.disabled = false;
|
|
395
|
+
}
|
|
396
|
+
if (type !== "activity_clear") await renderAccess();
|
|
397
|
+
else if (note3.dataset.error !== "true") await renderHistory();
|
|
398
|
+
});
|
|
399
|
+
}
|
|
400
|
+
control("access-stop", "access_stop", accessNote);
|
|
401
|
+
control("access-resume", "access_resume", accessNote);
|
|
402
|
+
control("activity-clear", "activity_clear", historyNote);
|
|
403
|
+
document.getElementById("activity-all")?.addEventListener("click", () => {
|
|
404
|
+
void chrome.tabs.create({ url: `${chrome.runtime.getURL("options.html")}#activity-section` });
|
|
405
|
+
});
|
|
406
|
+
filter?.addEventListener("change", () => void renderHistory());
|
|
407
|
+
chrome.storage.onChanged.addListener((changes, area) => {
|
|
408
|
+
if (area === "local" && changes[ACCESS_STOPPED_KEY]) void renderAccess();
|
|
409
|
+
if (area === "session" && (changes[ACTIVITY_KEY] || changes.activityError)) void renderHistory();
|
|
410
|
+
});
|
|
411
|
+
void renderAccess();
|
|
412
|
+
void renderHistory();
|
|
413
|
+
|
|
3
414
|
// shared/policy.ts
|
|
4
415
|
function hostOf(url) {
|
|
5
416
|
try {
|
|
@@ -10,15 +421,14 @@
|
|
|
10
421
|
}
|
|
11
422
|
function normalizeDomainPattern(pattern) {
|
|
12
423
|
let p = pattern.trim().toLowerCase();
|
|
13
|
-
if (p === "*" || p === "*://*/*") return "
|
|
424
|
+
if (p === "*" || p === "*://*/*" || p === "<all_urls>") return "";
|
|
14
425
|
p = p.replace(/^[a-z][a-z0-9+.-]*:\/\//, "");
|
|
15
426
|
p = p.replace(/[/?#].*$/, "");
|
|
16
427
|
p = p.replace(/^[^@]*@/, "").replace(/:\d+$/, "");
|
|
17
|
-
return p;
|
|
428
|
+
return p === "*" || p === "*." ? "" : p;
|
|
18
429
|
}
|
|
19
430
|
function globMatches(host, pattern) {
|
|
20
431
|
const p = normalizeDomainPattern(pattern);
|
|
21
|
-
if (p === "*") return true;
|
|
22
432
|
if (p.startsWith("*.")) {
|
|
23
433
|
const base = p.slice(2);
|
|
24
434
|
return host === base || host.endsWith("." + base);
|
|
@@ -31,62 +441,122 @@
|
|
|
31
441
|
return policy.allowDomains.some((pat) => globMatches(host, pat));
|
|
32
442
|
}
|
|
33
443
|
|
|
34
|
-
// shared/
|
|
35
|
-
|
|
444
|
+
// shared/browser-permissions.ts
|
|
445
|
+
function siteOrigins(input) {
|
|
446
|
+
if (/^[a-z][a-z0-9+.-]*:\/\//i.test(input) && !/^https?:\/\//i.test(input)) return [];
|
|
447
|
+
const pattern = normalizeDomainPattern(input);
|
|
448
|
+
const host = pattern.startsWith("*.") ? pattern.slice(2) : pattern;
|
|
449
|
+
if (!host || host.length > 253 || !/^[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?)*$/.test(host)) return [];
|
|
450
|
+
return [`http://${pattern}/*`, `https://${pattern}/*`];
|
|
451
|
+
}
|
|
452
|
+
var OPTIONAL_FEATURES = {
|
|
453
|
+
cookies: { label: "Cookies", explanation: "Read cookies on websites you have allowed. Cookie values still follow your server settings." },
|
|
454
|
+
downloads: { label: "Downloads", explanation: "Save files from websites you have allowed." }
|
|
455
|
+
};
|
|
456
|
+
var FEATURE_REQUESTS_KEY = "browserPermissionRequests";
|
|
36
457
|
|
|
37
|
-
// extension/src/
|
|
38
|
-
var
|
|
39
|
-
|
|
458
|
+
// extension/src/extra-permissions.ts
|
|
459
|
+
var section = document.getElementById("extra-permissions");
|
|
460
|
+
var list3 = document.getElementById("extra-permissions-list");
|
|
461
|
+
var note2 = document.getElementById("extra-permissions-note");
|
|
462
|
+
var rendering = 0;
|
|
463
|
+
async function render2() {
|
|
464
|
+
if (!section || !list3 || !note2) return;
|
|
465
|
+
const generation = ++rendering;
|
|
466
|
+
const saved = (await chrome.storage.local.get(FEATURE_REQUESTS_KEY))[FEATURE_REQUESTS_KEY];
|
|
467
|
+
const pending2 = Array.isArray(saved) ? saved : [];
|
|
468
|
+
const features = [];
|
|
469
|
+
for (const feature of Object.keys(OPTIONAL_FEATURES)) {
|
|
470
|
+
const granted = await chrome.permissions.contains({ permissions: [feature] }).catch(() => false);
|
|
471
|
+
if (!granted && !pending2.includes(feature)) continue;
|
|
472
|
+
features.push({ feature, granted });
|
|
473
|
+
}
|
|
474
|
+
if (generation !== rendering) return;
|
|
475
|
+
renderList(list3, features, ({ feature }) => feature, ({ granted }) => String(granted), ({ feature, granted }) => {
|
|
476
|
+
const { label, explanation } = OPTIONAL_FEATURES[feature];
|
|
477
|
+
const row2 = document.createElement("li");
|
|
478
|
+
row2.className = "client-row";
|
|
479
|
+
row2.dataset.feature = feature;
|
|
480
|
+
const title = document.createElement("strong");
|
|
481
|
+
title.textContent = label;
|
|
482
|
+
const description = document.createElement("p");
|
|
483
|
+
description.className = "note hint";
|
|
484
|
+
description.textContent = explanation;
|
|
485
|
+
const button2 = document.createElement("button");
|
|
486
|
+
button2.className = granted ? "ghost" : "primary";
|
|
487
|
+
button2.textContent = granted ? `Remove ${label.toLowerCase()}` : `Allow ${label.toLowerCase()}`;
|
|
488
|
+
button2.addEventListener("click", async (event) => {
|
|
489
|
+
if (!event.isTrusted) return;
|
|
490
|
+
try {
|
|
491
|
+
await busyButton(button2, async () => {
|
|
492
|
+
const result = await chrome.runtime.sendMessage({ type: "feature_access", feature, allow: !granted });
|
|
493
|
+
note2.textContent = result?.ok ? "" : result?.error ?? "Could not change this permission. Please try again.";
|
|
494
|
+
});
|
|
495
|
+
} catch {
|
|
496
|
+
note2.textContent = "Could not change this permission. Please try again.";
|
|
497
|
+
}
|
|
498
|
+
await render2();
|
|
499
|
+
});
|
|
500
|
+
row2.append(title, description, button2);
|
|
501
|
+
return row2;
|
|
502
|
+
});
|
|
503
|
+
section.hidden = features.length === 0;
|
|
504
|
+
}
|
|
505
|
+
chrome.storage.onChanged.addListener((changes, area) => {
|
|
506
|
+
if (area === "local" && changes[FEATURE_REQUESTS_KEY]) void render2();
|
|
507
|
+
});
|
|
508
|
+
chrome.permissions.onAdded.addListener(() => void render2());
|
|
509
|
+
chrome.permissions.onRemoved.addListener(() => void render2());
|
|
510
|
+
void render2();
|
|
511
|
+
|
|
512
|
+
// extension/src/site-access.ts
|
|
513
|
+
async function permittedSites(sites) {
|
|
514
|
+
const checks = await Promise.all(sites.map(async (site) => {
|
|
515
|
+
const origins = siteOrigins(site);
|
|
516
|
+
return origins.length && await chrome.permissions.contains({ origins }).catch(() => false) ? site : null;
|
|
517
|
+
}));
|
|
518
|
+
return checks.filter((site) => site !== null);
|
|
519
|
+
}
|
|
520
|
+
async function changeSiteAccess(input, allow) {
|
|
521
|
+
const origins = siteOrigins(input);
|
|
522
|
+
if (!origins.length) return { ok: false, error: "Please enter one website, such as example.com. All-site access is not available." };
|
|
40
523
|
try {
|
|
41
|
-
const
|
|
42
|
-
|
|
524
|
+
const result = await chrome.runtime.sendMessage({
|
|
525
|
+
type: "site_access",
|
|
526
|
+
host: normalizeDomainPattern(input),
|
|
527
|
+
allow
|
|
528
|
+
});
|
|
529
|
+
return result ?? { ok: false, error: "Please start your connected app and try again." };
|
|
43
530
|
} catch (err) {
|
|
44
|
-
|
|
45
|
-
if (/not found|not registered|Specified native messaging host/i.test(why)) {
|
|
46
|
-
return {
|
|
47
|
-
ok: false,
|
|
48
|
-
error: "no_helper",
|
|
49
|
-
message: "Add the MCP Browser Extension server to your AI client (Claude Code, Cursor\u2026) and start it once; it sets this up. Then click Connect again."
|
|
50
|
-
};
|
|
51
|
-
}
|
|
52
|
-
return { ok: false, message: why };
|
|
531
|
+
return { ok: false, error: err instanceof Error ? err.message : "Could not change this website permission. Please try again." };
|
|
53
532
|
}
|
|
54
533
|
}
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
wsPort: reply.port,
|
|
58
|
-
token: reply.token,
|
|
59
|
-
// The server's own --profile when it set one; otherwise let the server name us.
|
|
60
|
-
...reply.profile ? { profile: reply.profile } : {},
|
|
61
|
-
pairingSource: "native"
|
|
62
|
-
});
|
|
63
|
-
}
|
|
534
|
+
|
|
535
|
+
// extension/src/connect.ts
|
|
64
536
|
async function connectWithOneClick() {
|
|
65
|
-
let granted = false;
|
|
66
537
|
try {
|
|
67
|
-
|
|
68
|
-
} catch
|
|
69
|
-
return { ok: false, message:
|
|
538
|
+
return await chrome.runtime.sendMessage({ type: "connect_with_click" }) ?? { ok: false, message: "Could not reach the extension." };
|
|
539
|
+
} catch {
|
|
540
|
+
return { ok: false, message: "Could not reach the extension. Reopen the popup and try again." };
|
|
70
541
|
}
|
|
71
|
-
if (!granted) return { ok: false, message: "Chrome needs that permission to fetch the pairing for you. You can also pair by hand in Settings." };
|
|
72
|
-
const reply = await fetchPairing();
|
|
73
|
-
if (!reply.ok) return { ok: false, message: reply.message };
|
|
74
|
-
await applyPairing(reply);
|
|
75
|
-
await chrome.runtime.sendMessage({ type: "reconnect" }).catch(() => void 0);
|
|
76
|
-
return { ok: true };
|
|
77
542
|
}
|
|
78
543
|
|
|
79
544
|
// extension/src/popup/popup.ts
|
|
80
545
|
var $ = (id) => document.getElementById(id);
|
|
81
546
|
async function grant(host, allow) {
|
|
82
|
-
const res = await
|
|
83
|
-
|
|
547
|
+
const res = await changeSiteAccess(host, allow);
|
|
548
|
+
await render3();
|
|
549
|
+
$("allowed-note").textContent = res.ok ? "" : res.error ?? "Could not change website access. Please try again.";
|
|
84
550
|
}
|
|
85
551
|
function button(label, onClick, kind = "") {
|
|
86
552
|
const b = document.createElement("button");
|
|
87
553
|
b.textContent = label;
|
|
88
554
|
if (kind) b.className = kind;
|
|
89
|
-
b.addEventListener("click",
|
|
555
|
+
b.addEventListener("click", (event) => {
|
|
556
|
+
if (event.isTrusted) void busyButton(b, onClick).catch(() => {
|
|
557
|
+
$("allowed-note").textContent = "Could not finish that action. Please try again.";
|
|
558
|
+
});
|
|
559
|
+
});
|
|
90
560
|
return b;
|
|
91
561
|
}
|
|
92
562
|
function hue(host) {
|
|
@@ -127,30 +597,42 @@
|
|
|
127
597
|
return null;
|
|
128
598
|
}
|
|
129
599
|
}
|
|
130
|
-
|
|
600
|
+
var renderGeneration2 = 0;
|
|
601
|
+
async function render3() {
|
|
602
|
+
const generation = ++renderGeneration2;
|
|
131
603
|
const s = await chrome.storage.local.get([
|
|
132
604
|
"connState",
|
|
133
605
|
"pairedProfile",
|
|
134
606
|
"allowedSites",
|
|
135
607
|
"grantedSites",
|
|
136
608
|
"blockedSites",
|
|
609
|
+
"dismissedSites",
|
|
137
610
|
"tabBorder",
|
|
138
611
|
"latestExtension",
|
|
139
|
-
|
|
612
|
+
ACCESS_STOPPED_KEY
|
|
140
613
|
]);
|
|
141
|
-
const state = typeof s.connState === "string" ? s.connState : "idle";
|
|
614
|
+
const state = s[ACCESS_STOPPED_KEY] !== void 0 && s[ACCESS_STOPPED_KEY] !== false ? "stopped" : typeof s.connState === "string" ? s.connState : "idle";
|
|
142
615
|
const connected = state === "connected";
|
|
143
|
-
const allowed = Array.isArray(s.allowedSites) ? s.allowedSites : [];
|
|
616
|
+
const allowed = Array.isArray(s.allowedSites) ? s.allowedSites.map(normalizeDomainPattern).filter(Boolean) : [];
|
|
144
617
|
const granted = Array.isArray(s.grantedSites) ? s.grantedSites : null;
|
|
145
|
-
const
|
|
146
|
-
const
|
|
618
|
+
const permitted = await permittedSites(allowed);
|
|
619
|
+
const host = connected ? await currentHost() : null;
|
|
620
|
+
const hostPermitted = host ? (await permittedSites([host])).length > 0 : false;
|
|
621
|
+
if (generation !== renderGeneration2) return;
|
|
147
622
|
const policy = { allowDomains: allowed };
|
|
623
|
+
const pending2 = Array.isArray(s.blockedSites) ? s.blockedSites : [];
|
|
624
|
+
const blocked = [.../* @__PURE__ */ new Set([
|
|
625
|
+
...pending2.filter((b) => !isDomainAllowed(`https://${b.host}/`, { allowDomains: permitted })).map((b) => b.host),
|
|
626
|
+
...allowed.filter((site) => !permitted.includes(site))
|
|
627
|
+
])].filter((site) => !Array.isArray(s.dismissedSites) || !s.dismissedSites.includes(site));
|
|
628
|
+
const canGrant = connected && (granted !== null || allowed.length > 0);
|
|
148
629
|
const labels = {
|
|
149
630
|
connected: ["Connected", "ok"],
|
|
150
631
|
connecting: ["Connecting\u2026", "warn"],
|
|
151
632
|
unauthorized: ["Token rejected", "bad"],
|
|
152
633
|
superseded: ["Name taken", "bad"],
|
|
153
|
-
idle: ["Not connected", ""]
|
|
634
|
+
idle: ["Not connected", ""],
|
|
635
|
+
stopped: ["Access stopped", "bad"]
|
|
154
636
|
};
|
|
155
637
|
const [text, cls] = labels[state] ?? [state, ""];
|
|
156
638
|
$("state-text").textContent = text;
|
|
@@ -163,11 +645,10 @@
|
|
|
163
645
|
btn.className = connected ? "secondary" : "primary";
|
|
164
646
|
}
|
|
165
647
|
$("connect-card").className = connected ? "card connect done" : "card connect";
|
|
166
|
-
$("connect-text").textContent = state === "
|
|
167
|
-
const host = connected ? await currentHost() : null;
|
|
648
|
+
$("connect-text").textContent = state === "stopped" ? "" : state === "unauthorized" ? "The connection needs to be refreshed. Click Connect again." : state === "superseded" ? `Another browser connected as "${typeof s.pairedProfile === "string" ? s.pairedProfile : "this profile"}", so this one stepped aside. Give it its own Profile name in Settings.` : "Connect to your app to start using this browser.";
|
|
168
649
|
$("this-site").hidden = !host;
|
|
169
650
|
if (host) {
|
|
170
|
-
const ok = isDomainAllowed(`https://${host}/`, policy);
|
|
651
|
+
const ok = hostPermitted && isDomainAllowed(`https://${host}/`, policy);
|
|
171
652
|
$("site-host").textContent = host;
|
|
172
653
|
$("site-host").title = host;
|
|
173
654
|
const avatar = $("site-avatar");
|
|
@@ -177,29 +658,34 @@
|
|
|
177
658
|
$("site-state").textContent = ok ? "\u25CF Agent can use this site" : "\u25CF Blocked for the agent";
|
|
178
659
|
$("site-state").className = `chip ${ok ? "ok" : "warn"}`;
|
|
179
660
|
$("site-allow").hidden = ok || !canGrant;
|
|
180
|
-
$("site-allow").onclick = () =>
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
)
|
|
661
|
+
$("site-allow").onclick = (event) => {
|
|
662
|
+
if (event.isTrusted) void busyButton($("site-allow"), () => grant(host, true));
|
|
663
|
+
};
|
|
664
|
+
}
|
|
665
|
+
renderList(
|
|
666
|
+
$("blocked"),
|
|
667
|
+
blocked,
|
|
668
|
+
(host2) => host2,
|
|
669
|
+
(host2) => host2,
|
|
670
|
+
(host2) => row(host2, [
|
|
671
|
+
button("Dismiss", () => chrome.runtime.sendMessage({ type: "dismiss_blocked", host: host2 }), "ghost"),
|
|
672
|
+
button("Allow", () => grant(host2, true), "primary")
|
|
673
|
+
])
|
|
189
674
|
);
|
|
190
675
|
$("blocked-section").hidden = !canGrant || blocked.length === 0;
|
|
191
676
|
$("blocked-count").textContent = String(blocked.length);
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
)
|
|
677
|
+
renderList(
|
|
678
|
+
$("allowed"),
|
|
679
|
+
permitted,
|
|
680
|
+
(host2) => host2,
|
|
681
|
+
(host2) => JSON.stringify([host2, granted?.includes(host2)]),
|
|
682
|
+
(h) => row(h, [...granted?.includes(h) ? [] : [tag("From setup")], button("Remove", () => grant(h, false), "ghost")])
|
|
196
683
|
);
|
|
197
684
|
$("allowed-section").hidden = !connected;
|
|
198
|
-
$("allowed-count").textContent =
|
|
199
|
-
|
|
200
|
-
else if (connected && granted === null) $("allowed-note").textContent = "This server takes sites only from its flags.";
|
|
685
|
+
$("allowed-count").textContent = String(permitted.length);
|
|
686
|
+
$("allowed-note").textContent = connected && permitted.length === 0 ? "No sites allowed yet. Click Allow above to give Chrome permission for a website." : "";
|
|
201
687
|
$("tab-border").checked = s.tabBorder !== false;
|
|
202
|
-
void renderUpdate(typeof s.latestExtension === "string" ? s.latestExtension : null
|
|
688
|
+
void renderUpdate(typeof s.latestExtension === "string" ? s.latestExtension : null);
|
|
203
689
|
}
|
|
204
690
|
function compareVersions(a, b) {
|
|
205
691
|
const x = a.split(".").map((n) => Number.parseInt(n, 10) || 0);
|
|
@@ -210,22 +696,31 @@
|
|
|
210
696
|
}
|
|
211
697
|
return 0;
|
|
212
698
|
}
|
|
213
|
-
async function renderUpdate(latest
|
|
699
|
+
async function renderUpdate(latest) {
|
|
214
700
|
const mine = chrome.runtime.getManifest().version;
|
|
215
701
|
const unpacked = await chrome.management.getSelf().then((me) => me.installType === "development").catch(() => false);
|
|
216
702
|
const behind = latest !== null && compareVersions(latest, mine) > 0;
|
|
217
|
-
|
|
218
|
-
$("update").hidden = !unpacked
|
|
219
|
-
$("update-
|
|
220
|
-
$("update-text").textContent = behind ? `You have ${mine}. This copy was loaded by hand and does not update itself. The Chrome Web Store copy updates automatically.` : "This copy was loaded by hand and does not update itself. Install the Chrome Web Store copy to get every update automatically, then remove this one.";
|
|
221
|
-
$("update-dismiss").onclick = () => void chrome.storage.local.set({ updateDismissedFor: key }).then(render);
|
|
703
|
+
$("update").hidden = !unpacked;
|
|
704
|
+
$("update-store").hidden = !unpacked;
|
|
705
|
+
$("update-text").textContent = behind ? `Update available: ${latest}. You have ${mine}. This copy was loaded by hand and does not update itself. The Chrome Web Store copy updates automatically.` : "This copy was loaded by hand and does not update itself. Install the Chrome Web Store copy to get every update automatically, then remove this one.";
|
|
222
706
|
}
|
|
707
|
+
var updateHelp = $("update-help");
|
|
708
|
+
updateHelp.addEventListener("keydown", (event) => {
|
|
709
|
+
if (event.key === "Escape") updateHelp.dataset.dismissed = "true";
|
|
710
|
+
});
|
|
711
|
+
updateHelp.addEventListener("mouseleave", () => {
|
|
712
|
+
delete updateHelp.dataset.dismissed;
|
|
713
|
+
});
|
|
714
|
+
updateHelp.addEventListener("focusout", () => {
|
|
715
|
+
delete updateHelp.dataset.dismissed;
|
|
716
|
+
});
|
|
223
717
|
$("update-store").addEventListener("click", () => void chrome.tabs.create({ url: STORE_EXTENSION_URL }));
|
|
224
718
|
$("tab-border").addEventListener("change", (e) => {
|
|
225
719
|
void chrome.storage.local.set({ tabBorder: e.target.checked });
|
|
226
720
|
});
|
|
227
721
|
$("settings").addEventListener("click", () => void chrome.runtime.openOptionsPage());
|
|
228
|
-
$("connect").addEventListener("click", async () => {
|
|
722
|
+
$("connect").addEventListener("click", async (event) => {
|
|
723
|
+
if (!event.isTrusted) return;
|
|
229
724
|
const btn = $("connect");
|
|
230
725
|
btn.disabled = true;
|
|
231
726
|
btn.textContent = "Connecting\u2026";
|
|
@@ -233,13 +728,15 @@
|
|
|
233
728
|
const res = await connectWithOneClick();
|
|
234
729
|
btn.disabled = false;
|
|
235
730
|
if (!res.ok) $("connect-msg").textContent = res.message ?? "Could not connect.";
|
|
236
|
-
void
|
|
731
|
+
void render3();
|
|
237
732
|
});
|
|
238
733
|
chrome.storage.onChanged.addListener((changes, area) => {
|
|
239
734
|
if (area !== "local") return;
|
|
240
|
-
if (changes.connState || changes.allowedSites || changes.grantedSites || changes.blockedSites || changes.pairedProfile || changes.latestExtension) {
|
|
241
|
-
void
|
|
735
|
+
if (changes[ACCESS_STOPPED_KEY] || changes.connState || changes.allowedSites || changes.grantedSites || changes.blockedSites || changes.dismissedSites || changes.pairedProfile || changes.latestExtension) {
|
|
736
|
+
void render3();
|
|
242
737
|
}
|
|
243
738
|
});
|
|
244
|
-
void
|
|
739
|
+
void render3();
|
|
740
|
+
chrome.permissions.onAdded.addListener(() => void render3());
|
|
741
|
+
chrome.permissions.onRemoved.addListener(() => void render3());
|
|
245
742
|
})();
|