Skip to content

Instantly share code, notes, and snippets.

@zapthedingbat
Created November 29, 2014 21:20
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 zapthedingbat/1760ce9943a56462ef97 to your computer and use it in GitHub Desktop.
Save zapthedingbat/1760ce9943a56462ef97 to your computer and use it in GitHub Desktop.
Remove a monkey-patch from a JavaScript method.
// Unpatch.js
// Sam Greenhalgh
// http://RadicalResearch.co.uk/
// Example usage
// window.console.log = unpatch(window.console.log);
function unpatch(method) {
var _ = Function.prototype.apply;
var r;
Function.prototype.apply = function () {
r = this;
Function.prototype.apply = _;
};
method();
return r;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment