Gotolei

gunnerkrigg.com imagus sieve

Nov 9th, 2015
164
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. {"gunnerkrigg.com":{"link":"gunnerkrigg\\.com/(\\?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] == '?p')? parseInt($[2]) : parseInt($[2]) - 2;\n\n$ = $._.match(/<select\\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]});","note":"credit to /u/hoaxnx: https://www.reddit.com/r/imagus/comments/3mlq7w/requesthelp_with_adding_leading_zeros/cvhivc5"}}
RAW Paste Data