Skip to content

Instantly share code, notes, and snippets.

@psiie
Created May 3, 2019 21:23
Show Gist options
  • Save psiie/e6090d79afd386f792269df0a60b2405 to your computer and use it in GitHub Desktop.
Save psiie/e6090d79afd386f792269df0a60b2405 to your computer and use it in GitHub Desktop.
Get the original function in javascript. useful if someone has replaced the function or you must guarantee that it is clean.
function _Function(path) {
let fn = () => {};
const split = path.split('.');
const $iframe = document.createElement('iframe');
$iframe.src = 'about:blank';
document.body.appendChild($iframe);
fn = $iframe.contentWindow;
for (let i=0; i<split.length; i++) {
fn = fn[split[i]];
}
$iframe.parentElement.removeChild($iframe);
return fn;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment