Created
November 23, 2015 03:00
-
-
Save kainino0x/ef6a30671d62f724e99e to your computer and use it in GitHub Desktop.
hijack.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var hijack = function(that, name, wrap) { | |
var f0 = that[name]; | |
that[name] = function() { | |
var f = function() { | |
f0.apply(that, arguments); | |
}; | |
var args = Array.prototype.slice.call(arguments); | |
args.unshift(f); | |
return wrap.apply(null, args); | |
}; | |
}; | |
// Example: | |
// | |
// hijack(gl, 'drawArrays', function(f, mode, first, count) { | |
// console.log('gl.drawArrays(', mode, first, count, ')'); | |
// return f(mode, first, count); | |
// }); | |
// |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment