-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathfind-snippets-v2.ts
More file actions
175 lines (148 loc) · 5.3 KB
/
find-snippets-v2.ts
File metadata and controls
175 lines (148 loc) · 5.3 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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
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 settings._cache
const cacheResult = await conn.Runtime.evaluate({
expression: `
(() => {
const ga = window.GoogleAccount;
if (!ga?.settings?._cache) return { error: "no _cache" };
const cache = ga.settings._cache;
const keys = Object.keys(cache);
// Find snippet-related keys
const snippetKeys = keys.filter(k =>
k.toLowerCase().includes('snippet') ||
k.toLowerCase().includes('phrase') ||
k.toLowerCase().includes('template')
);
// Get preview of snippet data
const snippetData = {};
for (const k of snippetKeys) {
snippetData[k] = {
type: typeof cache[k],
isArray: Array.isArray(cache[k]),
preview: JSON.stringify(cache[k])?.slice(0, 1000)
};
}
return {
totalCacheKeys: keys.length,
allKeys: keys,
snippetKeys,
snippetData
};
})()
`,
returnByValue: true,
});
console.log("=== Settings Cache ===\n");
console.log(JSON.stringify(cacheResult.result.value, null, 2));
// Check miscSettings specifically
const miscResult = await conn.Runtime.evaluate({
expression: `
(() => {
const ga = window.GoogleAccount;
const user = ga?.threads?.onDisk?.user;
if (!user?._miscSettings) return { error: "no _miscSettings" };
const misc = user._miscSettings;
return {
type: typeof misc,
keys: Object.keys(misc),
hasSnippets: JSON.stringify(misc).toLowerCase().includes('snippet'),
preview: JSON.stringify(misc).slice(0, 2000)
};
})()
`,
returnByValue: true,
});
console.log("\n=== Misc Settings ===\n");
console.log(JSON.stringify(miscResult.result.value, null, 2));
// Search globally for "snippet" in window properties
const globalSearch = await conn.Runtime.evaluate({
expression: `
(() => {
const found = [];
// Check window properties
for (const key of Object.getOwnPropertyNames(window)) {
try {
const val = window[key];
if (typeof val === 'object' && val !== null && key !== 'window') {
const str = JSON.stringify(val);
if (str && str.toLowerCase().includes('"snippet"') && str.length < 50000) {
found.push({
location: 'window.' + key,
preview: str.slice(0, 500)
});
}
}
} catch (e) {
// Skip inaccessible properties
}
}
return found.slice(0, 10);
})()
`,
returnByValue: true,
});
console.log("\n=== Global Window Search for 'snippet' ===\n");
console.log(JSON.stringify(globalSearch.result.value, null, 2));
// Try accessing OnDisk class/prototype
const onDiskProto = await conn.Runtime.evaluate({
expression: `
(() => {
const ga = window.GoogleAccount;
const onDisk = ga?.threads?.onDisk;
if (!onDisk) return { error: "no onDisk" };
const proto = Object.getPrototypeOf(onDisk);
const protoKeys = Object.getOwnPropertyNames(proto);
const snippetKeys = protoKeys.filter(k => k.toLowerCase().includes('snippet'));
// Also check instance properties
const instanceKeys = Object.keys(onDisk);
const instanceSnippetKeys = instanceKeys.filter(k => k.toLowerCase().includes('snippet'));
return {
protoSnippetKeys: snippetKeys,
instanceSnippetKeys: instanceSnippetKeys,
allInstanceKeys: instanceKeys.slice(0, 30)
};
})()
`,
returnByValue: true,
});
console.log("\n=== OnDisk Object Keys ===\n");
console.log(JSON.stringify(onDiskProto.result.value, null, 2));
// Check for snippets in compose form controller props
const composePropsResult = await conn.Runtime.evaluate({
expression: `
(() => {
const vs = window.ViewState;
const cfc = vs?._composeFormController;
if (!cfc) return { error: "no _composeFormController" };
const draftKey = Object.keys(cfc)[0];
const ctrl = cfc[draftKey];
if (!ctrl) return { error: "no controller" };
const propsKeys = ctrl.props ? Object.keys(ctrl.props) : [];
const snippetRelated = propsKeys.filter(k =>
k.toLowerCase().includes('snippet') ||
k.toLowerCase().includes('phrase')
);
// Check account props
const accountKeys = ctrl.props?.account ? Object.keys(ctrl.props.account) : [];
const accountSnippetKeys = accountKeys.filter(k =>
k.toLowerCase().includes('snippet') ||
k.toLowerCase().includes('phrase')
);
return {
propsKeys: propsKeys,
snippetRelated,
accountKeys: accountKeys.slice(0, 30),
accountSnippetKeys
};
})()
`,
returnByValue: true,
});
console.log("\n=== Compose Controller Props ===\n");
console.log(JSON.stringify(composePropsResult.result.value, null, 2));
await disconnect(conn);
}
main().catch(console.error);