summaryrefslogtreecommitdiff
path: root/ext/bg/js
diff options
context:
space:
mode:
Diffstat (limited to 'ext/bg/js')
-rw-r--r--ext/bg/js/search-main.js41
1 files changed, 11 insertions, 30 deletions
diff --git a/ext/bg/js/search-main.js b/ext/bg/js/search-main.js
index 5e4d7a20..1075d46e 100644
--- a/ext/bg/js/search-main.js
+++ b/ext/bg/js/search-main.js
@@ -19,10 +19,14 @@
* DisplaySearch
* apiForwardLogsToBackend
* apiOptionsGet
+ * dynamicLoader
*/
-function injectSearchFrontend() {
- const scriptSrcs = [
+async function injectSearchFrontend() {
+ dynamicLoader.loadStyles([
+ '/fg/css/client.css'
+ ]);
+ await dynamicLoader.loadScripts([
'/mixed/js/text-scanner.js',
'/fg/js/frontend-api-receiver.js',
'/fg/js/frame-offset-forwarder.js',
@@ -30,27 +34,7 @@ function injectSearchFrontend() {
'/fg/js/popup-proxy-host.js',
'/fg/js/frontend.js',
'/fg/js/content-script-main.js'
- ];
- for (const src of scriptSrcs) {
- const node = document.querySelector(`script[src='${src}']`);
- if (node !== null) { continue; }
-
- const script = document.createElement('script');
- script.async = false;
- script.src = src;
- document.body.appendChild(script);
- }
-
- const styleSrcs = [
- '/fg/css/client.css'
- ];
- for (const src of styleSrcs) {
- const style = document.createElement('link');
- style.rel = 'stylesheet';
- style.type = 'text/css';
- style.href = src;
- document.head.appendChild(style);
- }
+ ]);
}
(async () => {
@@ -63,18 +47,15 @@ function injectSearchFrontend() {
let optionsApplied = false;
const applyOptions = async () => {
- const optionsContext = {
- depth: 0,
- url: window.location.href
- };
+ const optionsContext = {depth: 0, url: window.location.href};
const options = await apiOptionsGet(optionsContext);
if (!options.scanning.enableOnSearchPage || optionsApplied) { return; }
+
optionsApplied = true;
+ yomichan.off('optionsUpdated', applyOptions);
window.frontendInitializationData = {depth: 1, proxy: false, isSearchPage: true};
- injectSearchFrontend();
-
- yomichan.off('optionsUpdated', applyOptions);
+ await injectSearchFrontend();
};
yomichan.on('optionsUpdated', applyOptions);