Skip to content

Instantly share code, notes, and snippets.

@vishnuharidas
Last active January 4, 2026 00:01
Show Gist options
  • Select an option

  • Save vishnuharidas/abadbbf1a74c6a32283d7b6dca1f4032 to your computer and use it in GitHub Desktop.

Select an option

Save vishnuharidas/abadbbf1a74c6a32283d7b6dca1f4032 to your computer and use it in GitHub Desktop.
A tiny browser-console script for Hacker News that displays each comment's indentation level directly inside the comment cell.
function showIndentNumberInTDs({
selector = "td.ind",
attr = "indent",
className = "indent-label",
color = "#ff660088",
fontSize = "28px",
fontWeight = "600",
padding = "4px"
} = {}) {
const tds = document.querySelectorAll(selector);
tds.forEach(td => {
const n = parseInt(td.getAttribute(attr), 10);
if (!Number.isFinite(n)) return;
// Remove existing label if re-running
td.querySelectorAll(`:scope > .${className}`).forEach(el => el.remove());
// Ensure positioning context
if (getComputedStyle(td).position === "static") {
td.style.position = "relative";
}
const label = document.createElement("div");
label.className = className;
label.textContent = n;
Object.assign(label.style, {
position: "absolute",
top: padding,
right: padding,
color,
fontSize,
fontWeight,
lineHeight: "1",
pointerEvents: "none",
userSelect: "none",
zIndex: 1
});
td.appendChild(label);
});
return { updated: tds.length };
}
// Run it
showIndentNumberInTDs();
@vishnuharidas
Copy link
Author

Reason for this: I lost track of what I am reading on this thread: https://news.ycombinator.com/item?id=46473348

@vishnuharidas
Copy link
Author

Screenshot:
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment