Created
July 7, 2010 00:50
-
-
Save bga/466143 to your computer and use it in GitHub Desktop.
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
Function.prototype._makeLikeNative = function() | |
{ | |
if(Object.defineProperty) | |
{ | |
var blackLabelProp = | |
{ | |
enumerable: false, | |
configurable: false, | |
writable: false, | |
value: true | |
}; | |
Function.prototype._makeLikeNative = function() | |
{ | |
Object.defineProperty(this, 'isSourceHided', blackLabelProp); | |
}; | |
var _oldFnToString = Function.prototype.toString; | |
Object.defineProperty(Function.prototype, 'toString', | |
{ | |
configurable: false, | |
writable: false, | |
value: function() | |
{ | |
if(this.isSourceHided === true) | |
return 'function () { [native code] }'; | |
return _oldFnToString.call(this); | |
} | |
} | |
); | |
Function.prototype.toString._makeLikeNative(); | |
} | |
else | |
{ | |
var _hider = function() | |
{ | |
return 'function () { [native code] }'; | |
}; | |
_hider.toString = _hider; | |
Function.prototype._makeLikeNative = function() | |
{ | |
// also dont remember that IE do not enum valueOf and toString properties :P | |
this.toString = _hider; | |
}; | |
} | |
Function.prototype._makeLikeNative._makeLikeNative(); | |
this._makeLikeNative(); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment