@ai-ecoverse/sliccy-browser 0.1.36 → 0.1.37
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/package.json +1 -1
- package/src/browser.js +6 -4
package/package.json
CHANGED
package/src/browser.js
CHANGED
|
@@ -362,11 +362,11 @@ function evalSourceAsync(tab, source) {
|
|
|
362
362
|
|
|
363
363
|
export { evalSource as eval, evalSourceAsync as evalAsync };
|
|
364
364
|
|
|
365
|
-
function evaluate(tab, source, awaitPromise) {
|
|
366
|
-
return using(() => evaluateNow(tab, source, awaitPromise));
|
|
365
|
+
function evaluate(tab, source, awaitPromise, decodeJson = true) {
|
|
366
|
+
return using(() => evaluateNow(tab, source, awaitPromise, decodeJson));
|
|
367
367
|
}
|
|
368
368
|
|
|
369
|
-
async function evaluateNow(tab, source, awaitPromise) {
|
|
369
|
+
async function evaluateNow(tab, source, awaitPromise, decodeJson) {
|
|
370
370
|
const { client, sessionId } = await sessionFor(targetIdOf(tab));
|
|
371
371
|
const result = await client.send(
|
|
372
372
|
'Runtime.evaluate',
|
|
@@ -380,7 +380,8 @@ async function evaluateNow(tab, source, awaitPromise) {
|
|
|
380
380
|
if (result?.exceptionDetails) {
|
|
381
381
|
throw new Error(exceptionMessage(result.exceptionDetails));
|
|
382
382
|
}
|
|
383
|
-
|
|
383
|
+
const value = result?.result?.value;
|
|
384
|
+
return decodeJson ? unwrapEvalResult(value) : value;
|
|
384
385
|
}
|
|
385
386
|
|
|
386
387
|
export async function cookie(tab, name) {
|
|
@@ -401,6 +402,7 @@ export async function localStorage(tab, key) {
|
|
|
401
402
|
const raw = await evaluate(
|
|
402
403
|
tab,
|
|
403
404
|
`(function(){try{var v=window.localStorage.getItem(${JSON.stringify(key)});return v===null?null:String(v);}catch(e){return null;}})()`,
|
|
405
|
+
false,
|
|
404
406
|
false
|
|
405
407
|
);
|
|
406
408
|
if (raw === null || raw === undefined) return null;
|