Last active
July 28, 2021 09:10
-
-
Save ngseke/42d4157d0f199152442c3471959764c0 to your computer and use it in GitHub Desktop.
fuck interview dot tw
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function getVipButtons () { | |
return [...document.querySelectorAll('button.btn-exchange-vip')] | |
} | |
function getIsListLoaded () { | |
return document.querySelector('.interview-list').style.opacity === '1' | |
} | |
function goToNextPage () { | |
const $next = document.querySelector('.iw_pagination-item.iw_active').nextSibling.nextSibling.querySelector?.('a') | |
$next.click() | |
return new Promise(resolve => { | |
const timer = setInterval(() => { | |
console.log('Try to go to next page') | |
if (getIsListLoaded()) { | |
clearInterval(timer) | |
resolve() | |
} | |
}, 500) | |
}) | |
} | |
function sleep (delay = 500) { | |
return new Promise(resolve => setTimeout(resolve, delay)) | |
} | |
async function task () { | |
while (true) { | |
const $buttons = getVipButtons() | |
const { length } = $buttons | |
if (!length) { | |
console.log('🤔 Seems empty') | |
// break | |
} | |
console.log(`Click ${length} buttons`) | |
$buttons.forEach(i => i.click()) | |
await sleep() | |
await goToNextPage() | |
} | |
console.log('😊 DONE') | |
} | |
task() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment