Skip to content

Instantly share code, notes, and snippets.

@edvakf
Created June 8, 2010 18:10
Show Gist options
  • Select an option

  • Save edvakf/430418 to your computer and use it in GitHub Desktop.

Select an option

Save edvakf/430418 to your computer and use it in GitHub Desktop.
--- oAutoPagerize.js.orig 2010-06-08 14:09:09.000000000 -0400
+++ oAutoPagerize.js 2010-06-08 14:08:45.000000000 -0400
@@ -125,7 +125,7 @@
,exampleUrl: 'http://eow.alc.co.jp/%E3%81%82%E3%82%8C/UTF-8/ http://eow.alc.co.jp/are'
}
,{
- url: '^http://matome\\.naver\\.jp/\w+'
+ url: '^http://matome\\.naver\\.jp/odai/'
,nextLink: '//a[@class="next"]'
,pageElement: 'id("itemDetail")/li'
,exampleUrl: 'http://matome.naver.jp/odai/2127476492987286301'
@@ -213,35 +213,32 @@
setTimeout(function(){if (window.AutoPagerize) AutoPagerize.addDocumentFilter(alc);},500);
});
} else if (location.host==='matome.naver.jp') {
- var info, href = location.href;
- SITEINFO.some(function(site){
- var r = new RegExp(site.url);
- var m = !r.test('http://a') && r.test(href);
- if (m) {
- info = site;
- return true;
- }
- });
- if (info) {
- miscellaneous.push(function(utils){
- var X = utils.getFirstElementByXPath;
- var naver = function(doc){
- var next = X(info.nextLink, doc);
- if (next){
- if (next.getAttribute('onclick')) {
- var nextpage = next.getAttribute('onclick').match(/(\d+)/)[1];
- var form=document.getElementsByName('missionViewForm')[0];
- var param=[].slice.call(form).map(function(i){return i.name+'='+(i.name==='page'?nextpage:i.value);}).join('&');
- next.href = location.pathname+'?'+param;
- } else {
- next.parentNode.removeChild(next);
- }
- }
- };
- naver(document);
- setTimeout(function(){if (window.AutoPagerize) AutoPagerize.addDocumentFilter(naver);},500);
+ miscellaneous.push(function(utils){
+ var info, href = location.href;
+ TOP_SITEINFO.concat(SITEINFO, BOTTOM_SITEINFO).some(function(site){
+ var r = new RegExp(site.url);
+ var m = !r.test('http://a') && r.test(href);
+ if (m) {
+ info = site;
+ return true;
+ }
});
- }
+ if (!info) return;
+ var X = utils.getFirstElementByXPath;
+ var naver = function(doc){
+ var next = X(info.nextLink, doc);
+ try{
+ var nextpage = next.getAttribute('onclick').match(/goPage\(\s*(\d+)\s*\)/)[1];
+ var form=document.getElementsByName('missionViewForm')[0];
+ var param=[].slice.call(form).map(function(i){return i.name+'='+(i.name==='page'?nextpage:i.value);}).join('&');
+ next.href = location.pathname+'?'+param;
+ }catch(e){// last page
+ next.removeAttribute('href');
+ }
+ };
+ naver(document);
+ setTimeout(function(){if (window.AutoPagerize) AutoPagerize.addDocumentFilter(naver);},500);
+ });
}
if (HISTORY_MODE_FAST && window.opera) {
opera.addEventListener('AfterEvent.GM_AutoPagerizeNextPageLoaded', function(){
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment