I use this bookmarklet to collapse all the top comment threads on a hacker news story. I usually do this for stories where there's a lot of threads, and use the currently open thread is my "bookmark". It collapses 1 thread a second (any faster and the toggle request may not succeed):
javascript: var TIMER_WAIT = 1000; var timer = 0; var topComment = []; var list = document.getElementsByClassName('togg'); for (let item of list) { if (item.parentElement.parentElement.parentElement.parentElement.getElementsByTagName('img')[0].width == 0) topComment.push(item) }; for (let item of topComment) { setTimeout(() => { console.log("toggling comment by " + item.parentNode.getElementsByClassName('hnuser')[0].innerText); item.click(); }, timer + TIMER_WAIT); timer = timer + TIMER_WAIT; }