diff --git a/main.js b/main.js index 6136e51..fc090f6 100644 --- a/main.js +++ b/main.js @@ -7805,11 +7805,23 @@ async function main() { }); var currentTimezone = Intl.DateTimeFormat().resolvedOptions().timeZone; - + if (timezones.includes(currentTimezone)) { - var el = getById("languagesList").querySelector("li a[data-tz*='" + currentTimezone + "']"); // select language li - el.parentElement.removeChild(el); // remove it - getById("languagesList").insertBefore(el, getById("languagesList").querySelector("li:nth-child(2)")); // insert it after English + var list = getById("languagesList"); + // Find the link element matching the timezone + var el = list.querySelector("li a[data-tz*='" + currentTimezone + "']"); + + if (el) { + var targetLi = el.parentElement; // Get the parent
  • + var firstLi = list.querySelector("li:first-child"); // Get the first li (English) + + // Only move if it's not already the first or second element + if (targetLi && firstLi && targetLi !== firstLi && targetLi !== firstLi.nextSibling) { + // Insert the
  • after the first element (English) + list.insertBefore(targetLi, firstLi.nextSibling); + // The original
  • is automatically removed from its old position when inserted elsewhere. + } + } } var visAudioTimeout = null;