diff --git a/tes.user.js b/tes.user.js new file mode 100644 index 0000000..b17f48d --- /dev/null +++ b/tes.user.js @@ -0,0 +1,44 @@ +// ==UserScript== +// @name osu! full background link +// @version 1.0.1 +// @grant none +// @match https://osu.ppy.sh/* +// ==/UserScript== + +const observer = new MutationObserver(mutations => { + const meta = document.querySelector(".beatmapset-info__box.beatmapset-info__box--meta:not(.bg-link-added)"); + if (meta) { + meta.classList.add("bg-link-added"); + + const beatmapId = window.location.pathname.split("/")[2]; + + const link = document.createElement("h3"); + link.className = "beatmapset-info__header"; + + const a = document.createElement("a"); + a.href = `https://assets.ppy.sh/beatmaps/${beatmapId}/covers/raw.jpg`; + a.innerHTML = "Background"; + link.append(a); + meta.prepend(link); + } + + const items = document.querySelectorAll(".beatmapset-panel__menu:not(.bg-link-added)"); + items.forEach(e => { + e.classList.add("bg-link-added"); + const downloadLink = e.querySelector("a"); + const beatmapId = downloadLink.pathname.split("/")[2]; + + const a = document.createElement("a"); + a.href = `https://assets.ppy.sh/beatmaps/${beatmapId}/covers/raw.jpg`; + a.className = "beatmapset-panel__menu-item"; + const icon = document.createElement("span"); + icon.className = "fas fa-image"; + a.append(icon); + downloadLink.before(a); + }) +}); + +observer.observe(document, { + childList: true, + subtree: true +}); \ No newline at end of file