It annoys me that certain web sites intercept standard browser UI hotkeys.
I use Firefox and when I hit the forward slash key ('/'), I want to search the text in the current tab. I do not want the cursor to get focused in google's search box at the top of the page. Here's a typical offending page:
https://groups.google.com/forum/#!msg/vim_use/r3TdW9G9ms4/s-Jr3BpcnvUJ
I've tried some greasemonkey techniques that work on other sites, like installing my own addEventListener() for keyup, keydown and keypress as seen here, or replacing prototype.addEventListener() as seen here.
Here's some sample code where I try to nuke all key event listeners on all div elements using the latter technique:
// ==UserScript==
// @description Stop google groups from highjacking the keyboard
// @include http://groups.google.com/*
// @include https://groups.google.com/*
// @run-at document-start
// @grant unsafeWindow
// ==/UserScript==
realHTMLDivElementAddEventListener = unsafeWindow.HTMLDivElement.prototype.addEventListener;
unsafeWindow.HTMLDivElement.prototype.addEventListener = function(a,b,c) {
if ( a == 'keydown' || a == 'keyup' || a == 'keypress' ) {
console.log("zapped: " + a);
console.log("zapped: this is id: " + this.id);
console.log("zapped: this is cl: " + this.className);
} else {
realHTMLDivElementAddEventListener(a,b,c);
}
}
This catches a few but let's hundreds of event listeners still get installed. Fireing my GM on "load" or "DOMContentLoaded" did not help things...
I'm actually not sure it's a DIV element that needs zapping (I've not been able to coax Firebug into breaking when I hit '/'), but I'm surprised that the code above fails to zap all attempts to add a key event listenver to a DIV.
Has google figured out a way to elude the power of Greasemonkey?