Created
November 5, 2023 18:40
-
-
Save vermi321/f07f18800e06ff2625bd3ce3bf0dee91 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
(async () => { | |
if (!window.location.href.startsWith('https://debank.com/official-ranking')) { | |
alert('Navigate to the Official Account Ranking page'); | |
return; | |
} | |
const sleep = (ms) => new Promise(resolve => setTimeout(resolve, ms)); | |
const getUsernameEls = () => document.querySelectorAll('.db-table-body .List_officialName__1Mj63'); | |
const getRowEls = () => document.querySelectorAll('.db-table-body .db-table-row'); | |
const goToPage = async (page) => { | |
document.querySelector(`.db-talbe-pagination li[title="${page}"]`).click(); | |
await sleep(1000); | |
while (getUsernameEls().length === 0) { | |
await sleep(100); | |
} | |
} | |
let nextPageNumber = 1 | |
while (nextPageNumber) { | |
try { | |
console.log(`Navigating to the page: ${nextPageNumber}`) | |
await goToPage(nextPageNumber) | |
await Promise.all( | |
Array.from(getRowEls()).map(async (item, index) => new Promise(res => { | |
setTimeout(() => { | |
item.querySelector('[class*=Button_is_primary__]')?.click(); | |
res(); | |
}, 200 * index); | |
})) | |
); | |
nextPageNumber += 1; | |
} catch { | |
nextPageNumber = null; | |
} | |
} | |
console.log(`Done`) | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment