With the power of await, this isn't so difficult: let nacl, scrypt; function main() { /* Synchronous code that calls nacl and scrypt */ } (async () => { [nacl, scrypt] = await Promise.all([new Promise(nacl_factory.instantiate), new Promise(scrypt_module_factory)]); return main(); })();
Auto-updating userscripts hosted on Github Gist
In the process of crafting this small set of improvements to Advance Wars By Web, I found out about the proper URL for auto-updating userscripts which are hosted on Microsoft's "Gist" service: // @updateURL https://gist.githubusercontent.com/������/����������������/raw/�����.user.js This will always redirect to the latest version of the file.
Javascript: getElementByXPath
function getElementByXPath(path, context=null, _document=undefined) {
if( _document === undefined ) _document = document;
let res = document.evaluate(path, _document, context, XPathResult.FIRST_ORDERED_NODE_TYPE);
if( !res ) return null;
return res.singleNodeValue;
}