Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (() => {
- var requestAnimationFrame = window.requestAnimationFrame || window.mozRequestAnimationFrame ||
- window.webkitRequestAnimationFrame || window.msRequestAnimationFrame;
- window.requestAnimationFrame = requestAnimationFrame;
- })();
- var last = 130000000;
- asyncLoop(
- 1e9,
- (loop) => {
- var img = new Image;
- img.src = 'https://vk.com/im?sel=-' + (--last);
- requestAnimationFrame(loop.next);
- },
- () => {
- console.log('Работа скрипта закончена!');
- }
- );
- function asyncLoop(iterations, func, callback) {
- var index = 0;
- var done = false;
- var loop = {
- next: () => {
- if (done) {
- return;
- }
- if (index < iterations) {
- index++;
- func(loop);
- } else {
- done = true;
- callback();
- }
- },
- iteration: () => {
- return index - 1;
- },
- break: () => {
- done = true;
- callback();
- }
- };
- loop.next();
- return loop;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement