Skip to content

Instantly share code, notes, and snippets.

@rektide
Forked from johnelliott/gist:690905bb909347a56941
Last active August 29, 2015 14:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rektide/b4f6d6ce9b780ed59512 to your computer and use it in GitHub Desktop.
Save rektide/b4f6d6ce9b780ed59512 to your computer and use it in GitHub Desktop.
// ==UserScript==
// @name monkeybusiness-codeschool
// @namespace https://github.com/johnelliott/monkeybusiness
// @include http://*.codeschool.com/*
// ==/UserScript==
// this is not actually a UserScript. because `getEventListeners` only exists in the dev-consoles.
// so copy paste this content in rather than actually running it as a userscript
// the capability not actually in HTML.
// gee it sure would be great if the Document Object Model could tell you about itself but it's EventTargets cannot.
// seems a pretty basic part of what the DOM is supposed to be about- giving you an object model
// to tell you what you are dealing with, what you are looking at or hearing
var n = getEventListeners(document.body).keyup;
console.log("do we have an n?", n);
function guardedKeyupListener(e) {
if ((e.keyCode === 75 || e.keyCode === 74) && e.ctrlKey) {
console.log("return?");
return;
}
console.log("listener call");
n[0].listener.call(this, e);
}
// get rid of old event listener
document.body.removeEventListener("keyup", n[0].listener);
// put listener back and see if it the right key to pass through
document.body.addEventListener("keyup", guardedKeyupListener);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment