-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathfind-isabelle.ts
More file actions
69 lines (61 loc) · 2.36 KB
/
find-isabelle.ts
File metadata and controls
69 lines (61 loc) · 2.36 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
import { connectToSuperhuman, disconnect } from "./src/superhuman-api";
async function findIsabelle() {
const conn = await connectToSuperhuman(9333, true);
if (!conn) return;
const result = await conn.Runtime.evaluate({
expression: `
(async () => {
try {
const ga = window.GoogleAccount;
const identityMap = ga?.threads?.identityMap;
if (!identityMap) return { error: "No identityMap" };
const results = [];
// Helper to check for Isabelle
const check = (r, modelId, subject) => {
if (!r) return;
const name = r.name || r.displayName || r.fullName || '';
const email = r.email || '';
if (name.toLowerCase().includes('isabelle') || email.toLowerCase().includes('isabelle')) {
results.push({ name, email, threadId: modelId, subject });
}
};
// Iterate over identityMap
// If it's a Map
if (typeof identityMap.forEach === 'function') {
identityMap.forEach((thread, id) => {
const model = thread?._threadModel;
if (!model) return;
const messages = model.messages || [];
messages.forEach(msg => {
check(msg.from, model.id, model.subject);
(msg.to || []).forEach(r => check(r, model.id, model.subject));
(msg.cc || []).forEach(r => check(r, model.id, model.subject));
});
});
} else {
// If it's a plain object
for (const key in identityMap) {
const thread = identityMap[key];
const model = thread?._threadModel;
if (!model) continue;
const messages = model.messages || [];
for (const msg of messages) {
check(msg.from, model.id, model.subject);
(msg.to || []).forEach(r => check(r, model.id, model.subject));
(msg.cc || []).forEach(r => check(r, model.id, model.subject));
}
}
}
return results;
} catch (e) {
return { error: e.message };
}
})()
`,
returnByValue: true,
awaitPromise: true
});
console.log(JSON.stringify(result.result.value, null, 2));
await disconnect(conn);
}
findIsabelle().catch(console.error);