<?xml version="1.0" encoding="UTF-8"?>
<post>
  <body>Potential candidates for unpagination is any page that was cookie-cutter-template-wise turned into multiple pages between which there are &quot;next&quot; links, or &quot;page 1..N&quot; links, of any sort. Anything you can craft an XPath expression for picking up on -- &lt;code&gt;//a[.=&quot;next&quot;]&lt;/code&gt; is an easy case, but it can be anything that is deterministic enough to be expressed in the language, which is very rich in its possibilities (peek at the very minimal &quot;source code&quot; of some of &lt;a href=&quot;http://userscripts.org/tags/microformat%20producer&quot;&gt;these scripts&lt;/a&gt; for inspiration, if you are new to it).

When I look for XPath expressions, I use Firebug's Inspect feature a lot -- open the Firebug console, click &quot;Inspect&quot; on top, and click on the next link. Let's say we're on page 2 right now and it comes up with an HTML structure that looks like this (a somewhat common and maybe-not-that-trivial one, for a budding XPath hacker):

&lt;code&gt;&lt;pre&gt;
&amp;lt;div id=&quot;comments&quot;&gt;
  &amp;lt;a href=&quot;...&quot;&gt;1&amp;lt;/a&gt; 2 &amp;lt;a href=&quot;...&quot;&gt;3&amp;lt;/a&gt;
&amp;lt;/div&gt;&lt;/pre&gt;&lt;/code&gt;

My strategy in this case will be &quot;among all the page links, select the first one that follows a not-just-whitespace text node&quot;, which will probably work on page 1 to N-1, which happens to be all pages we need a next link from. (For a tricky case where multiple strategies are needed, craft an expression like 'how-to-do-it-on-some-pages | how-to-do-it-on-other-pages | how-to-do-it-on-yet-other-pages | ...'.)

In this case, the above comes out, for instance (untested -- if you have some example page in mind though, feel free to name its URL), &lt;code&gt;id(&quot;comments&quot;)/a[(preceding-sibling::*[1])[length(normalize-space(.))&gt;0]]&lt;/code&gt;

It's easy to try the expression in Firebug; just try $x('id(&quot;comments&quot;)...') in the Firebug console and see what it found. If the first node is your next link, and if that is the case on not just this page, but any page in the sequence (try the first page, one in the middle somewhere, the last but one page and the last one -- which should come up empty), and you'll probably be reasonably certain you got it right.

Facebook evolves quicker than the frequency of my visits or active use of the site; my hack has in all likelihood rotted long ago.</body>
  <body-html>&lt;p&gt;Potential candidates for unpagination is any page that was cookie-cutter-template-wise turned into multiple pages between which there are &quot;next&quot; links, or &quot;page 1..N&quot; links, of any sort. Anything you can craft an XPath expression for picking up on -- &lt;code&gt;//a[.=&quot;next&quot;]&lt;/code&gt; is an easy case, but it can be anything that is deterministic enough to be expressed in the language, which is very rich in its possibilities (peek at the very minimal &quot;source code&quot; of some of &lt;a href=&quot;http://userscripts.org/tags/microformat%20producer&quot;&gt;these scripts&lt;/a&gt; for inspiration, if you are new to it).&lt;/p&gt;

&lt;p&gt;When I look for XPath expressions, I use Firebug's Inspect feature a lot -- open the Firebug console, click &quot;Inspect&quot; on top, and click on the next link. Let's say we're on page 2 right now and it comes up with an HTML structure that looks like this (a somewhat common and maybe-not-that-trivial one, for a budding XPath hacker):&lt;/p&gt;

&lt;p&gt;&lt;code&gt;&lt;pre&gt;
&amp;lt;div id=&quot;comments&quot;&gt;
  &amp;lt;a href=&quot;...&quot;&gt;1&amp;lt;/a&gt; 2 &amp;lt;a href=&quot;...&quot;&gt;3&amp;lt;/a&gt;
&amp;lt;/div&gt;&lt;/pre&gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;My strategy in this case will be &quot;among all the page links, select the first one that follows a not-just-whitespace text node&quot;, which will probably work on page 1 to N-1, which happens to be all pages we need a next link from. (For a tricky case where multiple strategies are needed, craft an expression like 'how-to-do-it-on-some-pages | how-to-do-it-on-other-pages | how-to-do-it-on-yet-other-pages | ...'.)&lt;/p&gt;

&lt;p&gt;In this case, the above comes out, for instance (untested -- if you have some example page in mind though, feel free to name its URL), &lt;code&gt;id(&quot;comments&quot;)/a[(preceding-sibling::*[1])[length(normalize-space(.))&gt;0]]&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;It's easy to try the expression in Firebug; just try $x('id(&quot;comments&quot;)...') in the Firebug console and see what it found. If the first node is your next link, and if that is the case on not just this page, but any page in the sequence (try the first page, one in the middle somewhere, the last but one page and the last one -- which should come up empty), and you'll probably be reasonably certain you got it right.&lt;/p&gt;

&lt;p&gt;Facebook evolves quicker than the frequency of my visits or active use of the site; my hack has in all likelihood rotted long ago.&lt;/p&gt;</body-html>
  <created-at type="datetime">2009-04-18T19:03:01Z</created-at>
  <forumable-id type="integer">23175</forumable-id>
  <forumable-type>Script</forumable-type>
  <id type="integer">112144</id>
  <topic-id type="integer">25064</topic-id>
  <updated-at type="datetime">2009-04-18T19:06:05Z</updated-at>
  <user-agent nil="true"></user-agent>
  <user-id type="integer">326</user-id>
</post>
