Last active
July 29, 2022 04:11
-
-
Save mhay10/895a2ebc09b7e0a903ffa8c056170eef to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| "use strict"; | |
| const sleep = (ms) => { | |
| return new Promise((resolve) => setTimeout(resolve, ms)); | |
| }; | |
| const getUrl = async (page) => { | |
| page.scrollIntoViewIfNeeded(); | |
| const img = page.querySelector("img"); | |
| await sleep(100); | |
| return img.src; | |
| }; | |
| window.onload = () => { | |
| const validPage = window.location.href.includes("/scores/"); | |
| if (validPage) { | |
| const aside = document.querySelector("aside"); | |
| const pageContainer = document.getElementById("jmuse-scroller-component"); | |
| const downloadButton = document.createElement("button"); | |
| aside.firstChild.appendChild(downloadButton); | |
| downloadButton.textContent = "Download Score"; | |
| downloadButton.onclick = async (e) => { | |
| const pages = [...pageContainer.children]; | |
| for (let i = 1; i < pages.length; i++) { | |
| if (pages[i].className != pages[i - 1].className) break; | |
| console.log(await getUrl(pages[i])); | |
| } | |
| }; | |
| } | |
| }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment