@jeffawe/understudy 0.0.0-stage → 0.2.0

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.
Files changed (99) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +171 -2
  3. package/REASONER.md +67 -0
  4. package/build/extension/firefox/background.js +186 -0
  5. package/build/extension/firefox/icons/icon-128.png +0 -0
  6. package/build/extension/firefox/icons/icon-16.png +0 -0
  7. package/build/extension/firefox/icons/icon-32.png +0 -0
  8. package/build/extension/firefox/icons/icon-48.png +0 -0
  9. package/build/extension/firefox/manifest.json +54 -0
  10. package/build/extension/firefox/popup.html +52 -0
  11. package/build/extension/firefox/popup.js +106 -0
  12. package/build/extension/firefox/recorder.js +362 -0
  13. package/dist/adapters/recorder/accname-bundle.d.ts +12 -0
  14. package/dist/adapters/recorder/accname-bundle.js +12 -0
  15. package/dist/adapters/recorder/extension.d.ts +57 -0
  16. package/dist/adapters/recorder/extension.js +146 -0
  17. package/dist/adapters/recorder/injected.d.ts +21 -0
  18. package/dist/adapters/recorder/injected.js +352 -0
  19. package/dist/adapters/recorder/live.d.ts +105 -0
  20. package/dist/adapters/recorder/live.js +317 -0
  21. package/dist/adapters/recorder/script.d.ts +43 -0
  22. package/dist/adapters/recorder/script.js +530 -0
  23. package/dist/adapters/recorder/wire.d.ts +42 -0
  24. package/dist/adapters/recorder/wire.js +51 -0
  25. package/dist/core/auth-cache.d.ts +119 -0
  26. package/dist/core/auth-cache.js +216 -0
  27. package/dist/core/browser.d.ts +47 -0
  28. package/dist/core/browser.js +82 -0
  29. package/dist/core/distill.d.ts +118 -0
  30. package/dist/core/distill.js +197 -0
  31. package/dist/core/fingerprint.d.ts +15 -0
  32. package/dist/core/fingerprint.js +21 -0
  33. package/dist/core/recording-store.d.ts +34 -0
  34. package/dist/core/recording-store.js +64 -0
  35. package/dist/core/recording.d.ts +185 -0
  36. package/dist/core/recording.js +100 -0
  37. package/dist/core/replay.d.ts +307 -0
  38. package/dist/core/replay.js +804 -0
  39. package/dist/core/sig.d.ts +70 -0
  40. package/dist/core/sig.js +0 -0
  41. package/dist/core/trigger.d.ts +18 -0
  42. package/dist/core/trigger.js +35 -0
  43. package/dist/core/types.d.ts +28 -0
  44. package/dist/core/types.js +8 -0
  45. package/dist/core/visual.d.ts +80 -0
  46. package/dist/core/visual.js +111 -0
  47. package/dist/entry/cli.d.ts +9 -0
  48. package/dist/entry/cli.js +1008 -0
  49. package/dist/entry/mcp.d.ts +20 -0
  50. package/dist/entry/mcp.js +288 -0
  51. package/dist/flows/destructive.d.ts +19 -0
  52. package/dist/flows/destructive.js +48 -0
  53. package/dist/flows/distill.d.ts +28 -0
  54. package/dist/flows/distill.js +109 -0
  55. package/dist/flows/drift.d.ts +43 -0
  56. package/dist/flows/drift.js +116 -0
  57. package/dist/flows/emit.d.ts +23 -0
  58. package/dist/flows/emit.js +133 -0
  59. package/dist/flows/execute.d.ts +75 -0
  60. package/dist/flows/execute.js +133 -0
  61. package/dist/flows/findings.d.ts +38 -0
  62. package/dist/flows/findings.js +136 -0
  63. package/dist/flows/runs.d.ts +42 -0
  64. package/dist/flows/runs.js +93 -0
  65. package/dist/flows/save.d.ts +74 -0
  66. package/dist/flows/save.js +171 -0
  67. package/dist/memory/notes.d.ts +89 -0
  68. package/dist/memory/notes.js +163 -0
  69. package/dist/memory/placeholders.d.ts +41 -0
  70. package/dist/memory/placeholders.js +139 -0
  71. package/dist/memory/recall.d.ts +118 -0
  72. package/dist/memory/recall.js +147 -0
  73. package/dist/memory/vocabulary.d.ts +9 -0
  74. package/dist/memory/vocabulary.js +24 -0
  75. package/dist/plan/planner.d.ts +69 -0
  76. package/dist/plan/planner.js +211 -0
  77. package/dist/plan/seams.d.ts +58 -0
  78. package/dist/plan/seams.js +99 -0
  79. package/dist/store/db.d.ts +62 -0
  80. package/dist/store/db.js +183 -0
  81. package/dist/store/embed.d.ts +46 -0
  82. package/dist/store/embed.js +100 -0
  83. package/dist/store/reembed.d.ts +13 -0
  84. package/dist/store/reembed.js +32 -0
  85. package/dist/store/settings.d.ts +67 -0
  86. package/dist/store/settings.js +151 -0
  87. package/dist/store/types.d.ts +220 -0
  88. package/dist/store/types.js +14 -0
  89. package/extension/README.md +79 -0
  90. package/extension/background.js +186 -0
  91. package/extension/icons/icon-128.png +0 -0
  92. package/extension/icons/icon-16.png +0 -0
  93. package/extension/icons/icon-32.png +0 -0
  94. package/extension/icons/icon-48.png +0 -0
  95. package/extension/manifest.json +38 -0
  96. package/extension/popup.html +52 -0
  97. package/extension/popup.js +106 -0
  98. package/extension/recorder.js +362 -0
  99. package/package.json +68 -4
@@ -0,0 +1,186 @@
1
+ // Understudy recorder — background service worker.
2
+ //
3
+ // Holds the one recording in progress (which tab, which token), injects the
4
+ // recorder into that tab after every page load, and forwards each action to
5
+ // the `understudy record <app>` process on this machine, in order.
6
+ // The extension stores nothing about the page itself.
7
+
8
+ const DEFAULT_PORT = 7397;
9
+
10
+ async function cliUrl() {
11
+ const { port = DEFAULT_PORT } = await chrome.storage.local.get('port');
12
+ return `http://127.0.0.1:${port}`;
13
+ }
14
+
15
+ /** Is `understudy record <app>` running, and for which app? */
16
+ async function hello() {
17
+ let res;
18
+ try {
19
+ res = await fetch(`${await cliUrl()}/hello`);
20
+ } catch {
21
+ throw new Error('Understudy is not waiting. In a terminal, run: understudy record <app>');
22
+ }
23
+ if (!res.ok) throw new Error(`Understudy answered ${res.status}`);
24
+ return res.json();
25
+ }
26
+
27
+ async function post(path, body) {
28
+ let res;
29
+ try {
30
+ res = await fetch(`${await cliUrl()}${path}`, {
31
+ method: 'POST',
32
+ headers: { 'content-type': 'application/json' },
33
+ body: JSON.stringify(body),
34
+ });
35
+ } catch {
36
+ throw new Error('Understudy is no longer running in the terminal. Run: understudy record <app>');
37
+ }
38
+ const data = await res.json().catch(() => ({}));
39
+ if (!res.ok) throw new Error(data.error || `Understudy answered ${res.status}`);
40
+ return data;
41
+ }
42
+
43
+ async function current() {
44
+ return (await chrome.storage.session.get('rec')).rec;
45
+ }
46
+
47
+ async function inject(tabId, frameIds) {
48
+ await chrome.scripting.executeScript({
49
+ target: frameIds ? { tabId, frameIds } : { tabId, allFrames: true },
50
+ files: ['recorder.js'],
51
+ });
52
+ }
53
+
54
+ /** This tab's cookies and local storage, in the shape Playwright restores. */
55
+ async function captureSession(tab) {
56
+ const sameSite = { no_restriction: 'None', lax: 'Lax', strict: 'Strict', unspecified: 'Lax' };
57
+ const cookies = (await chrome.cookies.getAll({ url: tab.url })).map((c) => ({
58
+ name: c.name, value: c.value, domain: c.domain, path: c.path,
59
+ expires: c.session ? -1 : c.expirationDate ?? -1,
60
+ httpOnly: c.httpOnly, secure: c.secure, sameSite: sameSite[c.sameSite] ?? 'Lax',
61
+ }));
62
+ const [{ result: entries = [] } = {}] = await chrome.scripting.executeScript({
63
+ target: { tabId: tab.id },
64
+ func: () => Object.entries(localStorage),
65
+ });
66
+ const origin = new URL(tab.url).origin;
67
+ return { cookies, origins: [{ origin, localStorage: entries.map(([name, value]) => ({ name, value })) }] };
68
+ }
69
+
70
+ // The tab's sign-in is always sent. Ticked "I'm signed in here": the flow starts
71
+ // signed in, full stop. Unticked: Understudy works it out when you save (it
72
+ // proves the recording without the sign-in first) and deletes it if unneeded.
73
+ let starting = null;
74
+ function startRecording(tabId, opts = {}) {
75
+ // One start at a time: the popup and the permission-granted handler below can
76
+ // both ask, and the second must wait for, not repeat, the first.
77
+ return (starting ??= doStart(tabId, opts).finally(() => { starting = null; }));
78
+ }
79
+
80
+ async function doStart(tabId, { signedIn = false, save = true } = {}) {
81
+ if (await current()) throw new Error('Already recording — stop that one first.');
82
+ const { app, token, started, savedBy = 'terminal' } = await hello();
83
+ if (started) throw new Error('That Understudy recording has already started. Run the command again for a new one.');
84
+ const tab = await chrome.tabs.get(tabId);
85
+ const storageState = await captureSession(tab);
86
+ await post('/start', { token, url: tab.url, storageState, signedIn });
87
+ await chrome.storage.session.set({ rec: { tabId, token, app, origin: new URL(tab.url).origin, save, savedBy } });
88
+ await inject(tabId);
89
+ await chrome.action.setBadgeText({ tabId, text: 'REC' });
90
+ await chrome.action.setBadgeBackgroundColor({ tabId, color: '#c62828' });
91
+ return { app };
92
+ }
93
+
94
+ // --- starting right after the user allows a site -----------------------------
95
+ //
96
+ // Chrome closes the popup when its "allow this site?" dialog appears, so the
97
+ // click on "Record from this page" would be lost and nothing would start. The
98
+ // popup leaves a note first; once the permission is granted, this worker —
99
+ // which outlives the popup — starts the recording itself.
100
+
101
+ const PENDING_MS = 2 * 60 * 1000;
102
+
103
+ async function noteFailure(tabId, message) {
104
+ await chrome.storage.session.set({ lastError: message });
105
+ await chrome.action.setBadgeText({ tabId, text: '!' }).catch(() => {});
106
+ await chrome.action.setBadgeBackgroundColor({ tabId, color: '#ef6c00' }).catch(() => {});
107
+ }
108
+
109
+ async function onPermissionAdded({ origins = [] }) {
110
+ const { pending } = await chrome.storage.session.get('pending');
111
+ if (!pending || Date.now() - pending.at > PENDING_MS) return;
112
+ // Only for the site that was asked about (the pattern is `<origin>/*`).
113
+ if (!origins.some((o) => o.replace(/\/\*$/, '') === pending.origin)) return;
114
+ await chrome.storage.session.remove('pending');
115
+ try {
116
+ await startRecording(pending.tabId, { signedIn: pending.signedIn, save: pending.save !== false });
117
+ } catch (e) {
118
+ if (!/Already recording/.test(e.message)) await noteFailure(pending.tabId, e.message);
119
+ }
120
+ }
121
+ chrome.permissions.onAdded.addListener(onPermissionAdded);
122
+
123
+ /** Stop. `name` (when the user ticked "Save as a flow when I stop"): the terminal proves and saves it under that name. */
124
+ async function stopRecording({ name } = {}) {
125
+ const rec = await current();
126
+ if (!rec) return { stopped: false };
127
+ // A field still being typed in hasn't been sent yet; flush it.
128
+ await chrome.scripting
129
+ .executeScript({ target: { tabId: rec.tabId, allFrames: true }, func: () => window.__understudyFlush && window.__understudyFlush() })
130
+ .catch(() => {});
131
+ await new Promise((r) => setTimeout(r, 300));
132
+ await queue;
133
+ await chrome.storage.session.remove('rec');
134
+ await chrome.action.setBadgeText({ tabId: rec.tabId, text: '' }).catch(() => {});
135
+ const saving = Boolean(name) && rec.save && rec.savedBy !== 'agent';
136
+ const { events, hash } = await post('/stop', { token: rec.token, ...(saving ? { name } : {}) });
137
+ return { stopped: true, events, hash, saving, savedBy: rec.savedBy };
138
+ }
139
+
140
+ // Events go out one at a time, in the order they happened.
141
+ let queue = Promise.resolve();
142
+ function forward(event) {
143
+ queue = queue.then(async () => {
144
+ const rec = await current();
145
+ if (rec) await post('/event', { token: rec.token, event }).catch(() => {});
146
+ });
147
+ }
148
+
149
+ chrome.runtime.onMessage.addListener((msg, sender, sendResponse) => {
150
+ if (sender.id !== chrome.runtime.id) return false;
151
+ if (msg.type === 'understudy:event') {
152
+ current().then((rec) => {
153
+ if (rec && sender.tab && sender.tab.id === rec.tabId) forward(msg.event);
154
+ });
155
+ return false;
156
+ }
157
+ const handlers = {
158
+ 'understudy:status': async () => {
159
+ // A start that failed after the popup closed: say so once, then forget it.
160
+ const { lastError } = await chrome.storage.session.get('lastError');
161
+ await chrome.storage.session.remove('lastError');
162
+ return { rec: (await current()) ?? null, lastError: lastError ?? null, cli: await hello().catch((e) => ({ error: e.message })) };
163
+ },
164
+ 'understudy:start': () => startRecording(msg.tabId, { signedIn: Boolean(msg.signedIn), save: msg.save !== false }),
165
+ 'understudy:stop': () => stopRecording({ name: msg.name }),
166
+ };
167
+ const handler = handlers[msg.type];
168
+ if (!handler) return false;
169
+ handler().then((r) => sendResponse({ ok: true, ...r }), (e) => sendResponse({ ok: false, error: e.message }));
170
+ return true; // answering asynchronously
171
+ });
172
+
173
+ // A click that loads a new page loses the recorder; put it back. Pages on a
174
+ // site you haven't allowed (a payment provider, say) can't be recorded.
175
+ chrome.webNavigation.onDOMContentLoaded.addListener(async ({ tabId, frameId }) => {
176
+ const rec = await current();
177
+ if (rec && rec.tabId === tabId) await inject(tabId, [frameId]).catch(() => {});
178
+ });
179
+
180
+ chrome.tabs.onRemoved.addListener(async (tabId) => {
181
+ const rec = await current();
182
+ if (rec && rec.tabId === tabId) await stopRecording().catch(() => {});
183
+ });
184
+
185
+ // For tests and the console: drive it without the popup.
186
+ self.understudy = { startRecording, stopRecording, current, onPermissionAdded };
Binary file
Binary file
Binary file
Binary file
@@ -0,0 +1,38 @@
1
+ {
2
+ "manifest_version": 3,
3
+ "name": "Understudy recorder",
4
+ "version": "0.2.0",
5
+ "description": "Record a flow in the tab you already have open, for Understudy to replay as a test.",
6
+ "action": {
7
+ "default_popup": "popup.html",
8
+ "default_title": "Understudy recorder",
9
+ "default_icon": {
10
+ "16": "icons/icon-16.png",
11
+ "32": "icons/icon-32.png",
12
+ "48": "icons/icon-48.png"
13
+ }
14
+ },
15
+ "background": {
16
+ "service_worker": "background.js"
17
+ },
18
+ "permissions": [
19
+ "activeTab",
20
+ "scripting",
21
+ "storage",
22
+ "cookies",
23
+ "webNavigation"
24
+ ],
25
+ "host_permissions": [
26
+ "http://127.0.0.1/*"
27
+ ],
28
+ "optional_host_permissions": [
29
+ "https://*/*",
30
+ "http://*/*"
31
+ ],
32
+ "icons": {
33
+ "16": "icons/icon-16.png",
34
+ "32": "icons/icon-32.png",
35
+ "48": "icons/icon-48.png",
36
+ "128": "icons/icon-128.png"
37
+ }
38
+ }
@@ -0,0 +1,52 @@
1
+ <!doctype html>
2
+ <html>
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <style>
6
+ body { font: 13px/1.4 system-ui, sans-serif; width: 300px; margin: 12px; color: #222; }
7
+ h1 { font-size: 14px; margin: 0 0 8px; }
8
+ .status { white-space: pre-line; overflow-wrap: anywhere; padding: 8px; border-radius: 6px; background: #f2f2f2; margin-bottom: 10px; }
9
+ .status.rec { background: #fdecea; color: #b71c1c; }
10
+ .status.err { background: #fff4e5; color: #8a4b00; }
11
+ label { display: flex; gap: 6px; align-items: flex-start; margin: 8px 0; }
12
+ button { width: 100%; padding: 8px; font-size: 13px; border: 0; border-radius: 6px; cursor: pointer; }
13
+ #start { background: #1565c0; color: #fff; }
14
+ #stop { background: #c62828; color: #fff; }
15
+ button:disabled { opacity: .5; cursor: default; }
16
+ .small { color: #666; font-size: 11px; }
17
+ details { margin-top: 10px; }
18
+ input[type=number] { width: 80px; }
19
+ input[type=text] { width: 100%; padding: 7px 8px; font: inherit; border: 1px solid #ccc; border-radius: 6px; margin: 2px 0 8px; }
20
+ .field { display: block; margin: 0 0 4px; }
21
+ .hint { color: #666; font-size: 11px; margin: 6px 0 0; }
22
+ </style>
23
+ </head>
24
+ <body>
25
+ <h1>Understudy recorder</h1>
26
+ <div id="status" class="status">Checking…</div>
27
+ <div id="startPane" hidden>
28
+ <label><input type="checkbox" id="signedIn">
29
+ <span>I'm signed in here
30
+ <span class="small">Not sure? Leave it — Understudy works it out when you save.</span></span>
31
+ </label>
32
+ <label id="saveOnStopRow"><input type="checkbox" id="saveOnStop" checked>
33
+ <span>Save as a flow when I stop
34
+ <span class="small">Understudy replays it to check it works, then keeps it.</span></span>
35
+ </label>
36
+ <button id="start">Record from this page</button>
37
+ </div>
38
+ <div id="stopPane" hidden>
39
+ <div id="nameRow" hidden>
40
+ <label class="field" for="flowName">What does this flow do?</label>
41
+ <input type="text" id="flowName" placeholder="e.g. log in and add to cart">
42
+ </div>
43
+ <button id="stop">Stop</button>
44
+ <p class="hint" id="stopHint"></p>
45
+ </div>
46
+ <details>
47
+ <summary class="small">Settings</summary>
48
+ <label>Port <input type="number" id="port" min="1" max="65535"></label>
49
+ </details>
50
+ <script src="popup.js"></script>
51
+ </body>
52
+ </html>
@@ -0,0 +1,106 @@
1
+ // Understudy recorder — popup. Shows whether `understudy record <app>`
2
+ // is waiting, and starts or stops recording on the current tab.
3
+
4
+ const $ = (id) => document.getElementById(id);
5
+ const send = (msg) => chrome.runtime.sendMessage(msg);
6
+
7
+ function show(text, kind = '') {
8
+ $('status').textContent = text;
9
+ $('status').className = `status ${kind}`;
10
+ }
11
+
12
+ // The tab this popup was opened on. Looked up as soon as the popup opens,
13
+ // because Firefox only lets an extension ask for a site's permission straight
14
+ // from the click — with no waiting on anything first.
15
+ let here;
16
+ chrome.tabs.query({ active: true, currentWindow: true }).then(([tab]) => { here = tab; });
17
+
18
+ async function refresh() {
19
+ const { port = 7397 } = await chrome.storage.local.get('port');
20
+ $('port').value = port;
21
+ const s = await send({ type: 'understudy:status' });
22
+ $('startPane').hidden = true;
23
+ $('stopPane').hidden = true;
24
+ if (s.rec) {
25
+ show(s.cli?.error
26
+ ? 'The terminal that was recording has stopped, so this recording can\'t be saved. Click Stop to clear it.'
27
+ : `Recording "${s.rec.app}". Use the page as normal, then stop here.`, s.cli?.error ? 'err' : 'rec');
28
+ $('stopPane').hidden = false;
29
+ // Saving here only when it was asked for — and never when an agent started
30
+ // the recording: then the agent saves it.
31
+ const saving = s.rec.save && s.rec.savedBy !== 'agent' && !s.cli?.error;
32
+ $('nameRow').hidden = !saving;
33
+ $('stop').textContent = saving ? 'Stop and save as a flow' : 'Stop';
34
+ $('stopHint').textContent = s.rec.savedBy === 'agent' ? 'Your agent will save it.' : saving ? '' : 'The recording is kept; save it as a flow from the terminal.';
35
+ if (saving) $('flowName').focus();
36
+ } else if (s.lastError) {
37
+ show(`Couldn't start recording: ${s.lastError}`, 'err');
38
+ if (!s.cli?.error && !s.cli?.started) $('startPane').hidden = false;
39
+ } else if (s.cli?.error) {
40
+ show(s.cli.error, 'err');
41
+ } else if (s.cli?.started) {
42
+ show('That recording already ran. Run `understudy record <app>` again.', 'err');
43
+ } else {
44
+ show(`Ready to record "${s.cli.app}".`);
45
+ $('startPane').hidden = false;
46
+ $('saveOnStopRow').hidden = s.cli.savedBy === 'agent';
47
+ }
48
+ }
49
+
50
+ $('start').addEventListener('click', async () => {
51
+ const tab = here;
52
+ // Clicking the toolbar icon grants activeTab, which is what lets the popup
53
+ // see this tab's address — browsers hide it from extensions otherwise.
54
+ if (!tab?.url) return show('Couldn\'t read this tab\'s address — close this popup and click the Understudy icon again.', 'err');
55
+ if (!/^https?:/.test(tab.url)) return show('This page can\'t be recorded (only http and https pages).', 'err');
56
+ const site = new URL(tab.url).origin;
57
+ const signedIn = $('signedIn').checked;
58
+ const save = $('saveOnStop').checked;
59
+ $('start').disabled = true;
60
+
61
+ // Per-site access, asked for now — while you're clicking — rather than for
62
+ // every site at install; already allowed, it answers yes without asking. If it
63
+ // does ask, the browser may close this popup, so leave a note first: the
64
+ // background worker starts recording the moment you allow it. Nothing is
65
+ // awaited before the request — Firefox refuses one that isn't straight from the click.
66
+ chrome.storage.session.set({ pending: { tabId: tab.id, origin: site, signedIn, save, at: Date.now() } });
67
+ const allowed = await chrome.permissions.request({ origins: [`${site}/*`] }).catch(() => false);
68
+ await chrome.storage.session.remove('pending');
69
+ if (!allowed) {
70
+ $('start').disabled = false;
71
+ return show('Understudy needs access to this site to record it.', 'err');
72
+ }
73
+
74
+ const r = await send({ type: 'understudy:start', tabId: tab.id, signedIn, save });
75
+ $('start').disabled = false;
76
+ if (!r.ok && !/Already recording/.test(r.error)) return show(r.error, 'err');
77
+ window.close();
78
+ });
79
+
80
+ $('stop').addEventListener('click', async () => {
81
+ const saving = !$('nameRow').hidden;
82
+ const name = $('flowName').value.trim();
83
+ if (saving && !name) {
84
+ $('flowName').focus();
85
+ return show('Say what the flow does, so it can be found later.', 'err');
86
+ }
87
+ $('stop').disabled = true;
88
+ const r = await send({ type: 'understudy:stop', ...(saving ? { name } : {}) });
89
+ $('stop').disabled = false;
90
+ if (!r.ok) return show(r.error, 'err');
91
+ $('stopPane').hidden = true;
92
+ if (r.saving) show(`Recorded ${r.events ?? 0} steps. Now checking it works — the terminal shows the result.`);
93
+ else if (r.savedBy === 'agent') show(`Recorded ${r.events ?? 0} steps. Your agent will save it.`);
94
+ else show(`Recorded ${r.events ?? 0} steps. To keep it as a flow, run in the terminal:\nunderstudy save ${r.hash} "<what it does>"`);
95
+ });
96
+
97
+ $('flowName').addEventListener('keydown', (e) => {
98
+ if (e.key === 'Enter') $('stop').click();
99
+ });
100
+
101
+ $('port').addEventListener('change', async () => {
102
+ await chrome.storage.local.set({ port: Number($('port').value) || 7397 });
103
+ refresh();
104
+ });
105
+
106
+ refresh();