From be57260c2163678ba908d8850f2ae1fbeefc00b7 Mon Sep 17 00:00:00 2001 From: xing Date: Mon, 27 Jun 2022 04:10:42 +0000 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=20'tes.user.js'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tes.user.js | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 tes.user.js 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