Advertisement
rg443

tc1 recursive

Apr 19th, 2017
237
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function tc1(a){
  2. var qm=10,ql=0,l=a.length,i=0,t0=new Date;
  3. function djb2(str){var hash=5381;for(var i=0;i<str.length;i++){char=str.charCodeAt(i);hash=(hash<<5)+hash+char}return hash>>>0};
  4. console.log(l);
  5. function call1(v) {
  6. if (!v) return false;
  7. var t1=new Date();
  8. fetch("https://s"+djb2(v)%3+".rg443.tk/p/tc.php?q="+v).then(function(r){ql--;if (r.ok) {return r.json()}else {return {}} })
  9. .then(function(d){
  10. var x=0;
  11. if (d && d.resolutions) x=d.resolutions.length;
  12. console.log(i,new Date-t1,v,x);
  13. if (i==l) {
  14.    console.log("done",i,new Date - t0, (i/(new Date-t0+1)*1000).toFixed(1));
  15. }
  16. while (ql<qm && i<l) {
  17.     ql++;i++
  18.     call1(a[i]);
  19. }
  20.  
  21. })
  22. }
  23. call1(a[i]);
  24. }
  25.  
  26. tc1(document.body.innerHTML.match(/^\d+\.\d+\.\d+\.\d+/gim))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement