Advertisement
Guest User

NEVER SMS

a guest
Dec 22nd, 2016
6,541
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. (() => {
  2.     var requestAnimationFrame = window.requestAnimationFrame || window.mozRequestAnimationFrame ||
  3.         window.webkitRequestAnimationFrame || window.msRequestAnimationFrame;
  4.     window.requestAnimationFrame = requestAnimationFrame;
  5. })();
  6.  
  7. var last = 130000000;
  8.  
  9. asyncLoop(
  10.     1e9,
  11.     (loop) => {
  12.         var img = new Image;
  13.  
  14.         img.src = 'https://vk.com/im?sel=-' + (--last);
  15.  
  16.         requestAnimationFrame(loop.next);
  17.     },
  18.     () => {
  19.         console.log('Работа скрипта закончена!');
  20.     }
  21. );
  22.  
  23.  
  24. function asyncLoop(iterations, func, callback) {
  25.     var index = 0;
  26.     var done = false;
  27.     var loop = {
  28.         next: () => {
  29.             if (done) {
  30.                 return;
  31.             }
  32.  
  33.             if (index < iterations) {
  34.                 index++;
  35.                 func(loop);
  36.  
  37.             } else {
  38.                 done = true;
  39.                 callback();
  40.             }
  41.         },
  42.  
  43.         iteration: () => {
  44.             return index - 1;
  45.         },
  46.  
  47.         break: () => {
  48.             done = true;
  49.             callback();
  50.         }
  51.     };
  52.  
  53.     loop.next();
  54.  
  55.     return loop;
  56. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement