Show ??? for missing bsr key, revert Expert+ spacing
This commit is contained in:
parent
346e4c80ba
commit
9e4af403ae
@ -22,8 +22,8 @@
|
|||||||
<span id="difficulty">Easy</span>
|
<span id="difficulty">Easy</span>
|
||||||
<img id="characteristicIcon" src="images/characteristic/Standard.svg">
|
<img id="characteristicIcon" src="images/characteristic/Standard.svg">
|
||||||
<span id="difficultyLabel">Diff Label</span>
|
<span id="difficultyLabel">Diff Label</span>
|
||||||
|
<span id="type"></span>
|
||||||
<span id="bsrKey">25f</span>
|
<span id="bsrKey">25f</span>
|
||||||
<span id="type">WIP</span>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<script src="main.js"></script>
|
<script src="main.js"></script>
|
||||||
|
|||||||
13
main.js
13
main.js
@ -55,25 +55,26 @@ const mapper = document.getElementById("mapper");
|
|||||||
const difficulty = document.getElementById("difficulty");
|
const difficulty = document.getElementById("difficulty");
|
||||||
const characteristicIcon = document.getElementById("characteristicIcon");
|
const characteristicIcon = document.getElementById("characteristicIcon");
|
||||||
const difficultyLabel = document.getElementById("difficultyLabel");
|
const difficultyLabel = document.getElementById("difficultyLabel");
|
||||||
const bsrKey = document.getElementById("bsrKey");
|
|
||||||
const type = document.getElementById("type");
|
const type = document.getElementById("type");
|
||||||
|
const bsrKey = document.getElementById("bsrKey");
|
||||||
|
|
||||||
/** @param {MapInfoChanged} data */
|
/** @param {MapInfoChanged} data */
|
||||||
async function updateMapInfo(data) {
|
async function updateMapInfo(data) {
|
||||||
const custom = data.level_id.startsWith("custom_level_");
|
const custom = data.level_id.startsWith("custom_level_");
|
||||||
|
const wip = custom && data.level_id.endsWith("WIP");
|
||||||
cover.style.backgroundImage = data.coverRaw ? `url("data:image/jpeg;base64,${data.coverRaw}")` : "";
|
cover.style.backgroundImage = data.coverRaw ? `url("data:image/jpeg;base64,${data.coverRaw}")` : "";
|
||||||
title.textContent = data.name || "";
|
title.textContent = data.name || "";
|
||||||
subTitle.textContent = data.sub_name || "";
|
subTitle.textContent = data.sub_name || "";
|
||||||
artist.textContent = data.artist || "";
|
artist.textContent = data.artist || "";
|
||||||
mapper.textContent = data.mapper || "";
|
mapper.textContent = data.mapper || "";
|
||||||
difficulty.textContent = data.difficulty.replace("Plus", "\u2009+") || "";
|
difficulty.textContent = data.difficulty.replace("Plus", " +") || "";
|
||||||
characteristicIcon.setAttribute("src", `images/characteristic/${data.characteristic}.svg`);
|
characteristicIcon.src = `images/characteristic/${data.characteristic}.svg`;
|
||||||
difficultyLabel.textContent = ""; // BS+ does not provide label
|
difficultyLabel.textContent = ""; // BS+ does not provide label
|
||||||
bsrKey.textContent = data.BSRKey || ""; // Always empty?
|
type.textContent = !custom ? "OST" : wip ? "WIP" : "";
|
||||||
type.textContent = !custom ? "OST" : data.level_id.endsWith(" WIP") ? "WIP" : "";
|
bsrKey.textContent = data.BSRKey || "???"; // Always empty?
|
||||||
|
|
||||||
// Fetch extra info from BeatSaver
|
// Fetch extra info from BeatSaver
|
||||||
if (custom) {
|
if (custom && !wip) {
|
||||||
document.body.classList.add("loading");
|
document.body.classList.add("loading");
|
||||||
try {
|
try {
|
||||||
const response = await fetch(`https://api.beatsaver.com/maps/hash/${data.level_id.substring(13, 53)}`);
|
const response = await fetch(`https://api.beatsaver.com/maps/hash/${data.level_id.substring(13, 53)}`);
|
||||||
|
|||||||
@ -112,3 +112,7 @@ body:not([data-game-state="Playing"]) {
|
|||||||
content: "!bsr ";
|
content: "!bsr ";
|
||||||
letter-spacing: normal;
|
letter-spacing: normal;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#type:not(:empty) + #bsrKey {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|||||||
4
types.d.ts
vendored
4
types.d.ts
vendored
@ -64,5 +64,7 @@ type BeatSaberPlusEvent = HandshakeEvent | GameStateEvent | ResumeEvent | PauseE
|
|||||||
type MapInfoChanged = MapInfoChangedEvent["mapInfoChanged"];
|
type MapInfoChanged = MapInfoChangedEvent["mapInfoChanged"];
|
||||||
|
|
||||||
interface Document {
|
interface Document {
|
||||||
getElementById(elementId: string): HTMLElement; // Assume non-null
|
// Assume non-null
|
||||||
|
getElementById(elementId: `${string}Icon`): HTMLImageElement;
|
||||||
|
getElementById(elementId: string): HTMLElement;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user