Skip to content

Latest commit

 

History

History
191 lines (170 loc) · 3.49 KB

index.md

File metadata and controls

191 lines (170 loc) · 3.49 KB

Curse of Aros - All Ranks

Name:
 Lone Wolf
Name Rank XP Page
Overall
Melee
Magic
Mining
Smithing
Woodcutting
Crafting
Fishing
Cooking
Tailoring

Made by https://kaue.me

Data from https://curseofaros.com

<style> table { padding: 2px; border-collapse: collapse; } th, td { border: 1px solid black; padding: 2px; } td { text-align: right; } .left { text-align: left; } </style> <script> const MAX_PAGE = 1000; const DEFAULT_NAME = "Bot"; const DEFAULT_LW = "0"; const INDEX = { "rank": 1, "xp": 2, "page": 3, }; const skills = ["overall", "melee", "magic", "mining", "smithing", "woodcutting", "crafting", "fishing", "cooking", "tailoring"]; function byId(id) { return document.getElementById(id); } function setCell(row, index, value) { row.cells[INDEX[index]].innerHTML = value; } let search = async () => { const name = byId("name").value; const table = byId("table"); const lw = byId("lw").checked ? "1" : "0"; for (let i = 0; i < skills.length; i++) { const row = table.rows[i + 1]; let suffix = skills[i]; if (suffix != "") { suffix = "-" + suffix; } let found = false; let rank = 0; for (let page = 0; page < MAX_PAGE; page++) { setCell(row, "page", page + 1); const url = "https://www.curseofaros.com/highscores" + suffix + ".json?p=" + page + "&lw=" + lw; const response = await fetch(url); const json = await response.json(); for (let i = 0; i < json.length; i++) { rank++; const item = json[i]; if (item.name != name) { continue } setCell(row, "rank", rank); setCell(row, "xp", item.xp); found = true; break } if (found) { break; } } if (!found) { console.log("name", name, "not found"); } } }; function main() { const queryString = window.location.search; const urlParams = new URLSearchParams(queryString); let name = DEFAULT_NAME; if (urlParams.has("name")) { got = urlParams.get("name"); if (got != "") { name = got; } } byId("name").value = name; let lw = DEFAULT_LW; if (urlParams.has("lw")) { got = urlParams.get("lw"); if (got != "") { lw = got; } } byId("lw").checked = lw == "on"; search(); } main(); </script>