globalThis.addEventListener("DOMContentLoaded", () => { const selector = ".colspan-full"; const elements = document.querySelectorAll(selector); for (const e of elements) { let table = e.parentElement; if (table == null) continue; while (table?.tagName.toLowerCase() !== "table") { table = table?.parentElement ?? null; } if (table == null) console.error("couldn't find the table!"); const columnCount = table .querySelector("thead") ?.querySelector("tr") ?.querySelectorAll("th, td").length ?? 0; e.setAttribute("colspan", columnCount.toString()); } });