fix: ensure city label is available for JS-rendered alt IP rows

When the primary IP lacks city data, the conditional <tr data-label="city">
row is absent from the DOM, so readLabels() cannot scrape the translated
label. Embed translated labels as data-l-* attributes on the <table> element
so they are always available regardless of which rows are rendered.
This commit is contained in:
NetworkCats
2026-03-23 18:23:42 +08:00
parent c2247fc4a6
commit 0ee38b44df
2 changed files with 11 additions and 1 deletions
+9
View File
@@ -238,6 +238,15 @@ function initAltIp(root, section) {
function readLabels() {
const labels = {};
const table = root.querySelector(".info-table");
if (table) {
for (const [attr, val] of Object.entries(table.dataset)) {
if (attr.startsWith("l")) {
const key = attr.slice(1).toLowerCase();
if (key) labels[key] = val;
}
}
}
for (const row of root.querySelectorAll(".info-table tbody tr")) {
const key = row.getAttribute("data-label");
const th = row.querySelector("th");