Last active
August 22, 2019 15:53
-
-
Save PaGury/5cfe617863c84f279ab03a0e4d8f1c63 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
var funcSerialized = (name) => `function ${name}() { [native code] }`; | |
var nativeObjects = [Array, Boolean, Date, Function, JSON, Object, Promise, RegExp]; | |
var ignoreList = ['length', 'constructor', '__proto__', 'caller', 'callee', 'arguments', 'source', 'toGMTString']; | |
var test = (nativeObject) => { | |
const proto = nativeObject.prototype || nativeObject; | |
Object.getOwnPropertyNames(proto) | |
.filter(name => !ignoreList.includes(name)) | |
.filter(name => proto[name]) | |
.map(name => ({ | |
name, | |
func: proto[name], | |
funcToString: proto[name].toString(), | |
})).forEach(({ name, func, funcToString}) => { | |
if (funcToString !== funcSerialized(name)) { | |
console.log('Function', name, 'overloaded by client script:', func); | |
} | |
}); | |
}; | |
nativeObjects.forEach(obj => test(obj)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment