Skip to content

Instantly share code, notes, and snippets.

@chriswhong
Last active March 22, 2022 14:30
Show Gist options
  • Select an option

  • Save chriswhong/a43565c8ba5c22d90ec967263ef5c44f to your computer and use it in GitHub Desktop.

Select an option

Save chriswhong/a43565c8ba5c22d90ec967263ef5c44f to your computer and use it in GitHub Desktop.

Revisions

  1. chriswhong revised this gist Mar 22, 2022. 1 changed file with 4 additions and 0 deletions.
    4 changes: 4 additions & 0 deletions intakeq-bulk-download.js
    Original file line number Diff line number Diff line change
    @@ -3,6 +3,10 @@
    // 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
  2. chriswhong revised this gist Mar 22, 2022. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion intakeq-bulk-download.js
    Original file line number Diff line number Diff line change
    @@ -11,7 +11,7 @@ var rows = document.querySelectorAll("tbody tr")
    // iterate over the rows, waiting 5 seconds between each
    var i = 0;
    var interval = setInterval(() => {
    console.log(`downloading for for row ${i}`)
    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()
  3. chriswhong revised this gist Mar 22, 2022. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions intakeq-bulk-download.js
    Original file line number Diff line number Diff line change
    @@ -11,6 +11,7 @@ var rows = document.querySelectorAll("tbody tr")
    // iterate over the rows, waiting 5 seconds between each
    var i = 0;
    var interval = setInterval(() => {
    console.log(`downloading for for row ${i}`)
    var row = rows[i];
    // get the customer's name
    var name = row.querySelectorAll('td:nth-child(3)')[0].textContent.trim()
    @@ -23,5 +24,4 @@ var interval = setInterval(() => {

    i++;
    if(i === rows.length) clearInterval(interval);
    }, 5000);

    }, 5000);
  4. chriswhong created this gist Mar 22, 2022.
    27 changes: 27 additions & 0 deletions intakeq-bulk-download.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,27 @@
    // 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

    // 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(() => {
    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);