Advertisement
Gotolei

gunnerkrigg.com imagus sieve

Nov 9th, 2015 (edited)
288
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.20 KB | None | 0 0
  1. Import text:
  2.  
  3. {"Gunnerkrigg":{"link":"gunnerkrigg\\.com\\/((?:index\\.php)?\\?p|archive\\_page\\.php\\?comicID)=(\\d+)","res":":\nvar doc = $._, latest, p, size = 8, n = [], imgs = [], i = 1, max = -1, tmp, s, lp;\n\np = ($[1].slice(-2) == '?p')? parseInt($[2]) : parseInt($[2]) - 2;\n\n$ = $._.match(/<select\\s+aria-label=\"chapter\"\\s+name=\"chapter\"[^>]*?>[\\s\\S]*?<\\/select\\>/gi);\n\nlp = doc.match(/<a\\s+href=\"\\?p=(\\d+)\"[^>]*?>\\s*<img.+?latest\\_a\\.jpg/gi);\nlatest = (lp)? parseInt(lp[0].replace(/<a\\s+href=\"\\?p=(\\d+)\"[^>]*?>\\s*<img.+?latest\\_a\\.jpg/gi, '$1')): p;\n\nif($)\n{\n n = $[0].match(/<option value=[\"'](\\d+)[\"']>/gi);\n\n var l = n.length-1;\n while(i <= l && max == -1)\n {\n tmp = parseInt(n[i].replace(/<option value=[\"'](\\d+)[\"']>/gi, '$1'));\n if(tmp > p) max = tmp\n else i++;\n }\n}\n\nif(max == -1) max = latest + 1\nelse if(max == p) max = p+1;\n\nfor(j = p; j < max; ++j)\n{\n s = j + \"\";\n while(s.length < size) s = \"0\" + s;\n imgs.push('http://gunnerkrigg.com/comics/' + s + '.jpg');\n}\n\nreturn imgs.slice(0).map(function(x){ return [x]});"}}
  4.  
  5. credit to /u/hoaxnx: https://www.reddit.com/r/imagus/comments/3mlq7w/requesthelp_with_adding_leading_zeros/cvhivc5
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement