-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathget-current-snippets.ts
More file actions
33 lines (27 loc) · 985 Bytes
/
get-current-snippets.ts
File metadata and controls
33 lines (27 loc) · 985 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import { connectToSuperhuman, disconnect } from "./src/superhuman-api";
async function main() {
const conn = await connectToSuperhuman(9333);
if (!conn) { console.log("No connection"); process.exit(1); }
const result = await conn.Runtime.evaluate({
expression: `
(() => {
const account = window.ViewState?.account;
const settings = account?.settings;
return {
currentEmail: account?.emailAddress,
// Get snippets from settings.get()
snippetsFromGet: settings?.get?.('snippets'),
// Get snippets from cache directly
snippetsFromCache: settings?._cache?.snippets,
// Count
snippetCount: Object.keys(settings?._cache?.snippets || {}).length
};
})()
`,
returnByValue: true,
});
console.log("=== Current Account Snippets ===\n");
console.log(JSON.stringify(result.result.value, null, 2));
await disconnect(conn);
}
main().catch(console.error);