Skip to content

Instantly share code, notes, and snippets.

@hsayed21
Last active October 4, 2022 06:11
Show Gist options
  • Save hsayed21/a0bae8133deeba509494b72471b6428f to your computer and use it in GitHub Desktop.
Save hsayed21/a0bae8133deeba509494b72471b6428f to your computer and use it in GitHub Desktop.
var result = "";
// for each on all elements in div with id "grid"
var elements = document.getElementById("grid").children;
// get all children divs in div with id "grid"
for (var i = 0; i < elements.length; i++) {
// get the current element
var element = elements[i];
// add the class "selected" to the current element
element.classList.add("selected");
// after that click on ocr button
document.querySelector(".pdf_ocr").click();
// wait 2 second
await new Promise(r => setTimeout(r, 2000));
// get div with class "modal"
var modal = document.querySelector("#spin_box");
// wait until modal class to be "modal" because it will be "modal show" and display: block
while (modal.classList.contains("show") && modal.style.display == "block") {
// wait 100ms
await new Promise(r => setTimeout(r, 1000));
}
// scroll to bottom of page
window.scrollTo(0, document.body.scrollHeight);
// get downloaded link
var link = document.querySelector(".dropdown-menu > #download_pdf_searchable");
// append the full href to result
result += link.href + "\n";
// remove the class "selected" from the current element
element.classList.remove("selected");
// scroll to top of page
window.scrollTo(0, 0);
}
function CopyToClipboard(copyText) {
navigator.clipboard
.writeText(copyText)
.then(() => {
console.log('copied to clipboard');
})
.catch(() => {
const input = document.createElement('input')
document.body.appendChild(input)
input.setAttribute('value', copyText)
input.select()
if (document.execCommand('copy')) {
document.execCommand('copy')
}
document.body.removeChild(input)
console.log('copied to clipboard2');
})
}
console.log(result);
// copy the result to clipboard
CopyToClipboard(result);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment