summaryrefslogtreecommitdiff
path: root/ext/mixed/js/dynamic-loader.js
diff options
context:
space:
mode:
authortoasted-nutbread <toasted-nutbread@users.noreply.github.com>2020-04-22 17:48:42 -0400
committertoasted-nutbread <toasted-nutbread@users.noreply.github.com>2020-04-22 17:48:42 -0400
commit749b747728175d8a7d5638af2c6ec01102a282c1 (patch)
tree3e3aa1a0845209c05ba262fd9244e3dc5ca4fb86 /ext/mixed/js/dynamic-loader.js
parentd05a5f3c46d8baa0d6935e5387caf7ca5ba4235e (diff)
Remove sentinel script node after load
Diffstat (limited to 'ext/mixed/js/dynamic-loader.js')
-rw-r--r--ext/mixed/js/dynamic-loader.js4
1 files changed, 3 insertions, 1 deletions
diff --git a/ext/mixed/js/dynamic-loader.js b/ext/mixed/js/dynamic-loader.js
index 20ed8454..29672d36 100644
--- a/ext/mixed/js/dynamic-loader.js
+++ b/ext/mixed/js/dynamic-loader.js
@@ -48,12 +48,14 @@ const dynamicLoader = (() => {
}
function loadScriptSentinel(resolve, reject) {
+ const parent = document.body;
const script = document.createElement('script');
const sentinelEventName = 'dynamicLoaderSentinel';
const sentinelEventCallback = (e) => {
if (e.script !== script) { return; }
yomichan.off(sentinelEventName, sentinelEventCallback);
+ parent.removeChild(script);
resolve();
};
yomichan.on(sentinelEventName, sentinelEventCallback);
@@ -61,7 +63,7 @@ const dynamicLoader = (() => {
try {
script.async = false;
script.src = '/mixed/js/dynamic-loader-sentinel.js';
- document.body.appendChild(script);
+ parent.appendChild(script);
} catch (e) {
yomichan.off(sentinelEventName, sentinelEventCallback);
reject(e);