Advertisement
rg443

tumblr1

Jun 15th, 2013
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var cache1=cache1||{};
  2. // tumblr1("mindmayhem",304,"llnwd");
  3.  
  4. function tumblr1(){
  5.    var site=arguments[0]||"mindmayhem";
  6.    var pages=arguments[1]||304;
  7.    var filter=arguments[2];
  8.    // console.log(site,pages,filter);
  9.    for (var i=1;i<=pages;i++)setTimeout(get_url,(i-1)*100,"http://"+site+".tumblr.com/page/"+i,parse1);
  10.  
  11. function parse1(){
  12.    var a=this.match(/http:\/\/\S+.jpg/gim)||[];
  13.    // new RegExp("\\w+")
  14.    if (filter) a=a.filter(function(v){return new RegExp(filter).test(v)==false});
  15.    // a=a.map(function(v){return v.replace("24.","25.")})
  16.    a&&console.log(a.join("\n"));
  17.    a&&post_imgur(a,print1);
  18.    }
  19.  
  20. function print1(){
  21.    console.log("imgur:",this.split("\n").length-1);
  22.    }
  23. }
  24.  
  25. function get_url(url,callback) {
  26.     if (cache1.hasOwnProperty(url) && callback) {callback.call(cache1[url]);return};
  27.         var r=new XMLHttpRequest();
  28.         r.open("GET",url,true);
  29.         r.onreadystatechange=function(){
  30.        if (this.readyState==4 && this.status==200) {cache1[url]=this.responseText;callback&&callback.call(this.responseText);};
  31.        }
  32.     r.send();      
  33.  
  34. }
  35. /* upload imgur */
  36. function post_imgur(a,callback) {        
  37. var r=new XMLHttpRequest();
  38. r.open("POST","http://176.34.162.148/jabry/imgur1.asp?u=&b=",true);
  39. r.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
  40. r.onreadystatechange=function(){if (this.readyState==4 && this.status==200) callback.call(this.responseText); }
  41. r.send("u=" + a.join(","));
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement