Fork Copy (() => { let messages = Array.from(document.querySelectorAll('tr > td:nth-child(1) > a:nth-child(1)')) .filter(el => el.innerText.startsWith('ID:d')) .map(el => el.getAttribute('href')) .reverse(); let promise = Promise.resolve() for (let messageUrl of messages) { promise = promise.then(() => { return fetch(messageUrl) .then(res => res.text()) .then(html => { var el = document.createElement('html') el.innerHTML = html; var retryUrl = el.querySelector('table.layout > tbody:nth-child(1) > tr:nth-child(2) > td:nth-child(1) > table:nth-child(1) > tbody:nth-child(2) > tr:nth-child(2) > td:nth-child(1) > a:nth-child(1)').getAttribute('href'); return fetch(retryUrl) }) }) } })()