diff options
| author | Pinapelz <yukais@pinapelz.com> | 2025-04-06 23:00:20 -0700 |
|---|---|---|
| committer | Pinapelz <yukais@pinapelz.com> | 2025-04-06 23:00:20 -0700 |
| commit | d837a235d820891964f370101a699600df50b028 (patch) | |
| tree | a04aadaf69a1963887ef10efe25abf494f870879 /chuni/tachi/tachi_to_tachi_pb.js | |
| parent | 172613c9c0b37e33a71b6875fcc6d5680880f7a2 (diff) | |
chunithm_tachi: bookmarklets for exporting playdata from tachi to batch-manual (MYT)
Diffstat (limited to 'chuni/tachi/tachi_to_tachi_pb.js')
| -rw-r--r-- | chuni/tachi/tachi_to_tachi_pb.js | 96 |
1 files changed, 96 insertions, 0 deletions
diff --git a/chuni/tachi/tachi_to_tachi_pb.js b/chuni/tachi/tachi_to_tachi_pb.js new file mode 100644 index 0000000..b0dccb1 --- /dev/null +++ b/chuni/tachi/tachi_to_tachi_pb.js @@ -0,0 +1,96 @@ +javascript:void(function () { + function parseChunithmTable() { + const rows = document.querySelectorAll("table.table tbody tr"); + const difficultyMap = { + E: "Expert", + A: "Advanced", + B: "Basic", + M: "Master" + }; + const results = { + meta: { + game: "chunithm", + playtype: "Single", + service: "Tachi to Tachi PB Export", + }, + scores: [] + }; + + for (let i = 0; i < rows.length; i += 3) { + const row = rows[i]; + if (!row) continue; + + const cells = row.querySelectorAll("td"); + if (cells.length < 11) continue; + + let difficulty = cells[1].innerText.trim().replace(/\n/, " ").split(" ")[0]; + if (difficulty.length === 1) { + difficulty = difficultyMap[difficulty] || difficulty; + } + + const songAnchor = cells[3].querySelector("a"); + const title = songAnchor?.childNodes[0]?.textContent.trim() || ""; + const artist = songAnchor?.querySelector("small")?.textContent.trim() || ""; + + const scoreRank = cells[5].querySelector("strong")?.innerText.trim() || ""; + const scoreValue = parseInt( + cells[5].innerText.replace(scoreRank, "").trim().replace(/,/g, "") + ); + + const judgementText = cells[6].innerText.trim(); + const parts = judgementText.split("-").map((x) => parseInt(x.trim())); + const [jcrit, justice, attack, miss] = parts; + + const fastSlowMatch = judgementText.match(/\(F:(\d+)\s+S:(\d+)\)/); + const fast = fastSlowMatch ? parseInt(fastSlowMatch[1]) : undefined; + const slow = fastSlowMatch ? parseInt(fastSlowMatch[2]) : undefined; + + const lamp = cells[7].innerText.trim(); + const rating = parseFloat(cells[8].innerText.trim()); + + const timestampText = cells[10].innerText.trim().split("\n"); + const timestampString = timestampText[1]?.trim() || ""; + const timeAchieved = timestampString ? new Date(timestampString).getTime() : 0; + + const score = { + score: scoreValue, + lamp, + matchType: "songTitle", + difficulty, + identifier: title, + artist, + judgements: { + jcrit, + justice, + attack, + miss, + }, + timeAchieved + }; + + if (fast !== undefined && slow !== undefined) { + score.judgements.fast = fast; + score.judgements.slow = slow; + } + + results.scores.push(score); + } + + return results; + } + + function downloadJSON(data) { + const blob = new Blob([JSON.stringify(data, null, 2)], { + type: "application/json", + }); + const url = URL.createObjectURL(blob); + const a = document.createElement("a"); + a.href = url; + a.download = "chunithm_table.json"; + a.click(); + URL.revokeObjectURL(url); + } + + const data = parseChunithmTable(); + downloadJSON(data); +})(); |
