Filling ILLiad forms

Posted on Sun 20 August 2017 in programming

You may have seen my other post on quickly getting papers remotely through your own library with JavaScript. This method works well if your paper is easy to find and you just need to get around the paywall using the access your institution pays for. Sometimes, especially with older papers, you may be able to find a reference, but not a paper. Libraries can offer great utilities to supporting finding original research articles, but they can sometimes be clunky and slow to use. This post will give an example of using JavaScript to file requests on ILLiad, an article requesting service from OCLC used at Penn State, from only a bibtex reference to the article.

Too long, didn't read

See my JavaScript Gist with the code and/or bookmark this Fill ILLiad link. Run the script or bookmarklet on an ILLiad request page (possible PSU link) and fill the prompt with the BibTeX entry of the reference you'd like to fill.

Motivation

In thermodynamic modeling, it is desirable to have original references to experimental studies in order to properly interpret the results and prevent propagating mistakes. For many alloy systems, especially binaries, many of the original articles were written between (roughly) 1900 and 1950. Despite these being indispensable for modeling work, digital versions of the paper can be challenging to track down.

ILLiad is an InterLibrary Loan software service from OCLC offered by many institutions including Penn State, allows research articles (and book chapters) that are not accessible through the usual library resources. A typical ILLiad request page is below. The form serves its purpose well for requesting single papers, but is tedious for beginning literature searches for many articles that must be requested. Even for well formatted references, it is tedious to copy and paste seven or more fields in to request just one paper.

ILLiad request page

It would naturally be ideal to try to automate this. For serious automation of on the order of a hundred or more citations, it would be efficient to a script in Python to make submissions automatically. Since I'm not sure what type of systems other institutions use, I thought it might be helpful to write something more general in JavaScript that could be adapted to any kind of webform.

Getting our bearings

We need three pieces to be able to fill the above form (or any like it) automatically:

  1. A standard citation format that will easily fill the forms fields
  2. A way to convert the standard citation into a useful form in JavaScript
  3. A place to fill our nicely formatted data

We'll stitch these together in a useful, portable bookmarklet, just like in my getting papers remotely post.

Reference format

More than any citation format, BibTeX files are the digital common denominator. Any reference management software worth using should be able to read and export to BibTeX. The fact that it can be stored and used as plain text makes it a natural choice to use for any digital reference management.

We will use BibTeX as input to our JavaScript bookmarklet. For Mendeley users, that will mean finding your reference, right-clicking and selecting BibTeX entry from the Copy As menu. See the reference software you use for instructions.

In our script, we'll just use a simple JavaScript prompt to prompt for user input.

Conversion

Another benefit of choosing an open format like BibTeX is that we should not have to worry about the syntax ourselves. I choose to use @mikolalysenko's parser and load it directly in the browser by using this accepted StackOverflow answer and rawgit. The loadScript function in the Gist is directly from that SO answer.

This parser will convert BibTeX entries into a JSON where each top-level key is the BibTeX citation key and the values are all the BibTeX fields, such as AUTHOR, TITLE, etc. We can assume that a user will only enter just one entry (and choose the last one if they enter more than one) just by using a simple loop through the keys and filling the form fields. See the replaceValues function to see the looping in action.

Though before we do this, we need to know where to fill these values.

Filling

Finally, we need targets to fill our data. All modern browsers have build in development tools. Here we've used Chrome to drill down through the elements and find the relevant textarea fields. You can see that the highlighted textarea has the id PhotoJournalTitle. From the inspection tree on the right, it appears that the other fields follow a similar format, e.g. PhotoJournalInclusivePages.

ILLiad dev tools

We can use JavaScript's getElementById function to grab each of these elements and let us change the values. For brevity and lack of creativity, I've hardcoded these in the Gist as the replacementDict. The replacementDict simply maps the name of the element id to the name of the key in the BibTeX JSON. If you don't use the same ILLiad system, you can inspect the page and you should only need to update the replacementDict.

Making it a bookmarklet

This example is only slightly more complicated than the getting papers remotely because it's not obvious how to squeeze down the content of the Gist to one line. Tools like Peter Coles' bookmarklet creator take a JavaScript script and condense it down to oneline and put it in a function to give things the correct scope. Though, notable this mangles the input with percent encodings.

See it in action

The input:

ILLiad input

And the resulting filled form:

ILLiad filled form

Note that the reference you entered is nicely put in the Notes section, in case your reference manager tries to pull the wool over your eyes when you import your ancient PDF.

Again, the link to the Gist and the Fill ILLiad bookmarklet.

Happy (semi-)automating!