AOL DiaryをAutoPagerizeる

AOL Diary は Autopagerize 泣かせ - twwpの件。
まずSITEINFOはこんな感じかなぁ。

url:          'http://diary.jp.aol.com/(?:applet/)?\\w+/',
nextLink:     'descendant::a[contains(@href,"/archive?")][last()]',
pageElement:  'id("mainbox")/div',
exampleUrl:   'http://diary.jp.aol.com/juicyfruits/'
url:          'http://diary.jp.aol.com/(?:applet/)?\\w+/',
nextLink:     'descendant::a[contains(@href,"/archive?")][last()]',
pageElement:  'id("center")/div/*[not(@class="text" or @class="menuRight" or @class="rss")]',
exampleUrl:  'http://diary.jp.aol.com/quadrille/'

全然構造が違うページをexampleUrl2にした別SITEINFOに分けたけど、もっとバリエーションありそうな感じ。

で、例によってAutoIncrementer pluginでaddDocumentFilter

window.AutoPagerize.addDocumentFilter(function(doc,req){
	var a = getElementsByXPath('descendant::a[starts-with(@href,"./")]',doc);
	a.forEach(function(a){
		a.href = req.replace(/(.*)\/.*/,'$1/') + a.getAttribute('href').replace(/^\.\//,'');
	});
});

./で始まっている相対パスを絶対パスに書き換え。addDocumentFilterに渡す関数は第2引数にrequestしたURLが入ってくるので、それを使ってパスを作ってみる。