diff --git a/chrome/content/zotero/runJS.html b/chrome/content/zotero/runJS.html
index f79199f74f..5b2a9bce52 100644
--- a/chrome/content/zotero/runJS.html
+++ b/chrome/content/zotero/runJS.html
@@ -17,7 +17,7 @@
Run as async function
-
+
diff --git a/chrome/content/zotero/runJS.js b/chrome/content/zotero/runJS.js
index 780656c2f0..888f7035b1 100644
--- a/chrome/content/zotero/runJS.js
+++ b/chrome/content/zotero/runJS.js
@@ -32,6 +32,20 @@ async function run() {
resultTextbox.value = Zotero.Utilities.varDump(result);
}
+function handleInput() {
+ var checkbox = document.getElementById('run-as-async');
+ var isAsync = checkbox.checked;
+ if (isAsync) {
+ return;
+ }
+ var code = document.getElementById('code').value;
+ // If `await` is used, switch to async mode
+ if (/^\s*await\s/m.test(code)) {
+ checkbox.checked = true;
+ update();
+ }
+}
+
window.addEventListener('keypress', function (event) {
if (Zotero.isMac) {
if (!event.metaKey) {