mirror of
https://github.com/NetworkCats/rustyip.git
synced 2026-11-13 16:17:46 +00:00
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:
@@ -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");
|
||||
|
||||
Reference in New Issue
Block a user