-
Notifications
You must be signed in to change notification settings - Fork 56
How to fix errors in your .keysnail.js
Masafumi Oyamada edited this page Sep 24, 2015
·
3 revisions
This is a simple guide to help you fix errors in your .keysnail.js
.
Most users will meet this "missing { before let block" error. Once syntax called let expression/statement like let (x = foo()) x * x
was valid in Firefox, but the syntax was dropped in Firefox 41, and now is causing the errors.
What you have to do is replace let expression/statement in your .keysnail.js
with standard JavaScript syntax.
See https://github.com/mooz/keysnail/pull/176 for details.
Here are several examples.
Fix
// Original (invalid)
function (ev, arg) {
let (elem = document.commandDispatcher.focusedElement) elem && elem.blur();
gBrowser.focus();
content.focus();
}
to
// Corrected (valid)
function (ev, arg) {
let elem = document.commandDispatcher.focusedElement;
if (elem) { elem.blur(); }
gBrowser.focus();
content.focus();
}
Fix
// Original (invalid)
function (ev, arg) {
gBrowser.loadOneTab(
let (url = command.getClipboardText())
url.indexOf("://") === -1 ?
util.format("http://www.google.com/search?q=%s&ie=utf-8&oe=utf-8", encodeURIComponent(url)) :
url,
null, null, null, false
);
}, false
to
// Corrected version (valid)
function (ev, arg) {
let url = command.getClipboardText();
if (url.indexOf("://") === -1) {
url = util.format("http://www.google.com/search?q=%s&ie=utf-8&oe=utf-8", encodeURIComponent(url));
}
gBrowser.loadOneTab(url, null, null, null, false);
}, false
Fix
// Original (invalid)
function (ev) {
if (!command.kill.ring.length)
return;
let (ct = command.getClipboardText())
(!command.kill.ring.length || ct != command.kill.ring[0]) && command.pushKillRing(ct);
prompt.selector(
{
message: "Paste:",
collection: command.kill.ring,
callback: function (i) { if (i >= 0) key.insertText(command.kill.ring[i]); }
}
);
}
to
// Corrected (valid)
function (ev) {
if (!command.kill.ring.length)
return;
let ct = command.getClipboardText();
if (!command.kill.ring.length || ct != command.kill.ring[0]) {
command.pushKillRing(ct);
}
prompt.selector(
{
message: "Paste:",
collection: command.kill.ring,
callback: function (i) { if (i >= 0) key.insertText(command.kill.ring[i]); }
}
);
}