From 749b747728175d8a7d5638af2c6ec01102a282c1 Mon Sep 17 00:00:00 2001 From: toasted-nutbread Date: Wed, 22 Apr 2020 17:48:42 -0400 Subject: Remove sentinel script node after load --- ext/mixed/js/dynamic-loader.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'ext/mixed/js') 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); -- cgit v1.2.3