From 0ee38b44df06aa17d540557805f0945cd0ec2dfa Mon Sep 17 00:00:00 2001 From: NetworkCats Date: Mon, 23 Mar 2026 18:23:42 +0800 Subject: [PATCH] fix: ensure city label is available for JS-rendered alt IP rows When the primary IP lacks city data, the conditional row is absent from the DOM, so readLabels() cannot scrape the translated label. Embed translated labels as data-l-* attributes on the element so they are always available regardless of which rows are rendered. --- static/script.js | 9 +++++++++ templates/index.html | 3 ++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/static/script.js b/static/script.js index ed77c89..5c99c2b 100644 --- a/static/script.js +++ b/static/script.js @@ -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"); diff --git a/templates/index.html b/templates/index.html index 5a70036..92557af 100644 --- a/templates/index.html +++ b/templates/index.html @@ -77,7 +77,8 @@ -
+
{% if !asn.is_empty() %}