Skip to content

Instantly share code, notes, and snippets.

@Mardak
Created May 1, 2011 00:03
Show Gist options
  • Save Mardak/950116 to your computer and use it in GitHub Desktop.
Save Mardak/950116 to your computer and use it in GitHub Desktop.
Prevent the page from seeing "j" presses
https://github.com/Mardak/restartless/blob/watchWindows/bootstrap.js
diff --git a/bootstrap.js b/bootstrap.js
index d9f353c..d2a3cd8 100644
--- a/bootstrap.js
+++ b/bootstrap.js
@@ -150,7 +150,17 @@ function unload(callback, container) {
/**
* Handle the add-on being activated on install/enable
*/
-function startup(data, reason) {}
+function startup(data, reason) {
+ watchWindows(function(window) {
+ let noJ = function(event) {
+ if (String.fromCharCode(event.charCode) == "j")
+ event.stopPropagation();
+ };
+
+ window.gBrowser.addEventListener("keypress", noJ, true);
+ unload(function() window.gBrowser.removeEventListener("keypress", noJ, true));
+ });
+}
/**
* Handle the add-on being deactivated on uninstall/disable
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment