@ai-ecoverse/slicc-browsers 1.27.0 → 1.27.1
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/guard-vectors.json +1 -1
- package/package.json +1 -1
- package/sign-in-hold.mjs +39 -16
package/guard-vectors.json
CHANGED
package/package.json
CHANGED
package/sign-in-hold.mjs
CHANGED
|
@@ -370,27 +370,50 @@ async function measureClient({
|
|
|
370
370
|
return result;
|
|
371
371
|
}
|
|
372
372
|
|
|
373
|
-
async function rawReadable(reader, targetId, mark, notes) {
|
|
373
|
+
async function rawReadable(reader, targetId, mark, notes, waitMs = 0) {
|
|
374
374
|
const attached = await outcome(reader.send('Target.attachToTarget', { targetId, flatten: true }));
|
|
375
375
|
if (!attached.ok || !attached.result?.sessionId)
|
|
376
376
|
return { readable: false, reason: `raw attach failed: ${attached.error?.message}` };
|
|
377
377
|
const sessionId = attached.result.sessionId;
|
|
378
378
|
await outcome(reader.send('Runtime.enable', {}, sessionId));
|
|
379
|
-
const
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
expression: 'document.
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
)
|
|
388
|
-
|
|
379
|
+
const readOnce = async () => {
|
|
380
|
+
const ready = await outcome(
|
|
381
|
+
reader.send(
|
|
382
|
+
'Runtime.evaluate',
|
|
383
|
+
{ expression: 'document.readyState', returnByValue: true },
|
|
384
|
+
sessionId
|
|
385
|
+
)
|
|
386
|
+
);
|
|
387
|
+
const committed = ready.ok && ['interactive', 'complete'].includes(ready.result?.result?.value);
|
|
388
|
+
const read = await outcome(
|
|
389
|
+
reader.send(
|
|
390
|
+
'Runtime.evaluate',
|
|
391
|
+
{
|
|
392
|
+
expression: 'document.title + " " + (document.body && document.body.innerText)',
|
|
393
|
+
returnByValue: true,
|
|
394
|
+
},
|
|
395
|
+
sessionId
|
|
396
|
+
)
|
|
397
|
+
);
|
|
398
|
+
const text = read.ok ? String(read.result?.result?.value ?? '') : '';
|
|
399
|
+
const readable = Boolean(committed && mark && text.includes(mark));
|
|
400
|
+
return { readable, text };
|
|
401
|
+
};
|
|
402
|
+
let result = await readOnce();
|
|
403
|
+
if (!result.readable && waitMs > 0) {
|
|
404
|
+
const found = await until(async () => {
|
|
405
|
+
const next = await readOnce();
|
|
406
|
+
return next.readable ? next : null;
|
|
407
|
+
}, waitMs);
|
|
408
|
+
if (found) result = found;
|
|
409
|
+
}
|
|
389
410
|
await outcome(reader.send('Target.detachFromTarget', { sessionId }));
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
411
|
+
note(notes, 'sign-in-hold.raw-read', {
|
|
412
|
+
targetId,
|
|
413
|
+
readable: result.readable,
|
|
414
|
+
text: result.text.slice(0, 120),
|
|
415
|
+
});
|
|
416
|
+
return result;
|
|
394
417
|
}
|
|
395
418
|
|
|
396
419
|
function holdExpression(control, ordinary, tag, marker, heldUrl) {
|
|
@@ -616,7 +639,7 @@ async function callbackTab({
|
|
|
616
639
|
targetId,
|
|
617
640
|
};
|
|
618
641
|
|
|
619
|
-
const { readable } = await rawReadable(reader, targetId, mark, notes);
|
|
642
|
+
const { readable } = await rawReadable(reader, targetId, mark, notes, Math.min(budget, 3000));
|
|
620
643
|
if (!readable)
|
|
621
644
|
return {
|
|
622
645
|
live: false,
|