Last active
August 10, 2023 00:16
Revisions
-
oddlyfunctional revised this gist
Aug 10, 2023 . 1 changed file with 13 additions and 7 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -7,12 +7,14 @@ const downloadURI = (uri, name) => { document.body.removeChild(link); } const downloaded = new Set() function downloadAndLoadNext() { const title = document.getElementById('PastaTxt') .innerText .replaceAll('\\', '-') .replaceAll(' ', '-') const [currentMatch, lastMatch] = document.getElementById('OcorNroLbl') .innerText .split('/') @@ -21,8 +23,12 @@ function downloadAndLoadNext() { const currentUrl = document.getElementById('DocumentoImg').src const nextPage = document.getElementById('OcorPosBtn') if (!downloaded.has(currentUrl)) { downloaded.add(currentUrl) const currentPage = document.getElementById('PagAtualTxt').value downloadURI(currentUrl, `${title}-Página-${currentPage}.jpg`) } if (currentMatch === lastMatch) { alert('Terminou!') @@ -43,4 +49,4 @@ function downloadAndLoadNext() { } } downloadAndLoadNext() -
oddlyfunctional revised this gist
Aug 10, 2023 . 1 changed file with 14 additions and 10 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -7,23 +7,27 @@ const downloadURI = (uri, name) => { document.body.removeChild(link); } const title = document.getElementById('PastaTxt') .title .replaceAll('\\', '-') .replaceAll(' ', '-') function downloadAndLoadNext() { const [currentMatch, lastMatch] = document.getElementById('OcorNroLbl') .innerText .split('/') .map(Number); const currentUrl = document.getElementById('DocumentoImg').src const nextPage = document.getElementById('OcorPosBtn') const currentPage = document.getElementById('PagAtualTxt').value downloadURI(currentUrl, `${title}-Página-${currentPage}.jpg`) if (currentMatch === lastMatch) { alert('Terminou!') } else { nextPage.click() function waitUntilLoaded() { const newUrl = document.getElementById('DocumentoImg').src @@ -39,4 +43,4 @@ function downloadAndLoadNext() { } } downloadAndLoadNext() -
oddlyfunctional created this gist
Aug 9, 2023 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,42 @@ const downloadURI = (uri, name) => { const link = document.createElement("a"); link.download = name; link.href = uri; document.body.appendChild(link); link.click(); document.body.removeChild(link); } const title = document.getElementById('PesquisarTxt').value .replaceAll('"', '') .replaceAll(' ', '-') const lastPage = Number(document.getElementById('PagTotalLbl').innerText.replace('/', '')) function downloadAndLoadNext() { const currentPageInput = document.getElementById('PagAtualTxt') const currentUrl = document.getElementById('DocumentoImg').src const currentPage = Number(currentPageInput.value) downloadURI(currentUrl, `${title}-${currentPage}.jpg`) if (currentPage === lastPage) { alert('Terminou!') } else { currentPageInput.value = currentPage + 1 currentPageInput.onchange() function waitUntilLoaded() { const newUrl = document.getElementById('DocumentoImg').src if (newUrl === currentUrl) { setTimeout(waitUntilLoaded, 0) } else { setTimeout(downloadAndLoadNext, 0) } } waitUntilLoaded() } } downloadAndLoadNext()