stock.xchngのSITEINFO
oAutoPagerizeのSITEINFO追加 - 0xFFで書いたstock.xchngのSITEINFOはoAutoPagerizeでは問題ないんだけど、Firefoxではbase要素のせいで3ページ目でエラーが。。
というのも、nextを取得する際に、その要素はページには追加されていないので、base指定による影響を受けない。
そのため、http://www.sxc.hu/category/1091/2の最後の/を基点として、http://www.sxc.hu/category/1091/category/1091/3というURLを取得してしまう。
残念ながら、こういうのはXPathをどうこうしても解決できない。
というわけで、AutoPagerizeをhackしてgetNextURLを書き換えてしまうGreasemonkeyを書いてみた。
// ==UserScript== // @name stock.xchng basefix // @namespace http://ss-o.net/ // @include http://www.sxc.hu/category/* // ==/UserScript== if (window.AutoPagerize) { var autopager = eval("ap", window.AutoPagerize.addFilter); if (autopager) { // override AutoPagerize#getNextURL var getNextURL = autopager.getNextURL; var getFirstElementByXPath = eval("getFirstElementByXPath", autopager); autopager.getNextURL = function(xpath, doc){ var next = getFirstElementByXPath(xpath, doc); if (next) { document.body.appendChild(next); var next_value = next.href || next.action || next.value; document.body.removeChild(next); return next_value; } } } }
nextの値を取得する前にページに追加して、取得したら削除してしまう。
これでbase要素の補正を受けてくれるので、何とか動いてくれました。やれやれ。