Add player id in ranking and ally members
Some checks failed
Continuous Deployment / lint (push) Successful in 30s
Continuous Deployment / deploy-chrome (push) Failing after 21s
Continuous Deployment / deploy-firefox (push) Successful in 4m38s

This commit is contained in:
2025-11-24 18:45:41 +01:00
parent 9a3c9c1401
commit 8d8ccd8e9d
4 changed files with 29 additions and 4 deletions

View File

@@ -27,7 +27,9 @@ function createCustomElement(tag, attrs, text, style) {
let elt = document.createElement(tag);
if (attrs) {
for (let [key, value] of Object.entries(attrs)) {
elt.setAttribute(key, value.toString());
if (value !== null) {
elt.setAttribute(key, value.toString());
}
}
}
if (text) {
@@ -163,6 +165,25 @@ function main() {
let sub = urlParams.get("sub");
let sendCommandForm = document.getElementById("sendCommandForm");
/* Add player id on ranking */
if (section === "ranking" || (section === "ally" && module === "members")) {
let mainContentPane = document.getElementsByClassName("contentpane")[1];
let borderListTable = mainContentPane.getElementsByClassName("borderlist")[0];
let playerRows = borderListTable.getElementsByTagName("tr");
let headerCells = playerRows[0].getElementsByTagName("th");
let idHeaderCell = createCustomElement("th", {"class": headerCells[0].getAttribute("class")}, "Id");
playerRows[0].insertBefore(idHeaderCell, headerCells[1]);
for (let i = 1; i < playerRows.length; i ++) {
let playerCells = playerRows[i].getElementsByTagName("td");
let playerProfileLink = playerCells[1].getElementsByTagName("a")[0].getAttribute("href");
let idValue = playerProfileLink.replace(/^.*id=(\d+)$/, "$1");
let idCell = createCustomElement("td", {"class": playerCells[0].getAttribute("class")}, idValue);
playerRows[i].insertBefore(idCell, playerCells[1]);
}
}
/* Display unit-points on user profile */
if (section === "info_player" && (module === "profile" || module === null)) {
let mainContentPane = document.getElementsByClassName("contentpane")[1];