Skip to content

Instantly share code, notes, and snippets.

@jasonrwang
Last active September 4, 2019 21:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jasonrwang/1867065aaca41d38abce9cac66a6307f to your computer and use it in GitHub Desktop.
Save jasonrwang/1867065aaca41d38abce9cac66a6307f to your computer and use it in GitHub Desktop.
Automagically access TU Delft journals off-campus with this script (if you use Safari on macOS)

University Journal Remote Access via Proxy Script for Safari on macOS

How-To

Save this little guy wherever, and then use it whenever you're browsing for some journals.

For example, if I save this to ~/Scripts, then to access

The URL: https://science.sciencemag.org/content/341/6151/1235367 (Hsiang, S. M., Burke, M., & Miguel, E. (2013). Quantifying the Influence of Climate on Human Conflict. Science, 341(6151), 1235367–1235367. https://doi.org/10.1126/science.1235367)

Then type osascript ~/Scripts/TUDelft_Safari_proxy_URL.scpt in Terminal, hit ENTER on your keyboard, and the script will take care of the rest :) The Terminal window needs to be in the same desktop (i.e. Spaces window) as Safari to work properly.

Other

  • This script simply uses the .tudelft.idm.oclc.org proxy, so it of course requires that you have a TU Delft NetID with an active library subscription to work! See more here: https://www.jrwang.ca/2016/06/12/connectivity-tricks-for-students/
  • This proxy doesn't work for Nature, ScienceDirect (Elsevier), and some other publications for some reason, so you might have to resort to the VPN.
  • Obviously, you can change the proxy domain in line 17 to another, like .login.ezproxy.library.ualberta.ca for the University of Alberta's service, which happens to work instead of the VPN.
  • This has only been tested on macOS 10.14 Mojave. Your mileage may vary.
tell application "Safari"
set currentTab to current tab of front window
set currentURL to currentTab's URL
# Extract the domain
set AppleScript's text item delimiters to {"/"}
set urlParts to (every text item in currentURL) as list
set originalDomain to item 3 of urlParts
# Change "." to "-"
set AppleScript's text item delimiters to {"."}
set domainParts to (every text item in originalDomain) as list
set AppleScript's text item delimiters to {"-"}
set amendedDomain to domainParts as text
# Add the TU Delft proxy
set amendedDomain to amendedDomain & ".tudelft.idm.oclc.org"
set item 3 of urlParts to amendedDomain
set AppleScript's text item delimiters to {"/"}
set amendedURL to urlParts as text
# Re-open the page with the new file
tell currentTab
set URL to amendedURL
end tell
end tell
@jasonrwang
Copy link
Author

jasonrwang commented Apr 9, 2019

How-To

Save this little guy wherever, and then, whenever you're browsing for some journals.

For example, if I save this to ~/Scripts, then to access

The URL: https://science.sciencemag.org/content/341/6151/1235367
(Hsiang, S. M., Burke, M., & Miguel, E. (2013). Quantifying the Influence of Climate on Human Conflict. Science, 341(6151), 1235367–1235367. https://doi.org/10.1126/science.1235367)

Then type osascript ~/Scripts/TUDelft_Safari_proxy_URL.scpt in Terminal, hit ENTER on your keyboard, and the script will take care of the rest :)

Other

  • This script simply uses the .tudelft.idm.oclc.org proxy, so it of course requires that you have a TU Delft NetID with an active library subscription to work! See more here: https://www.jrwang.ca/2016/06/12/connectivity-tricks-for-students/
  • This proxy doesn't work for Nature and some other publications for some reason, so you might have to resort to the VPN.
  • Obviously, you can change the proxy domain in line 17 to another, like .login.ezproxy.library.ualberta.ca for the University of Alberta's service, which happens to work instead of the VPN.

@jasonrwang
Copy link
Author

Changed my comment into a small readme file :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment