Skip to content

Commit 1b02133

Browse files
committed
Cleanup
1 parent 83fc768 commit 1b02133

File tree

1 file changed

+15
-21
lines changed

1 file changed

+15
-21
lines changed

extension/src/content.ts

Lines changed: 15 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -23,22 +23,6 @@ import real_world_path from './real_world.ts?script&module'
2323

2424
DEV: {place_log(Place_Name.Content, 'loaded.')}
2525

26-
function loadScriptInRealWorld(path: string): Promise<void> {
27-
return new Promise((resolve, reject) => {
28-
29-
const script = document.createElement('script')
30-
script.src = chrome.runtime.getURL(path)
31-
script.type = 'module'
32-
33-
script.addEventListener('error', err => reject(err))
34-
script.addEventListener('load', () => resolve())
35-
36-
/* The script should execute as soon as possible */
37-
const mount = (document.head as HTMLHeadElement | null) || document.documentElement
38-
mount.appendChild(script)
39-
})
40-
}
41-
4226

4327
/* Wait for the document to fully load before injecting any scripts */
4428
if (document.readyState === 'complete') {
@@ -58,14 +42,24 @@ function on_loaded() {
5842
↳ 'Debugger_Connected' message
5943
*/
6044

61-
loadScriptInRealWorld(real_world_path)
62-
.catch(err => {
63-
place_error(Place_Name.Content, `Real_World script (${real_world_path}) failed to load.`, err)
64-
})
45+
let script = document.createElement('script')
46+
script.src = chrome.runtime.getURL(real_world_path)
47+
script.type = 'module'
48+
49+
script.addEventListener('error', err => {
50+
place_error(Place_Name.Content, `real-world script (${real_world_path}) failed to load.`, err)
51+
})
52+
script.addEventListener('load', () => {
53+
DEV: {place_log(Place_Name.Content, `real-world script (${real_world_path}) loaded successfully.`)}
54+
})
55+
56+
/* The script should execute as soon as possible */
57+
let mount = (document.head as HTMLHeadElement | null) || document.documentElement
58+
mount.appendChild(script)
6559
}
6660

6761

68-
const extension_version = chrome.runtime.getManifest().version
62+
let extension_version = chrome.runtime.getManifest().version
6963

7064
let bg_port: chrome.runtime.Port | null = null
7165
let devtools_opened = false

0 commit comments

Comments
 (0)