Fold comments

By Johan Sundström Last update Jun 8, 2009 — Installed 294 times.


Script Summary: Folds comments and the like by XPath expressions. Whenever entering a page on a supported site, with comments, it counts and folds them, so you see the real size of the document, in your browser scrollbar, and can zoom to its end if you'd want to.

Script homepage

New features (2009-06-01): When finding comments to fold, it also marks up the page with the part of the pagination microformat that custom keyboard bindings user script uses for paging through things with m/p, so you, once unfolded, can zip through comments one at a time without shifting eye focus, making skimming much easier.

Added support for XPath bookmarks, so a link referencing http://code.google.com/p/support/wiki/DVCSAnalysis#xpath:(id("commentlist")//*[@class="artifactcomment"])[15], for instance, will unfold that section. (Not perfect, as it performs the test after having already folded the section, which makes brittle absolute XPath references like /html/body/p[12] miss the mark, as folding has already changed page structure.)

The above two features get really good in combination with the update I did to custom keyboard bindings that automatically sets the url fragment to whichever place in the page you have paged to. (That functionality used to be available only after hitting ?, which was too obscure for me to even remember I once implemented it.)

Added support for folding rules for IDNA/punicode encoded host names like räksmörgås.nu.

New feature (2009-05-24): When you arrive at a page through a permalink to a comment, don't fold away that comment section on pageload. Similarly, when clicking an intra-page link to some section that is inside a fold, unfold that section automatically.

New feature: Now shows how much was folded too, like "Toggle 126 comments (67 pagefuls)" for this article.

This is presently a geek-UI-only hack that folds comments on blogs and magazines I occasionally read - paulgraham.com, www.codinghorror.com, steve-yegge.blogspot.com, www.antipope.org and blogg.aftonbladet.se, to name a few. If you're geeky enough to know XPath, you can easily tailor it to cater more sites by hand tweaking the top of the script; instructions in a nearby documentation comment.

(It @includes http://* not because it does anything across the entire web, but because I find it way too hasslesome to expand the @include directives when I add new sites -- feel free to limit it only to the sites you use it for.)