http://userscripts.org/scripts/review/8551
AutoPagerize version: 0.0.36 2009-03-08T14:43:37+09:00
var launchAutoPager = function(list) { if (list.length == 0) { return } for (var i = 0; i < list.length; i++) { try { if (ap) { return } else if (!location.href.match(list[i].url)) { } else if (!getFirstElementByXPath(list[i].nextLink)) { // FIXME microformats case detection. // limiting greater than 12 to filter microformats like SITEINFOs. if (list[i].url.length > 12 ) { debug("nextLink not found.", list[i].nextLink) } } else if (!getFirstElementByXPath(list[i].pageElement)) { if (list[i].url.length > 12 ) { debug("pageElement not found.", list[i].pageElement) } } else { ap = new AutoPager(list[i]) return } } catch(e) { log(e) continue } } }
これを、
var launchAutoPager = function(list) { if (list.length == 0) { return } for (var i = 0; i < list.length; i++) { try { if (ap) { return } else if (!location.href.match(list[i].url) && !getFirstElementByXPath(list[i].url)) { } else if (!getFirstElementByXPath(list[i].nextLink)) { // FIXME microformats case detection. // limiting greater than 12 to filter microformats like SITEINFOs. if (list[i].url.length > 12 ) { debug("nextLink not found.", list[i].nextLink) } } else if (!getFirstElementByXPath(list[i].pageElement)) { if (list[i].url.length > 12 ) { debug("pageElement not found.", list[i].pageElement) } } else { ap = new AutoPager(list[i]) return } } catch(e) { log(e) continue } } }
って、やるだけで、url に XPath 式がつかえるのかなあ?
ということで試してみた。autopagerize.user.js 本体を上のとおりに書き換えて、SITEINFO の url を XPath 式 (http://d.hatena.ne.jp/taizooo/20090323/1237801018) に書き換えてみた。
http://wedata.net/items/681?rev=32918
url ^http://[^.]+\.tumblr\.com/(?:page|tagged|search|$)
これを、こう書き換え。ore ore SITEINFO に追記してみた。
http://twwp.jottit.com/autopagerize_siteinfo?r=139
url: id("tumblr_controls")[self::iframe]
そしたら、独自ドメインな tumblr でも、あっけなく動いてしまいました。http://toukubo.com/ とかで。
文字列のmatchとXPathだとパフォーマンスがかなり違うから、個人的にはXPathは避けたいかな。
http://twitter.com/os0x/statuses/1381254544
うーん、次の手を考えるかあ。
XPath 式かどうかを文字列の match とかで評価してから XPath 探索するっていうのだとどうだろう? URL かどうかを見るんでもいいんだけど(
http://twitter.com/taizooo/statuses/1382637901
なんとなくだけど、その文字列が URL であるか判定するよりも XPath 式かどうかを判定する方が楽そう。'^//' か '^id(' なんつー正規表現くらいで十分なんじゃないかと(ハイ、いつもの当てずっぽうです)。
urlにXPathはやらないな。パフォーマンスとかじゃなくて。
http://twitter.com/swdyh/statuses/1382960523
あら残念。
違う話だけど、chromeの@matchみたいにするっていうのは少し考えてる
http://twitter.com/swdyh/statuses/1382976027
???