Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function sleep(waitMsec) {
- var startMsec = new Date();
- // 指定ミリ秒間、空ループ。CPUは常にビジー。
- while (new Date() - startMsec < waitMsec);
- }
- function asyncLoop(iterations, func, callback) {
- var index = 0;
- var done = false;
- var loop = {
- next: function() {
- if (done) {
- return;
- }
- if (index < iterations) {
- index++;
- func(loop);
- } else {
- done = true;
- callback();
- }
- },
- iteration: function() {
- return index - 1;
- },
- break: function() {
- done = true;
- callback();
- }
- };
- loop.next();
- return loop;
- }
- asyncLoop(1000, function(loop) {
- console.log(loop.iteration());
- $(".JudgementButtonsUnderCardButton.-like").click();
- sleep(1000);
- loop.next();
- },
- function(){console.log('done')}
- );
Add Comment
Please, Sign In to add comment