mirror of
https://github.com/Foundry376/Mailspring.git
synced 2024-11-11 18:32:20 +08:00
21 lines
459 B
Text
21 lines
459 B
Text
|
|
||
|
export const wait = (ms)=> {
|
||
|
return new Promise((resolve)=> {
|
||
|
setTimeout(()=> resolve(), ms);
|
||
|
});
|
||
|
};
|
||
|
|
||
|
export const clickRepeat = (client, selector, {times = 1, interval = 0} = {})=> {
|
||
|
if (times === 1) return client.click(selector);
|
||
|
const fn = (remaining)=> {
|
||
|
if (remaining > 0) {
|
||
|
return (
|
||
|
client.click(selector)
|
||
|
.then(()=> wait(interval))
|
||
|
.then(()=> fn(remaining - 1))
|
||
|
);
|
||
|
}
|
||
|
};
|
||
|
return fn(times);
|
||
|
};
|