Преглед на файлове

implement `single-file-on-init-capture-request` event (fix #1729)

Gildas преди 2 месеца
родител
ревизия
ff61dc2b64
променени са 1 файла, в които са добавени 8 реда и са изтрити 0 реда
  1. 8 0
      src/core/content/content.js

+ 8 - 0
src/core/content/content.js

@@ -38,6 +38,10 @@ const SHARE_PAGE_BUTTON_MESSAGE = browser.i18n.getMessage("topPanelSharePageButt
 const SHARE_SELECTION_BUTTON_MESSAGE = browser.i18n.getMessage("topPanelShareSelectionButton");
 const ERROR_TITLE_MESSAGE = browser.i18n.getMessage("topPanelError");
 
+const SINGLE_FILE_PREFIX = "single-file-";
+const WAIT_FOR_USERSCRIPT_PROPERTY_NAME = "_singleFile_waitForUserScript";
+const ON_INIT_CAPTURE_EVENT_NAME = SINGLE_FILE_PREFIX + "on-init-capture";
+
 let processor, processing, downloadParser, openFileInfobar, scrollY, transform, overflow;
 
 setLabels({
@@ -248,6 +252,10 @@ async function processPage(options) {
 			}
 		}
 	};
+	const waitForUserScript = globalThis[WAIT_FOR_USERSCRIPT_PROPERTY_NAME];
+	if (options.userScriptEnabled && waitForUserScript) {
+		await waitForUserScript(ON_INIT_CAPTURE_EVENT_NAME, options);
+	}
 	const cancelProcessor = processor.cancel.bind(processor);
 	if (options.insertEmbeddedImage && options.compressContent) {
 		ui.onInsertingEmbeddedImage(options);