-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathcheck-shared-snippets.ts
More file actions
85 lines (73 loc) · 2.82 KB
/
check-shared-snippets.ts
File metadata and controls
85 lines (73 loc) · 2.82 KB
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
import { connectToSuperhuman, disconnect } from "./src/superhuman-api";
async function main() {
const conn = await connectToSuperhuman(9333);
if (!conn) { console.log("No connection"); process.exit(1); }
// Check if ViewState has a shared settings or if Account.accountList() can give us all accounts
const result = await conn.Runtime.evaluate({
expression: `
(async () => {
const findings = {};
// Try Account.accountList()
const Account = window.Account;
if (Account?.accountList) {
try {
const accounts = Account.accountList();
findings.accountListResult = {
count: accounts?.length,
emails: accounts?.map(a => a.emailAddress || a.email),
types: accounts?.map(a => a.constructor?.name)
};
// Check if each account has its own settings with snippets
if (accounts?.length > 0) {
findings.accountSettings = [];
for (const acc of accounts) {
const accSettings = acc.settings;
if (accSettings) {
findings.accountSettings.push({
email: acc.emailAddress,
hasSnippets: 'snippets' in (accSettings._cache || {}),
snippetsValue: accSettings.get?.('snippets')
});
}
}
}
} catch (e) {
findings.accountListError = e.message;
}
}
// Check ViewState for global/shared settings
const vs = window.ViewState;
if (vs) {
// Look for shared settings
if (vs._sharedSettings) {
findings.hasSharedSettings = true;
}
// Check if there's a global snippets store
const vsKeys = Object.keys(vs);
const snippetRelated = vsKeys.filter(k =>
k.toLowerCase().includes('snippet')
);
findings.viewStateSnippetKeys = snippetRelated;
}
// Check if there's a UserSettings singleton
if (window.UserSettings) {
findings.hasUserSettings = true;
findings.userSettingsKeys = Object.keys(window.UserSettings).slice(0, 20);
}
// Check if the current GoogleAccount's settings userId matches across potential accounts
const ga = window.GoogleAccount;
if (ga?.settings) {
findings.currentAccountUserId = ga.settings._cache?.userId;
findings.currentAccountEmail = ga.emailAddress || ga.settings.account?.emailAddress;
}
return findings;
})()
`,
awaitPromise: true,
returnByValue: true,
});
console.log("=== Shared Snippets Check ===\n");
console.log(JSON.stringify(result.result.value, null, 2));
await disconnect(conn);
}
main().catch(console.error);