Skip to content

Instantly share code, notes, and snippets.

@kirjavascript
Created March 4, 2018 20:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kirjavascript/eff6c155d509c932fad3d37fbca6879f to your computer and use it in GitHub Desktop.
Save kirjavascript/eff6c155d509c932fad3d37fbca6879f to your computer and use it in GitHub Desktop.
worst api ever
const http = new Proxy({}, {
get(t, k) {
const url = `https://crossorigin.me/http://${k.replace(/_/g, '.')}`;
return new Proxy({}, {
get(t, k) {
fetch(url)
.then(res => res.text())
.then(res => {
(new Function(`return (${k})(\`${res.replace(/`/g, '\\`')}\`)`))()
});
}
});
}
});
// do a fetch request
http.www_google_com[(src) => {
console.log(src);
}];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment