Skip to content

Instantly share code, notes, and snippets.

@jimevans
Forked from jleyba/gist:8307735
Last active January 2, 2016 13:19
Show Gist options
  • Save jimevans/8308969 to your computer and use it in GitHub Desktop.
Save jimevans/8308969 to your computer and use it in GitHub Desktop.
bot.inject.recompileFunction_ = function(fn, theWindow) {
if (goog.isString(fn)) {
try {
return new theWindow['Function'](fn);
} catch (ex) {
// Try to recover if in IE-quirks.
// Need to initialize the script engine in the passed-in window.
if (goog.userAgent.IE && theWindow.execScript) {
theWindow.execScript(';');
return new theWindow['Function'](fn);
}
throw ex;
}
}
return theWindow == window ? fn : new theWindow['Function'](
'return (' + fn + ').apply(null,arguments);');
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment