3 ms·
Adding the following lines to the script posted by OP should add buttons for doing just that: var collapseButton = document.createElement("button") col
by alin23 5y ago
Adding the following lines to the script posted by OP should add buttons for doing just that:
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)