It does get more complicated. I cut certain chunks from the HSX portfolio, in Port Monkey. The code is commented, but, would still be difficult to grasp, for a new programmer. I have to review it myself, when I dig into it from time to time.
If you're thinking along the lines of eliminating certain poster comments from view, then, you would want to review my old Killfile code. Also pretty involved.
In both cases, there are a number of examples of finding specific things with document.evaluate. For heavy text filtering, you'd probably use "regular expressions," which I'm no good at.