|
|
@@ -28,7 +28,6 @@ import {
|
|
|
ON_BEFORE_CAPTURE_EVENT_NAME,
|
|
|
ON_AFTER_CAPTURE_EVENT_NAME,
|
|
|
WIN_ID_ATTRIBUTE_NAME,
|
|
|
- waitForUserScript,
|
|
|
preProcessDoc,
|
|
|
serialize,
|
|
|
postProcessDoc,
|
|
|
@@ -39,7 +38,6 @@ const helper = {
|
|
|
ON_BEFORE_CAPTURE_EVENT_NAME,
|
|
|
ON_AFTER_CAPTURE_EVENT_NAME,
|
|
|
WIN_ID_ATTRIBUTE_NAME,
|
|
|
- waitForUserScript,
|
|
|
preProcessDoc,
|
|
|
serialize,
|
|
|
postProcessDoc,
|
|
|
@@ -160,38 +158,38 @@ function getNewSessionId() {
|
|
|
}
|
|
|
|
|
|
function initRequestSync(message) {
|
|
|
- const waitForUserScript = helper.waitForUserScript;
|
|
|
const sessionId = message.sessionId;
|
|
|
+ const waitForUserScript = globalThis._singleFile_waitForUserScript;
|
|
|
if (!TOP_WINDOW) {
|
|
|
windowId = globalThis.frameId = message.windowId;
|
|
|
}
|
|
|
processFrames(document, message.options, windowId, sessionId);
|
|
|
if (!TOP_WINDOW) {
|
|
|
- if (message.options.userScriptEnabled && waitForUserScript.callback) {
|
|
|
- waitForUserScript.callback(helper.ON_BEFORE_CAPTURE_EVENT_NAME);
|
|
|
+ if (message.options.userScriptEnabled && waitForUserScript) {
|
|
|
+ waitForUserScript(helper.ON_BEFORE_CAPTURE_EVENT_NAME);
|
|
|
}
|
|
|
sendInitResponse({ frames: [getFrameData(document, globalThis, windowId, message.options)], sessionId, requestedFrameId: document.documentElement.dataset.requestedFrameId && windowId });
|
|
|
- if (message.options.userScriptEnabled && waitForUserScript.callback) {
|
|
|
- waitForUserScript.callback(helper.ON_AFTER_CAPTURE_EVENT_NAME);
|
|
|
+ if (message.options.userScriptEnabled && waitForUserScript) {
|
|
|
+ waitForUserScript(helper.ON_AFTER_CAPTURE_EVENT_NAME);
|
|
|
}
|
|
|
delete document.documentElement.dataset.requestedFrameId;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
async function initRequestAsync(message) {
|
|
|
- const waitForUserScript = helper.waitForUserScript;
|
|
|
const sessionId = message.sessionId;
|
|
|
+ const waitForUserScript = globalThis._singleFile_waitForUserScript;
|
|
|
if (!TOP_WINDOW) {
|
|
|
windowId = globalThis.frameId = message.windowId;
|
|
|
}
|
|
|
processFrames(document, message.options, windowId, sessionId);
|
|
|
if (!TOP_WINDOW) {
|
|
|
- if (message.options.userScriptEnabled && waitForUserScript.callback) {
|
|
|
- await waitForUserScript.callback(helper.ON_BEFORE_CAPTURE_EVENT_NAME);
|
|
|
+ if (message.options.userScriptEnabled && waitForUserScript) {
|
|
|
+ await waitForUserScript(helper.ON_BEFORE_CAPTURE_EVENT_NAME);
|
|
|
}
|
|
|
sendInitResponse({ frames: [getFrameData(document, globalThis, windowId, message.options)], sessionId, requestedFrameId: document.documentElement.dataset.requestedFrameId && windowId });
|
|
|
- if (message.options.userScriptEnabled && waitForUserScript.callback) {
|
|
|
- await waitForUserScript.callback(helper.ON_AFTER_CAPTURE_EVENT_NAME);
|
|
|
+ if (message.options.userScriptEnabled && waitForUserScript) {
|
|
|
+ await waitForUserScript(helper.ON_AFTER_CAPTURE_EVENT_NAME);
|
|
|
}
|
|
|
delete document.documentElement.dataset.requestedFrameId;
|
|
|
}
|