I have some JavaScript code that defines a function getElementsByAttribute as follows:
getElementsByAttribute
Object.prototype.getElementsByAttribute = function(attr)
Adding things to Object.prototype is a really bad idea. It will be added to every object, and that will cause unintended behavior, I guarantee it.
Object.prototype
Simply define your function and decorate it onto whatever objects you need dynamically.