Skip to content

Instantly share code, notes, and snippets.

@chriswhong
Last active March 22, 2022 14:30
Show Gist options
  • Save chriswhong/a43565c8ba5c22d90ec967263ef5c44f to your computer and use it in GitHub Desktop.
Save chriswhong/a43565c8ba5c22d90ec967263ef5c44f to your computer and use it in GitHub Desktop.
Iterates over the list of intakes in IntakeQ web UI, downloading each as a PDF.
// Bulk download of IntakeQ forms
// This script will iterate over the list of intakes in IntakeQ, downloading
// each as a PDF. It also pulls the customer's name from the list and uses it
// to create the filename
// this script does not paginate. To use navigate to a list of intakes, open
// developer tools, paste into the console, press enter
// if you have more than one page, manually navigate to the next page and repeat
// select all table row elements
var rows = document.querySelectorAll("tbody tr")
// limit to just one for testing purposes
// rows = [rows[0]]
// iterate over the rows, waiting 5 seconds between each
var i = 0;
var interval = setInterval(() => {
console.log(`downloading form for row ${i}`)
var row = rows[i];
// get the customer's name
var name = row.querySelectorAll('td:nth-child(3)')[0].textContent.trim()
// get the a tag with the pdf download link
var downloadLinkNode = row.querySelectorAll('ul li:nth-child(3) a')[0]
// set the download attribute, adding the customer's name
downloadLinkNode.setAttribute('download',`${name} - Intake Form`)
downloadLinkNode.click()
i++;
if(i === rows.length) clearInterval(interval);
}, 5000);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment