aboutsummaryrefslogtreecommitdiffstats
path: root/chuni/tachi/tachi_to_tachi_session.js
diff options
context:
space:
mode:
authorPinapelz <yukais@pinapelz.com>2025-04-06 23:00:20 -0700
committerPinapelz <yukais@pinapelz.com>2025-04-06 23:00:20 -0700
commitd837a235d820891964f370101a699600df50b028 (patch)
treea04aadaf69a1963887ef10efe25abf494f870879 /chuni/tachi/tachi_to_tachi_session.js
parent172613c9c0b37e33a71b6875fcc6d5680880f7a2 (diff)
chunithm_tachi: bookmarklets for exporting playdata from tachi to batch-manual (MYT)
Diffstat (limited to 'chuni/tachi/tachi_to_tachi_session.js')
-rw-r--r--chuni/tachi/tachi_to_tachi_session.js82
1 files changed, 82 insertions, 0 deletions
diff --git a/chuni/tachi/tachi_to_tachi_session.js b/chuni/tachi/tachi_to_tachi_session.js
new file mode 100644
index 0000000..05fe300
--- /dev/null
+++ b/chuni/tachi/tachi_to_tachi_session.js
@@ -0,0 +1,82 @@
+javascript: void (function () {
+ function parseChunithmTable() {
+ const rows = document.querySelectorAll("table.table tbody tr");
+ const results = {
+ meta: {
+ game: "chunithm",
+ playtype: "Single",
+ service: "Tachi to Tachi Export",
+ },
+ scores: [],
+ };
+ for (let i = 0; i < rows.length; i++) {
+ const row = rows[i];
+ const cells = row.querySelectorAll("td");
+ if (
+ cells.length < 9 ||
+ row.classList.contains("expandable-pseudo-row") ||
+ row.classList.contains("fake-row")
+ )
+ continue;
+ let difficultyCell = cells[0];
+ let difficultyText = difficultyCell.innerText.trim();
+ let difficultyMatch = difficultyText.match(
+ /(MASTER|EXPERT|ADVANCED|BASIC|M|E|A|B)/i,
+ );
+ let difficulty = difficultyMatch
+ ? difficultyMatch[0].toUpperCase()
+ : "UNKNOWN";
+ const difficultyMap = {
+ M: "Master",
+ E: "Expert",
+ A: "Advanced",
+ B: "Basic",
+ };
+ if (difficulty.length === 1)
+ difficulty = difficultyMap[difficulty] || difficulty;
+ const songAnchor = cells[2].querySelector("a");
+ const title = songAnchor?.childNodes[0]?.textContent.trim() || "";
+ const artist =
+ songAnchor?.querySelector("small")?.textContent.trim() || "";
+ const scoreRank =
+ cells[3].querySelector("strong")?.innerText.trim() || "";
+ const scoreValue = parseInt(
+ cells[3].innerText.replace(scoreRank, "").trim().replace(/,/g, ""),
+ );
+ const judgementText = cells[4].innerText.trim();
+ const parts = judgementText.split("-").map((x) => parseInt(x.trim()));
+ const [jcrit, justice, attack, miss] = parts;
+ const lamp = cells[5].innerText.trim();
+ const rating = parseFloat(cells[6].innerText.trim());
+ const timestampCellLines = cells[7].innerText.trim().split("\n");
+ const dateString =
+ timestampCellLines.find((line) => /\w+ \d+, \d+/.test(line)) || "";
+ const timeAchieved = dateString ? new Date(dateString).getTime() : 0;
+ results.scores.push({
+ score: scoreValue,
+ lamp,
+ matchType: "songTitle",
+ difficulty,
+ identifier: title,
+ artist,
+ rating,
+ judgements: { jcrit, justice, attack, miss },
+ timeAchieved,
+ });
+ }
+ 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);
+})();
send patches to the email below
yukais@pinapelz.com
include the subject [PATCH repo_name]
pinapelz.com
homepage