var collapseButton = document.createElement("button")
collapseButton.textContent = "Collapse level 2 comments"
collapseButton.onclick = (event) => document
.querySelectorAll('td[indent="1"]+td+td.default .togg')
.forEach((button) => {
if (button.textContent == "[–]") {
button.click()
}
})
var expandButton = document.createElement("button")
expandButton.textContent = "Expand level 2 comments"
expandButton.onclick = (event) => document
.querySelectorAll('td[indent="1"]+td+td.default .togg')
.forEach((button) => {
if (button.textContent != "[–]") {
button.click()
}
})
var table = document.querySelector("table.comment-tree")
table.parentNode.insertBefore(collapseButton, table)
table.parentNode.insertBefore(expandButton, table)HN should copy this feature. The top thread dominates the discussion all too often.
[ ...document.querySelectorAll('td.ind[indent="1"] + td.votelinks + td.default .comhead > .togg') ].forEach(div => div.click()) javascript:if (typeof hn_next_comment_to_jump_to == 'undefined') { pkqcbcnll = 0 }; document.querySelectorAll("img[src='s.gif'][width='0']")[hn_next_comment_to_jump_to++].scrollIntoView(true); javascript:if (typeof hn_next_comment_to_jump_to == 'undefined') { hn_next_comment_to_jump_to = 0 }; document.querySelectorAll("img[src='s.gif'][width='0']")[hn_next_comment_to_jump_to++].scrollIntoView(true);
Thanks for this!Looking at settings and links on the page I don't see any functionality like you describe.
You mentioned that the "toggle all comments" button is broken, could you elaborate a bit more on that, and if possible open a GitHub issue for it? Thanks a lot :D.
Apart from that, with RHN you can navigate through the comments using the "J" and "K" keyboard keys and Press "Enter" on the highlighted comment to toggle it. Hope that helps too, cheers :)
Well, I tried the [toggle all comments] button on a couple of stories before posting my comment, and it was only toggling the first comment. But I did more testing for this reply, and now it’s working as advertised. I can’t explain that, but if I every figure out the conditions that prevent it from working, I’ll open an issue.