JSFiddle - React, Tailwind, and code Playground
by boneskull
JavaScript
function derp(herp) {
alert(herp.burp());
};
window.herp = {
burp: function() {
return 'merp';
}
}
function inject(fn) {
var str = fn.toString();
var injectable = /function\s+\w+?\((\w+?)\)/.exec(str);
var parameters = [];
if (injectable.length) {
injectable = injectable[1];
if (window.hasOwnProperty(injectable)) {
parameters.push(window[injectable]);
}
}
fn.apply(this, parameters);
}
inject(derp);