Skip to content

Commit

Permalink
use dynamic import to run editor
Browse files Browse the repository at this point in the history
  • Loading branch information
marcustyphoon committed Dec 6, 2024
1 parent cd249cb commit 2e4e403
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions xkit.js
Original file line number Diff line number Diff line change
Expand Up @@ -4391,7 +4391,7 @@ function show_message(title, msg, icon, buttons) {
});
}

function xkit_init_special() {
async function xkit_init_special() {

$("body").html("");
document.title = "XKit";
Expand All @@ -4417,11 +4417,8 @@ function xkit_init_special() {

if (document.location.href.indexOf("/xkit_editor") !== -1) {
if (typeof(browser) !== 'undefined') {
var xhr = new XMLHttpRequest();
xhr.open('GET', browser.extension.getURL('editor.js'), false);
xhr.send(null);
try {
new Function(xhr.responseText + "\n//# sourceURL=xkit/editor.js")();
await import(browser.runtime.getURL("/editor.js"));
XKit.extensions.xkit_editor.run();
} catch (e) {
XKit.window.show("Can't launch XKit Editor", "<p>" + e.message + "</p>", "error", "<div id=\"xkit-close-message\" class=\"xkit-button default\">OK</div>");
Expand Down

0 comments on commit 2e4e403

Please sign in to comment.