If you figure out early enough that you need this kind of feature, you can architecture your code in such a way that those "drive-by fixes" are actually pluggable and maintainable.
Indeed - at my last job, we built a js widget that would go on customers websites, and we learned pretty quickly that we would need pluggable, sometimes customers-specific hacks. Things like old versions of Prototype.js that broke JSON.stringify or forcing Internet Explorer 8+ into IE7 emulation mode. One customer overwrote Array.prototype.forEach with a broken version that lost the scope. Fun times.