Skip to content

Instantly share code, notes, and snippets.

@trouble6174
Last active Aug 13, 2021
Embed
What would you like to do?
window.addEventListener("load", function(event) {
'use strict';
function onAltQ() {
console.log('start');
const cts = str => str.replace(/[A-Z]/g, letter => `-${letter.toLowerCase()}`);
var u="https://api.github.com/repos/csujedihy/lc-all-solutions/git/trees/master";
var idxn,fn,qname,url,m;
fn = document.getElementsByClassName("mtk10")[0].textContent;
fetch(u).then(r=>r.json()).then(d=>{
console.log(d.tree);
idxn = d.tree.filter(x=>x.path.includes(cts(fn)))[0].path;
qname=idxn.split('.')[1];
url=`https://raw.githubusercontent.com/csujedihy/lc-all-solutions/master/${idxn}/${qname}.py`
m=document.getElementsByClassName("mtk18")[0]
fetch(url).then(r=>r.text()).then(d=>m.textContent=d);
});
}
function onKeydown(evt) {
if (evt.altKey && evt.keyCode == 81) {
onAltQ();
}
}
document.addEventListener('keydown', onKeydown, true);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment