Skip to content

Commit 9964b26

Browse files
authored
Use WebExtension approach to inject editor.js (#1393)
Because the Firefox extension is now mostly a WebExtension, this updates xkit.js to inject editor.js using the correct method.
1 parent 435c749 commit 9964b26

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

xkit.js

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1074,20 +1074,23 @@ function xkit_init_special() {
10741074
}
10751075

10761076
if (document.location.href.indexOf("/xkit_editor") !== -1) {
1077-
if (XKit.browser().chrome === true) {
1078-
/* global chrome */
1077+
if (typeof(browser) !== 'undefined') {
1078+
/* global browser */
10791079
var xhr = new XMLHttpRequest();
1080-
xhr.open('GET', chrome.extension.getURL('editor.js'), false);
1080+
xhr.open('GET', browser.extension.getURL('editor.js'), false);
10811081
xhr.send(null);
10821082
try {
10831083
eval(xhr.responseText + "\n//# sourceURL=xkit/editor.js");
10841084
XKit.extensions.xkit_editor.run();
10851085
} catch (e) {
10861086
XKit.window.show("Can't launch XKit Editor", "<p>" + e.message + "</p>", "error", "<div id=\"xkit-close-message\" class=\"xkit-button default\">OK</div>");
10871087
}
1088-
}
1089-
if (XKit.browser().firefox === true || XKit.browser().safari === true) {
1088+
} else if (XKit.extensions.xkit_editor) {
10901089
XKit.extensions.xkit_editor.run();
1090+
} else {
1091+
XKit.window.show("Can't launch XKit Editor",
1092+
"Extension platform unsupported or broken.", "error",
1093+
"<div id=\"xkit-close-message\" class=\"xkit-button default\">OK</div>");
10911094
}
10921095
}
10931096

0 commit comments

Comments
 (0)