Github fetch file info
by techtiger255
HTML
<pre id="log"></pre>
JavaScript
function getFile(url, callback, identity=undefined) {
var identity = ;
fetch(url).then( response => {
response.text().then( txt => {
callback(txt, identity);
})
});
}
function gitFile(prefix, file, callback=false, identity=undefined) {
// Prefix is the user, the repository, branch, etc
getFile("https://raw.githubusercontent.com/" + prefix + "/" + file, callback, identity);
}
/*
> Example:
gitFile("Techtiger255/Hosting2.0/master/social/AlexanderHamilton", "js/console.js", done);
//Yeah I know eval isn't safe... Just use this as something trivial, or use safe-eval on npm or something
function done(txt) {
document.getElementById("log").textContent =
"Results:\n\n" + txt;
}
*/