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=null, namespaceResolver=null, first_ordered=true) {
if (context === null) context = window.document.documentElement;
if (document === null) document = context.ownerDocument;
if (namespaceResolver === null) namespaceResolver = document.createNSResolver(context);
const result = document.evaluate(path, context, namespaceResolver, first_ordered ? XPathResult.FIRST_ORDERED_NODE_TYPE : XPathResult.ANY_UNORDERED_NODE_TYPE, null);
return result.singleNodeValue || null;
}