This commit is contained in:
Cris Stringfellow 2021-12-15 22:30:22 +08:00
parent 7cfc183c0a
commit d3f065b01c
3 changed files with 13 additions and 14 deletions

View File

@ -282,8 +282,6 @@ async function collect({chrome_port:port, mode} = {}) {
if ( State.Indexing.has(info.targetId) ) return;
State.Indexing.add(info.targetId);
State.Index.set(info.url, info.title);
if ( ! sessionId ) {
sessionId = await untilHas(Sessions, info.targetId);
}
@ -292,6 +290,9 @@ async function collect({chrome_port:port, mode} = {}) {
await untilHas(Installations, sessionId);
}
const {title:latestTitle} = Targets.get(sessionId);
State.Index.set(info.url, latestTitle);
send("DOMSnapshot.enable", {}, sessionId);
await sleep(500);
@ -396,16 +397,13 @@ async function collect({chrome_port:port, mode} = {}) {
async function attachToTarget(targetInfo) {
if ( dontInstall(targetInfo) ) return;
const {url} = targetInfo;
if ( !!url && url != "about:blank" && !url.startsWith('chrome') ) {
if ( targetInfo.type == 'page' ) {
if ( ! targetInfo.attached ) {
const {sessionId} = await send("Target.attachToTarget", {
targetId: targetInfo.targetId,
flatten: true
});
Sessions.set(targetInfo.targetId, sessionId);
}
if ( url && targetInfo.type == 'page' ) {
if ( ! targetInfo.attached ) {
const {sessionId} = await send("Target.attachToTarget", {
targetId: targetInfo.targetId,
flatten: true
});
Sessions.set(targetInfo.targetId, sessionId);
}
}
}

View File

@ -21,7 +21,7 @@ import {fileURLToPath} from 'url';
export const context = Context;
export const DEBUG = process.env.DEBUG_22120 || false;
export const DEBUG = process.env.DEBUG_22120 || true;
export const CHECK_INTERVAL = 400;
export const TEXT_NODE = 3;

3
todo
View File

@ -1,5 +1,6 @@
- ensure we are correctly indexing / saving the page title when the page title updates.
- issues. Title still out of date. We are incorrectly connecting to newtab, etc.
- issues. Title still out of date.
- We need to reload on localhost 22120 if we open with that
- ensure we are getting the page text to index once it is actually loaded (we should call again later, or add mutation observer and update on mutate)
- add export and import of the FTS index
- link up to search input and provide results page