Skip to content

Instantly share code, notes, and snippets.

@mhay10
Last active July 29, 2022 04:11
Show Gist options
  • Select an option

  • Save mhay10/895a2ebc09b7e0a903ffa8c056170eef to your computer and use it in GitHub Desktop.

Select an option

Save mhay10/895a2ebc09b7e0a903ffa8c056170eef to your computer and use it in GitHub Desktop.
"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