Skip to content

Instantly share code, notes, and snippets.

@PaGury
Last active August 22, 2019 15:53
Show Gist options
  • Save PaGury/5cfe617863c84f279ab03a0e4d8f1c63 to your computer and use it in GitHub Desktop.
Save PaGury/5cfe617863c84f279ab03a0e4d8f1c63 to your computer and use it in GitHub Desktop.
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