glidercli 0.4.18 → 0.4.31
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.
- package/README.md +18 -6
- package/bin/glider.js +388 -71
- package/docs/setup.json +6 -2
- package/docs/tab-identity.scorched.json +2042 -0
- package/lib/bexplore.js +6 -5
- package/lib/bfavicon.js +3 -2
- package/lib/bwindow.js +8 -6
- package/lib/cdp-direct.js +1 -1
- package/lib/cookie-jar.js +233 -0
- package/lib/paths.js +48 -0
- package/lib/tab-catalog.js +67 -10
- package/lib/tab-map.js +282 -0
- package/lib/tab-tui.js +179 -0
- package/package.json +3 -3
package/lib/bexplore.js
CHANGED
|
@@ -12,6 +12,7 @@ const fs = require('fs');
|
|
|
12
12
|
const path = require('path');
|
|
13
13
|
const http = require('http');
|
|
14
14
|
const { relayHttpUrl, relayWebSocketUrl } = require('./relay-config.js');
|
|
15
|
+
const { capturesDir } = require('./paths.js');
|
|
15
16
|
|
|
16
17
|
const RELAY_URL = relayWebSocketUrl();
|
|
17
18
|
const RELAY_HTTP = relayHttpUrl();
|
|
@@ -131,7 +132,7 @@ class SiteExplorer {
|
|
|
131
132
|
this.toVisit = [];
|
|
132
133
|
// 0 = passive (reload/HAR/screenshots, zero clicks). Any other value = full live-DOM flay.
|
|
133
134
|
this.depth = options.depth === 0 ? 0 : Infinity;
|
|
134
|
-
this.outputDir = options.outputDir || '
|
|
135
|
+
this.outputDir = options.outputDir || capturesDir('explore');
|
|
135
136
|
this.harFile = options.harFile;
|
|
136
137
|
this.wantedSessionId = options.sessionId || null;
|
|
137
138
|
this.sessionResolved = null;
|
|
@@ -1199,7 +1200,7 @@ Usage:
|
|
|
1199
1200
|
|
|
1200
1201
|
Options:
|
|
1201
1202
|
--depth 0 Passive only (reload, discover, screenshots, HAR). Omit for full live-DOM flay.
|
|
1202
|
-
--output DIR Output directory (default: /
|
|
1203
|
+
--output DIR Output directory (default: $GLIDER/captures/explore)
|
|
1203
1204
|
--har FILE Save HAR file
|
|
1204
1205
|
--session-id ID CDP session (e.g. session-6 from GET /targets)
|
|
1205
1206
|
--workers N Extra tabs (default 1 = pinned session only). Hard cap ${HYDRA_WIDTH}.
|
|
@@ -1219,15 +1220,15 @@ The tool will:
|
|
|
1219
1220
|
8. Generate a comprehensive report
|
|
1220
1221
|
|
|
1221
1222
|
Examples:
|
|
1222
|
-
node bexplore.js --depth 0 --output
|
|
1223
|
-
node bexplore.js --output
|
|
1223
|
+
node bexplore.js --depth 0 --output ./passive --har ./passive.har --session-id session-3
|
|
1224
|
+
node bexplore.js --output ./sage-explore --har ./sage.har
|
|
1224
1225
|
node bexplore.js --depth 5 --output ~/explore-results
|
|
1225
1226
|
`);
|
|
1226
1227
|
process.exit(0);
|
|
1227
1228
|
}
|
|
1228
1229
|
|
|
1229
1230
|
let depth = Infinity;
|
|
1230
|
-
let outputDir = '
|
|
1231
|
+
let outputDir = capturesDir('explore');
|
|
1231
1232
|
let harFile = null;
|
|
1232
1233
|
let sessionId = null;
|
|
1233
1234
|
let workers = 1;
|
package/lib/bfavicon.js
CHANGED
|
@@ -10,6 +10,7 @@ const WebSocket = require('ws');
|
|
|
10
10
|
const fs = require('fs');
|
|
11
11
|
const { execSync } = require('child_process');
|
|
12
12
|
const { relayWebSocketUrl } = require('./relay-config.js');
|
|
13
|
+
const { capturesDir, scratchDir } = require('./paths.js');
|
|
13
14
|
|
|
14
15
|
const RELAY_URL = relayWebSocketUrl();
|
|
15
16
|
|
|
@@ -190,12 +191,12 @@ async function main() {
|
|
|
190
191
|
// Determine output path
|
|
191
192
|
if (!outputPath) {
|
|
192
193
|
const hostname = new URL(url).hostname.replace(/^www\./, '').split('.')[0];
|
|
193
|
-
outputPath =
|
|
194
|
+
outputPath = require('path').join(capturesDir(), `${hostname}-favicon.png`);
|
|
194
195
|
}
|
|
195
196
|
|
|
196
197
|
// Save the file
|
|
197
198
|
const buffer = Buffer.from(favicon.base64, 'base64');
|
|
198
|
-
const tempFile =
|
|
199
|
+
const tempFile = require('path').join(scratchDir(), `favicon-temp-${Date.now()}`);
|
|
199
200
|
|
|
200
201
|
// Detect format and save appropriately
|
|
201
202
|
const isIco = favicon.type.includes('icon') || favicon.url.endsWith('.ico');
|
package/lib/bwindow.js
CHANGED
|
@@ -1,16 +1,18 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
/**
|
|
3
|
-
* bwindow.js -
|
|
4
|
-
*
|
|
3
|
+
* bwindow.js - CDP window control plane (create/close/focus). Not tab identity SSOT.
|
|
4
|
+
*
|
|
5
|
+
* Identity + listing: `glider tabs` / `glider window list` → tab-catalog + $GLIDER/state/tab-map.json.
|
|
6
|
+
*
|
|
5
7
|
* Commands:
|
|
6
8
|
* glider window new [url] Create new browser window
|
|
7
9
|
* glider window close <targetId> Close specific tab/window
|
|
8
10
|
* glider window closeall Close all tabs created by Glider
|
|
9
|
-
* glider window list
|
|
11
|
+
* glider window list Same catalog/TUI as glider tabs (bin/glider.js)
|
|
10
12
|
* glider window focus <targetId> Bring tab to foreground
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
* Tabs created in the main window CANNOT be closed (Chrome security)
|
|
13
|
+
*
|
|
14
|
+
* Tabs created with newWindow:true CAN be closed via Target.closeTarget.
|
|
15
|
+
* Tabs created in the main window CANNOT be closed (Chrome security).
|
|
14
16
|
*/
|
|
15
17
|
|
|
16
18
|
const WebSocket = require('ws');
|
package/lib/cdp-direct.js
CHANGED
|
@@ -287,7 +287,7 @@ if (require.main === module) {
|
|
|
287
287
|
break;
|
|
288
288
|
case 'screenshot':
|
|
289
289
|
const ss = await cdp.screenshot();
|
|
290
|
-
const path = arg ||
|
|
290
|
+
const path = arg || require('path').join(require('./paths.js').capturesDir(), `screenshot-${Date.now()}.png`);
|
|
291
291
|
require('fs').writeFileSync(path, Buffer.from(ss.data, 'base64'));
|
|
292
292
|
console.log('Screenshot saved:', path);
|
|
293
293
|
break;
|
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const fs = require('fs');
|
|
4
|
+
const path = require('path');
|
|
5
|
+
const { cookiesDirRoot, cookiesDomainsFile, warchScanRoots } = require('./paths.js');
|
|
6
|
+
|
|
7
|
+
function stripAnsi(s) {
|
|
8
|
+
return String(s).replace(/\x1b\[[0-9;]*m/g, '');
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
function parseHeaderLine(raw) {
|
|
12
|
+
if (raw == null || raw === '') return '';
|
|
13
|
+
for (const line of String(raw).split(/\r?\n/)) {
|
|
14
|
+
let clean = stripAnsi(line).trimStart();
|
|
15
|
+
if (clean.startsWith('Cookie:')) clean = clean.slice('Cookie:'.length).trimStart();
|
|
16
|
+
if (clean && clean.includes('=')) return clean;
|
|
17
|
+
}
|
|
18
|
+
return '';
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function domainDir(domain) {
|
|
22
|
+
return path.join(cookiesDirRoot(), domain);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function ensureJarRoot() {
|
|
26
|
+
fs.mkdirSync(cookiesDirRoot(), { recursive: true });
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function loadDomainsFile() {
|
|
30
|
+
ensureJarRoot();
|
|
31
|
+
const p = cookiesDomainsFile();
|
|
32
|
+
if (!fs.existsSync(p)) return null;
|
|
33
|
+
return JSON.parse(fs.readFileSync(p, 'utf8'));
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function saveDomains(domains) {
|
|
37
|
+
ensureJarRoot();
|
|
38
|
+
const sorted = [...new Set(domains)].sort();
|
|
39
|
+
fs.writeFileSync(cookiesDomainsFile(), `${JSON.stringify({ domains: sorted }, null, 2)}\n`);
|
|
40
|
+
return sorted;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function listDomainNames() {
|
|
44
|
+
const data = loadDomainsFile();
|
|
45
|
+
if (data && Array.isArray(data.domains)) return data.domains;
|
|
46
|
+
rebuildDomains();
|
|
47
|
+
const again = loadDomainsFile();
|
|
48
|
+
return again && Array.isArray(again.domains) ? again.domains : [];
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function walkGliderJson(root) {
|
|
52
|
+
const out = [];
|
|
53
|
+
if (!root || !fs.existsSync(root)) return out;
|
|
54
|
+
const stack = [root];
|
|
55
|
+
while (stack.length) {
|
|
56
|
+
const dir = stack.pop();
|
|
57
|
+
let entries;
|
|
58
|
+
try {
|
|
59
|
+
entries = fs.readdirSync(dir, { withFileTypes: true });
|
|
60
|
+
} catch {
|
|
61
|
+
continue;
|
|
62
|
+
}
|
|
63
|
+
for (const ent of entries) {
|
|
64
|
+
const full = path.join(dir, ent.name);
|
|
65
|
+
if (ent.isDirectory()) stack.push(full);
|
|
66
|
+
else if (ent.isFile() && ent.name === 'glider.json') out.push(full);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
return out.sort();
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
function rebuildDomains() {
|
|
73
|
+
ensureJarRoot();
|
|
74
|
+
const domains = [];
|
|
75
|
+
for (const root of warchScanRoots()) {
|
|
76
|
+
for (const gj of walkGliderJson(root)) {
|
|
77
|
+
try {
|
|
78
|
+
const data = JSON.parse(fs.readFileSync(gj, 'utf8'));
|
|
79
|
+
const jar = data.cookie_jar || {};
|
|
80
|
+
if (jar.enabled && data.host) domains.push(data.host);
|
|
81
|
+
} catch {
|
|
82
|
+
/* skip */
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
let existing = [];
|
|
87
|
+
try {
|
|
88
|
+
const cur = loadDomainsFile();
|
|
89
|
+
if (cur && Array.isArray(cur.domains)) existing = cur.domains;
|
|
90
|
+
} catch {
|
|
91
|
+
/* fresh */
|
|
92
|
+
}
|
|
93
|
+
for (const d of existing) {
|
|
94
|
+
if (!domains.includes(d)) domains.push(d);
|
|
95
|
+
}
|
|
96
|
+
const sorted = saveDomains(domains);
|
|
97
|
+
return { path: cookiesDomainsFile(), count: sorted.length };
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
function writeMeta(domain, headerLine) {
|
|
101
|
+
const count = headerLine.split(';').filter((p) => p.trim()).length;
|
|
102
|
+
const now = Math.floor(Date.now() / 1000);
|
|
103
|
+
const meta = {
|
|
104
|
+
domain,
|
|
105
|
+
synced_at: now,
|
|
106
|
+
synced_iso: new Date(now * 1000).toISOString().replace(/\.\d{3}Z$/, 'Z'),
|
|
107
|
+
cookie_count: count,
|
|
108
|
+
stale: false,
|
|
109
|
+
};
|
|
110
|
+
fs.writeFileSync(path.join(domainDir(domain), 'meta.json'), `${JSON.stringify(meta, null, 2)}\n`);
|
|
111
|
+
return count;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
function markStale(domain) {
|
|
115
|
+
const metaPath = path.join(domainDir(domain), 'meta.json');
|
|
116
|
+
if (!fs.existsSync(metaPath)) return;
|
|
117
|
+
const m = JSON.parse(fs.readFileSync(metaPath, 'utf8'));
|
|
118
|
+
m.stale = true;
|
|
119
|
+
m.stale_since = Math.floor(Date.now() / 1000);
|
|
120
|
+
fs.writeFileSync(metaPath, `${JSON.stringify(m, null, 2)}\n`);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
async function syncOne(domain, fetchLive) {
|
|
124
|
+
fs.mkdirSync(domainDir(domain), { recursive: true });
|
|
125
|
+
let hdr = '';
|
|
126
|
+
if (fetchLive) {
|
|
127
|
+
try {
|
|
128
|
+
hdr = parseHeaderLine(await fetchLive(domain));
|
|
129
|
+
} catch {
|
|
130
|
+
hdr = '';
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
if (!hdr) {
|
|
134
|
+
markStale(domain);
|
|
135
|
+
const err = new Error(`${domain}: no cookies in response (extension down or not logged in)`);
|
|
136
|
+
err.code = 'SYNC_EMPTY';
|
|
137
|
+
throw err;
|
|
138
|
+
}
|
|
139
|
+
fs.writeFileSync(path.join(domainDir(domain), 'header.txt'), hdr);
|
|
140
|
+
const count = writeMeta(domain, hdr);
|
|
141
|
+
return { domain, count };
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
async function syncAll(fetchLive) {
|
|
145
|
+
const names = listDomainNames();
|
|
146
|
+
let ok = 0;
|
|
147
|
+
let fail = 0;
|
|
148
|
+
for (const d of names) {
|
|
149
|
+
try {
|
|
150
|
+
await syncOne(d, fetchLive);
|
|
151
|
+
ok += 1;
|
|
152
|
+
} catch {
|
|
153
|
+
fail += 1;
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
return { ok, fail };
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
async function readDomain(domain, fetchLive, warn) {
|
|
160
|
+
if (fetchLive) {
|
|
161
|
+
try {
|
|
162
|
+
const hdr = parseHeaderLine(await fetchLive(domain));
|
|
163
|
+
if (hdr) return hdr;
|
|
164
|
+
} catch {
|
|
165
|
+
/* fall through */
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
const jar = path.join(domainDir(domain), 'header.txt');
|
|
169
|
+
if (fs.existsSync(jar)) {
|
|
170
|
+
const metaPath = path.join(domainDir(domain), 'meta.json');
|
|
171
|
+
if (fs.existsSync(metaPath) && typeof warn === 'function') {
|
|
172
|
+
const m = JSON.parse(fs.readFileSync(metaPath, 'utf8'));
|
|
173
|
+
const age = Math.floor(Date.now() / 1000) - m.synced_at;
|
|
174
|
+
warn(`using jar (${age}s old)`);
|
|
175
|
+
}
|
|
176
|
+
return fs.readFileSync(jar, 'utf8').trim();
|
|
177
|
+
}
|
|
178
|
+
const err = new Error(`no live cookies and no jar for ${domain}`);
|
|
179
|
+
err.code = 'READ_MISS';
|
|
180
|
+
throw err;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
function ageDomain(domain) {
|
|
184
|
+
const metaPath = path.join(domainDir(domain), 'meta.json');
|
|
185
|
+
if (!fs.existsSync(metaPath)) return '';
|
|
186
|
+
const m = JSON.parse(fs.readFileSync(metaPath, 'utf8'));
|
|
187
|
+
return String(Math.floor(Date.now() / 1000) - m.synced_at);
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
function listJars() {
|
|
191
|
+
listDomainNames();
|
|
192
|
+
const rows = [];
|
|
193
|
+
for (const d of listDomainNames()) {
|
|
194
|
+
const metaPath = path.join(domainDir(d), 'meta.json');
|
|
195
|
+
if (fs.existsSync(metaPath)) {
|
|
196
|
+
const m = JSON.parse(fs.readFileSync(metaPath, 'utf8'));
|
|
197
|
+
const age = Math.floor(Date.now() / 1000) - m.synced_at;
|
|
198
|
+
rows.push({ domain: d, age: String(age), stale: m.stale ? 'yes' : 'no' });
|
|
199
|
+
} else {
|
|
200
|
+
rows.push({ domain: d, age: 'never', stale: '-' });
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
return rows;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
function addDomain(domain) {
|
|
207
|
+
const names = listDomainNames();
|
|
208
|
+
if (names.includes(domain)) return { added: false, domain };
|
|
209
|
+
names.push(domain);
|
|
210
|
+
saveDomains(names);
|
|
211
|
+
return { added: true, domain };
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
function rmDomain(domain) {
|
|
215
|
+
const names = listDomainNames();
|
|
216
|
+
if (!names.includes(domain)) return { removed: false, domain };
|
|
217
|
+
saveDomains(names.filter((d) => d !== domain));
|
|
218
|
+
return { removed: true, domain };
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
module.exports = {
|
|
222
|
+
parseHeaderLine,
|
|
223
|
+
rebuildDomains,
|
|
224
|
+
syncOne,
|
|
225
|
+
syncAll,
|
|
226
|
+
readDomain,
|
|
227
|
+
ageDomain,
|
|
228
|
+
listJars,
|
|
229
|
+
addDomain,
|
|
230
|
+
rmDomain,
|
|
231
|
+
listDomainNames,
|
|
232
|
+
domainDir,
|
|
233
|
+
};
|
package/lib/paths.js
CHANGED
|
@@ -8,6 +8,26 @@ function gliderHome() {
|
|
|
8
8
|
return process.env.GLIDER || path.join(os.homedir(), '.glider');
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
+
function ensureDir(dir) {
|
|
12
|
+
require('fs').mkdirSync(dir, { recursive: true });
|
|
13
|
+
return dir;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/** Ephemeral runtime state (loop state, etc.): $GLIDER/state. */
|
|
17
|
+
function stateDir() {
|
|
18
|
+
return ensureDir(path.join(gliderHome(), 'state'));
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/** Default output for screenshots/pdf/har/favicons/explore: $GLIDER/captures[/sub]. */
|
|
22
|
+
function capturesDir(sub) {
|
|
23
|
+
return ensureDir(sub ? path.join(gliderHome(), 'captures', sub) : path.join(gliderHome(), 'captures'));
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/** Scratch files deleted after use: $GLIDER/tmp. */
|
|
27
|
+
function scratchDir() {
|
|
28
|
+
return ensureDir(path.join(gliderHome(), 'tmp'));
|
|
29
|
+
}
|
|
30
|
+
|
|
11
31
|
/** Installed package root (glidercli npm tree). */
|
|
12
32
|
function packageRoot() {
|
|
13
33
|
return path.join(__dirname, '..');
|
|
@@ -35,6 +55,28 @@ function warchRoot() {
|
|
|
35
55
|
return path.join(registryBase(), 'warch');
|
|
36
56
|
}
|
|
37
57
|
|
|
58
|
+
/** Persistent cookie snapshots: $GLIDER/cookies. */
|
|
59
|
+
function cookiesDirRoot() {
|
|
60
|
+
return path.join(gliderHome(), 'cookies');
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
function cookiesDomainsFile() {
|
|
64
|
+
return path.join(cookiesDirRoot(), 'domains.json');
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/** Warch trees scanned for cookie_jar.enabled ($GLIDER/warch plus optional GLIDER_EXTRA_WARCH_ROOT). */
|
|
68
|
+
function warchScanRoots() {
|
|
69
|
+
const roots = [warchRoot()];
|
|
70
|
+
const extra = process.env.GLIDER_EXTRA_WARCH_ROOT;
|
|
71
|
+
if (extra) {
|
|
72
|
+
for (const raw of extra.split(path.delimiter)) {
|
|
73
|
+
const p = raw.trim();
|
|
74
|
+
if (p) roots.push(expandUser(p));
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
return [...new Set(roots)];
|
|
78
|
+
}
|
|
79
|
+
|
|
38
80
|
function domainsTemplatePath() {
|
|
39
81
|
return path.join(packageRoot(), 'config', 'domains.template.json');
|
|
40
82
|
}
|
|
@@ -63,11 +105,17 @@ function warchDirForHost(host, domainsIndex) {
|
|
|
63
105
|
|
|
64
106
|
module.exports = {
|
|
65
107
|
gliderHome,
|
|
108
|
+
stateDir,
|
|
109
|
+
capturesDir,
|
|
110
|
+
scratchDir,
|
|
66
111
|
packageRoot,
|
|
67
112
|
registryBase,
|
|
68
113
|
registryMode,
|
|
69
114
|
configPath,
|
|
70
115
|
warchRoot,
|
|
116
|
+
cookiesDirRoot,
|
|
117
|
+
cookiesDomainsFile,
|
|
118
|
+
warchScanRoots,
|
|
71
119
|
domainsTemplatePath,
|
|
72
120
|
expandUser,
|
|
73
121
|
warchDirForHost,
|
package/lib/tab-catalog.js
CHANGED
|
@@ -22,12 +22,17 @@ function windowIncognito(chromeWindows, wid, tabsInWindow) {
|
|
|
22
22
|
return { incognito: false, incognitoSource: '' };
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
+
function ti(page) {
|
|
26
|
+
return (page && page.targetInfo && typeof page.targetInfo === 'object') ? page.targetInfo : {};
|
|
27
|
+
}
|
|
28
|
+
|
|
25
29
|
function chromeRow(tab, page, win) {
|
|
26
30
|
const fromTab = !!tab.incognito;
|
|
27
31
|
const incognito = win.incognito || fromTab;
|
|
28
32
|
const incognitoSource = win.incognito
|
|
29
33
|
? win.incognitoSource
|
|
30
34
|
: (fromTab ? 'chrome.tabs' : '');
|
|
35
|
+
const info = ti(page);
|
|
31
36
|
return {
|
|
32
37
|
tabId: tab.id,
|
|
33
38
|
windowId: tab.windowId,
|
|
@@ -37,12 +42,61 @@ function chromeRow(tab, page, win) {
|
|
|
37
42
|
active: !!tab.active,
|
|
38
43
|
discarded: !!tab.discarded,
|
|
39
44
|
highlighted: !!tab.highlighted,
|
|
45
|
+
pinned: !!tab.pinned,
|
|
46
|
+
load: tab.status || tab.load || '',
|
|
40
47
|
incognito,
|
|
41
48
|
incognitoSource,
|
|
42
49
|
attached: Boolean(page && page.sessionId),
|
|
50
|
+
audible: !!tab.audible,
|
|
51
|
+
muted: !!(tab.muted || (tab.mutedInfo && tab.mutedInfo.muted)),
|
|
52
|
+
mutedReason: tab.mutedReason || (tab.mutedInfo && tab.mutedInfo.reason) || '',
|
|
53
|
+
mutedExtensionId: tab.mutedExtensionId || (tab.mutedInfo && tab.mutedInfo.extensionId) || '',
|
|
54
|
+
autoDiscardable: tab.autoDiscardable !== false,
|
|
55
|
+
groupId: tab.groupId == null ? '' : tab.groupId,
|
|
56
|
+
openerTabId: tab.openerTabId == null ? '' : tab.openerTabId,
|
|
57
|
+
pendingUrl: tab.pendingUrl || '',
|
|
58
|
+
favIconUrl: tab.favIconUrl || '',
|
|
59
|
+
frozen: !!tab.frozen,
|
|
60
|
+
lastAccessed: tab.lastAccessed == null ? '' : tab.lastAccessed,
|
|
61
|
+
width: tab.width == null ? '' : tab.width,
|
|
62
|
+
height: tab.height == null ? '' : tab.height,
|
|
63
|
+
chromeSessionId: tab.chromeSessionId || tab.sessionIdChrome || '',
|
|
64
|
+
successorTabId: tab.successorTabId == null ? '' : tab.successorTabId,
|
|
65
|
+
splitViewId: tab.splitViewId == null ? '' : tab.splitViewId,
|
|
66
|
+
selected: !!tab.selected,
|
|
43
67
|
sessionId: page && page.sessionId ? page.sessionId : '',
|
|
44
68
|
targetId: page && page.targetId ? page.targetId : '',
|
|
45
69
|
browserContextId: contextIdOf(page),
|
|
70
|
+
targetType: (page && (page.type || info.type)) || '',
|
|
71
|
+
subtype: info.subtype || '',
|
|
72
|
+
openerId: info.openerId || (page && page.openerId) || '',
|
|
73
|
+
openerFrameId: info.openerFrameId || (page && page.parentFrameId) || '',
|
|
74
|
+
canAccessOpener: info.canAccessOpener,
|
|
75
|
+
parent_sessionId: (page && page.parent_sessionId) || '',
|
|
76
|
+
parent_targetId: (page && (page.parent_targetId || page.parentFrameId)) || '',
|
|
77
|
+
parentFrameId: (page && page.parentFrameId) || '',
|
|
78
|
+
cdpAttached: info.attached,
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
function cdpRow(p, extra) {
|
|
83
|
+
const info = ti(p);
|
|
84
|
+
return {
|
|
85
|
+
tabId: p.tabId || 0,
|
|
86
|
+
sessionId: p.sessionId || '',
|
|
87
|
+
targetId: p.targetId || '',
|
|
88
|
+
title: p.title || '',
|
|
89
|
+
url: p.url || '',
|
|
90
|
+
type: p.type || info.type || '',
|
|
91
|
+
targetType: p.type || info.type || '',
|
|
92
|
+
subtype: info.subtype || '',
|
|
93
|
+
browserContextId: contextIdOf(p),
|
|
94
|
+
openerId: info.openerId || '',
|
|
95
|
+
openerFrameId: info.openerFrameId || p.parentFrameId || '',
|
|
96
|
+
parent_sessionId: p.parent_sessionId || '',
|
|
97
|
+
parent_targetId: p.parent_targetId || p.parentFrameId || '',
|
|
98
|
+
parentFrameId: p.parentFrameId || '',
|
|
99
|
+
...extra,
|
|
46
100
|
};
|
|
47
101
|
}
|
|
48
102
|
|
|
@@ -80,11 +134,21 @@ function buildCatalog({ chromeTabs, chromeWindows, cdpPages, focusedWindowId, li
|
|
|
80
134
|
wid,
|
|
81
135
|
tabs.filter((t) => t.windowId === wid),
|
|
82
136
|
);
|
|
137
|
+
const meta = (chromeWindows || []).find((w) => (w.windowId ?? w.id) === wid) || {};
|
|
83
138
|
windowMap.set(wid, {
|
|
84
139
|
windowId: wid,
|
|
85
140
|
current: focusedWindowId != null && wid === focusedWindowId,
|
|
141
|
+
focused: !!meta.focused,
|
|
86
142
|
incognito: win.incognito,
|
|
87
143
|
incognitoSource: win.incognitoSource,
|
|
144
|
+
type: meta.type || '',
|
|
145
|
+
state: meta.state || '',
|
|
146
|
+
alwaysOnTop: !!meta.alwaysOnTop,
|
|
147
|
+
width: meta.width == null ? '' : meta.width,
|
|
148
|
+
height: meta.height == null ? '' : meta.height,
|
|
149
|
+
left: meta.left == null ? '' : meta.left,
|
|
150
|
+
top: meta.top == null ? '' : meta.top,
|
|
151
|
+
chromeSessionId: meta.chromeSessionId || meta.sessionId || '',
|
|
88
152
|
tabs: [],
|
|
89
153
|
});
|
|
90
154
|
}
|
|
@@ -107,15 +171,7 @@ function buildCatalog({ chromeTabs, chromeWindows, cdpPages, focusedWindowId, li
|
|
|
107
171
|
const ok = listTabsOk === true;
|
|
108
172
|
for (const p of enriched) {
|
|
109
173
|
if (matched.has(p.sessionId)) continue;
|
|
110
|
-
const row =
|
|
111
|
-
tabId: p.tabId || 0,
|
|
112
|
-
sessionId: p.sessionId,
|
|
113
|
-
targetId: p.targetId,
|
|
114
|
-
title: p.title || '',
|
|
115
|
-
url: p.url || '',
|
|
116
|
-
type: p.type,
|
|
117
|
-
browserContextId: contextIdOf(p),
|
|
118
|
-
};
|
|
174
|
+
const row = cdpRow(p);
|
|
119
175
|
if (ok && p.tabId && !chromeIds.has(p.tabId)) {
|
|
120
176
|
stale.push({ ...row, reason: 'tab_gone' });
|
|
121
177
|
} else {
|
|
@@ -130,7 +186,8 @@ function buildCatalog({ chromeTabs, chromeWindows, cdpPages, focusedWindowId, li
|
|
|
130
186
|
attached,
|
|
131
187
|
stale,
|
|
132
188
|
reapSessionIds: stale.map((s) => s.sessionId).filter(Boolean),
|
|
133
|
-
iframes: part.iframes,
|
|
189
|
+
iframes: (part.iframes || []).map((p) => cdpRow(p)),
|
|
190
|
+
other: (part.other || []).map((p) => cdpRow(p)),
|
|
134
191
|
pages: part.pages,
|
|
135
192
|
};
|
|
136
193
|
}
|