Created
January 16, 2023 00:44
-
-
Save anemochore/23aeda789a1fce22138b3ea7a8b3ae05 to your computer and use it in GitHub Desktop.
run_rom_in_GA_pages.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(async () => { | |
const selector = 'div#artifacts table a.Link--primary'; | |
const romEl = await elementReady_(selector); | |
const romFilename = romEl.innerText; | |
const proxyPrefix = 'https://nightly.link/'; | |
const orgUrl = document.URL; //ex: https://github.com/pdpdds/kingsvalley/actions/runs/3908859118 | |
const newUrl = orgUrl.replace('https://github.com/', proxyPrefix) + '/' + romFilename + '.zip'; | |
const webMSXPrefix = 'https://webmsx.org/?ROM='; | |
window.open(webMSXPrefix + newUrl, '_blank'); | |
function elementReady_(selector) { | |
return new Promise((resolve, reject) => { | |
const els = [...document.querySelectorAll(selector)]; | |
if(els.length > 0) | |
resolve(els[els.length-1]); | |
new MutationObserver(async (m, o) => { | |
const els = [...document.querySelectorAll(selector)]; | |
if(els.length > 0) { | |
o.disconnect(); | |
resolve(els[els.length-1]); | |
} | |
}) | |
.observe(document, { | |
childList: true, | |
subtree: true | |
}); | |
}); | |
} | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment