Skip to content

Commit 866a756

Browse files
committed
clear interval
1 parent 72ee8bc commit 866a756

File tree

1 file changed

+7
-3
lines changed
  • scripts/backup/ext/fb-group-ext/popup/auto_duyet_bai

1 file changed

+7
-3
lines changed

scripts/backup/ext/fb-group-ext/popup/auto_duyet_bai/main.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -151,10 +151,14 @@ function start(action, maxPosts, waitMin, waitMax) {
151151

152152
function sleep(time, cancelFn) {
153153
return new Promise((resolve) => {
154-
setTimeout(resolve, time);
154+
const timeout = setTimeout(resolve, time);
155155
if (cancelFn) {
156-
setInterval(() => {
157-
if (cancelFn()) resolve();
156+
const interval = setInterval(() => {
157+
if (cancelFn()) {
158+
clearInterval(interval);
159+
clearTimeout(timeout);
160+
resolve();
161+
}
158162
}, 100);
159163
}
160164
});

0 commit comments

Comments
 (0)