diff options
Diffstat (limited to 'ext/bg')
-rw-r--r-- | ext/bg/background.html | 3 | ||||
-rw-r--r-- | ext/bg/context.html | 2 | ||||
-rw-r--r-- | ext/bg/js/backend.js | 3 | ||||
-rw-r--r-- | ext/bg/js/background-main.js | 25 | ||||
-rw-r--r-- | ext/bg/js/context-main.js (renamed from ext/bg/js/context.js) | 8 | ||||
-rw-r--r-- | ext/bg/js/search-main.js (renamed from ext/bg/js/search-frontend.js) | 12 | ||||
-rw-r--r-- | ext/bg/js/search.js | 8 | ||||
-rw-r--r-- | ext/bg/js/settings/popup-preview-frame-main.js | 25 | ||||
-rw-r--r-- | ext/bg/js/settings/popup-preview-frame.js | 11 | ||||
-rw-r--r-- | ext/bg/search.html | 3 | ||||
-rw-r--r-- | ext/bg/settings-popup-preview.html | 2 |
11 files changed, 70 insertions, 32 deletions
diff --git a/ext/bg/background.html b/ext/bg/background.html index f1006f8d..3446d9ce 100644 --- a/ext/bg/background.html +++ b/ext/bg/background.html @@ -24,6 +24,7 @@ <script src="/bg/js/anki.js"></script> <script src="/bg/js/anki-note-builder.js"></script> + <script src="/bg/js/backend.js"></script> <script src="/bg/js/mecab.js"></script> <script src="/bg/js/audio-uri-builder.js"></script> <script src="/bg/js/backend-api-forwarder.js"></script> @@ -45,6 +46,6 @@ <script src="/bg/js/util.js"></script> <script src="/mixed/js/audio-system.js"></script> - <script src="/bg/js/backend.js"></script> + <script src="/bg/js/background-main.js"></script> </body> </html> diff --git a/ext/bg/context.html b/ext/bg/context.html index 0e50ed7c..394869b1 100644 --- a/ext/bg/context.html +++ b/ext/bg/context.html @@ -185,6 +185,6 @@ <script src="/bg/js/options.js"></script> <script src="/bg/js/util.js"></script> - <script src="/bg/js/context.js"></script> + <script src="/bg/js/context-main.js"></script> </body> </html> diff --git a/ext/bg/js/backend.js b/ext/bg/js/backend.js index 6b696f2c..693a9ad6 100644 --- a/ext/bg/js/backend.js +++ b/ext/bg/js/backend.js @@ -1059,6 +1059,3 @@ class Backend { } } } - -window.yomichanBackend = new Backend(); -window.yomichanBackend.prepare(); diff --git a/ext/bg/js/background-main.js b/ext/bg/js/background-main.js new file mode 100644 index 00000000..24117f4e --- /dev/null +++ b/ext/bg/js/background-main.js @@ -0,0 +1,25 @@ +/* + * Copyright (C) 2020 Yomichan Authors + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <https://www.gnu.org/licenses/>. + */ + +/* global + * Backend + */ + +(async () => { + window.yomichanBackend = new Backend(); + await window.yomichanBackend.prepare(); +})(); diff --git a/ext/bg/js/context.js b/ext/bg/js/context-main.js index e3d4ad4a..e2086a96 100644 --- a/ext/bg/js/context.js +++ b/ext/bg/js/context-main.js @@ -51,7 +51,7 @@ function setupButtonEvents(selector, command, url) { } } -window.addEventListener('DOMContentLoaded', async () => { +async function mainInner() { await yomichan.prepare(); showExtensionInfo(); @@ -86,4 +86,8 @@ window.addEventListener('DOMContentLoaded', async () => { } }, 10); }); -}); +} + +(async () => { + window.addEventListener('DOMContentLoaded', mainInner, false); +})(); diff --git a/ext/bg/js/search-frontend.js b/ext/bg/js/search-main.js index e534e771..38b6d99a 100644 --- a/ext/bg/js/search-frontend.js +++ b/ext/bg/js/search-main.js @@ -16,6 +16,7 @@ */ /* global + * DisplaySearch * apiOptionsGet */ @@ -27,7 +28,7 @@ function injectSearchFrontend() { '/fg/js/popup.js', '/fg/js/popup-proxy-host.js', '/fg/js/frontend.js', - '/fg/js/frontend-initialize.js' + '/fg/js/content-script-main.js' ]; for (const src of scriptSrcs) { const node = document.querySelector(`script[src='${src}']`); @@ -51,9 +52,12 @@ function injectSearchFrontend() { } } -async function main() { +(async () => { await yomichan.prepare(); + const displaySearch = new DisplaySearch(); + await displaySearch.prepare(); + let optionsApplied = false; const applyOptions = async () => { @@ -74,6 +78,4 @@ async function main() { yomichan.on('optionsUpdated', applyOptions); await applyOptions(); -} - -main(); +})(); diff --git a/ext/bg/js/search.js b/ext/bg/js/search.js index 006536c0..684ea6d3 100644 --- a/ext/bg/js/search.js +++ b/ext/bg/js/search.js @@ -73,12 +73,6 @@ class DisplaySearch extends Display { ]); } - static create() { - const instance = new DisplaySearch(); - instance.prepare(); - return instance; - } - async prepare() { try { await super.prepare(); @@ -377,5 +371,3 @@ class DisplaySearch extends Display { } } } - -DisplaySearch.instance = DisplaySearch.create(); diff --git a/ext/bg/js/settings/popup-preview-frame-main.js b/ext/bg/js/settings/popup-preview-frame-main.js new file mode 100644 index 00000000..86c2814c --- /dev/null +++ b/ext/bg/js/settings/popup-preview-frame-main.js @@ -0,0 +1,25 @@ +/* + * Copyright (C) 2019-2020 Yomichan Authors + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <https://www.gnu.org/licenses/>. + */ + +/* global + * SettingsPopupPreview + */ + +(async () => { + const instance = new SettingsPopupPreview(); + await instance.prepare(); +})(); diff --git a/ext/bg/js/settings/popup-preview-frame.js b/ext/bg/js/settings/popup-preview-frame.js index fba114e2..420a7c5a 100644 --- a/ext/bg/js/settings/popup-preview-frame.js +++ b/ext/bg/js/settings/popup-preview-frame.js @@ -41,12 +41,6 @@ class SettingsPopupPreview { ]); } - static create() { - const instance = new SettingsPopupPreview(); - instance.prepare(); - return instance; - } - async prepare() { // Setup events window.addEventListener('message', this.onMessage.bind(this), false); @@ -178,8 +172,3 @@ class SettingsPopupPreview { this.setInfoVisible(!this.popupShown); } } - -SettingsPopupPreview.instance = SettingsPopupPreview.create(); - - - diff --git a/ext/bg/search.html b/ext/bg/search.html index fe88e264..9a824776 100644 --- a/ext/bg/search.html +++ b/ext/bg/search.html @@ -94,6 +94,7 @@ <script src="/bg/js/search-query-parser.js"></script> <script src="/bg/js/clipboard-monitor.js"></script> <script src="/bg/js/search.js"></script> - <script src="/bg/js/search-frontend.js"></script> + + <script src="/bg/js/search-main.js"></script> </body> </html> diff --git a/ext/bg/settings-popup-preview.html b/ext/bg/settings-popup-preview.html index f33ecedf..66475b7c 100644 --- a/ext/bg/settings-popup-preview.html +++ b/ext/bg/settings-popup-preview.html @@ -129,5 +129,7 @@ <script src="/fg/js/popup-proxy-host.js"></script> <script src="/fg/js/frontend.js"></script> <script src="/bg/js/settings/popup-preview-frame.js"></script> + + <script src="/bg/js/settings/popup-preview-frame-main.js"></script> </body> </html> |