Skip to content

Instantly share code, notes, and snippets.

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 erinrwhite/944809 to your computer and use it in GitHub Desktop.
Save erinrwhite/944809 to your computer and use it in GitHub Desktop.
Bookmarklets for accessing content behind the New York Times paywall using library subscriptions
(function(){var e="";if(document.getElementsByName("hdl_p")[0]){e=document.getElementsByName("hdl_p")[0].getAttribute("content")}if(e==""){if(document.getElementsByName("hdl")[0]){e=document.getElementsByName("hdl")[0].getAttribute("content")}}if(document.getElementsByName("DISPLAYDATE")[0]){var t=new Date(document.getElementsByName("DISPLAYDATE")[0].getAttribute("content"))}if(e&&t){var n=t.toString().substring(4,7);var r=t.getFullYear();e=e.replace(/\u2018|\u2019|\u201A|\uFFFD\u201c|\u201d|\u201e|\u0028|\u0029/g,"");var i="http://www.lexisnexis.com/us/lnacademic/api/version1/sr?shr=t&csi=6742&sr=HLEAD%28"+e+"%29+AND+DATE+IS+"+n+" "+r;window.open("http://proxy.library.vcu.edu/login?url="+i)}else{alert("This article hasn't been published in the print version of the NY Times and isn't accessible through VCU Libraries.")}})()
/* use new york times meta tags to find paywalled articles in your library's lexis nexis subscription */
/* @author erin white, vcu libraries april 2011 erwhite@vcu.edu */
javascript:
(
function() {
/* find the headline - look in hdl_p first, then in hdl - then date */
var hdl = '';
if (document.getElementsByName('hdl_p')[0]) { hdl = document.getElementsByName('hdl_p')[0].getAttribute('content'); }
if (hdl == '') { if(document.getElementsByName('hdl')[0]) { hdl = document.getElementsByName('hdl')[0].getAttribute('content'); } }
if(document.getElementsByName('DISPLAYDATE')[0]) { var pubdate = new Date(document.getElementsByName('DISPLAYDATE')[0].getAttribute('content')); }
if (hdl && pubdate) {
var month = pubdate.toString().substring(4,7);
var year = pubdate.getFullYear();
/* thanks dan.hersam.org for this smartquote escape code */
hdl = hdl.replace( /\u2018|\u2019|\u201A|\uFFFD\u201c|\u201d|\u201e|\u0028|\u0029/g, '' );
var articleURL = 'http://www.lexisnexis.com/us/lnacademic/api/version1/sr?shr=t&csi=6742&sr=HLEAD%28' + hdl + '%29+AND+DATE+IS+' + month + ' ' + year;
/* you should replace the proxy link and library name below with your library's */
window.open('http://proxy.library.vcu.edu/login?url=' + articleURL);
} else {
alert('This article hasn\'t been published in the print version of the NY Times and isn\'t accessible through VCU Libraries.');
}
})
();
javascript:
(
function()
{
var source = document.documentElement.innerHTML;
var regex1 = /appeared in print on
((January|February|March|April|May|June|July|August|September|October|November|December)
([1-2][0-9]|3[0-1]|0?[1-9]), ((19|20)[0-9][0-9])), on page (\w+) of the
New York edition with the headline:(.*)</g;
var match = regex1.exec(source);
if (match)
{
var articleDate = new Date(match[2] + ' ' + match[3] + ', '
+ match[4]);
var articleYear = articleDate.getFullYear();
var articleMonth = articleDate.getMonth() + 1;
var articleDay = articleDate.getDate();
var regex2 = /([A-Z]+)(\d+)/g;
var pageMatch = regex2.exec(match[6]);
var articleURL =
'http://www.lexisnexis.com/us/lnacademic/api/version1/sr?shr=t&csi=6742&sr=HLEAD%28'
+ match[7] + '%29+AND+DATE+IS+' + articleMonth + '%2F' + articleDay +
'%2F' + articleYear;
window.open('http://proxy.library.vcu.edu/login?url=' +
articleURL);
}
else
{
alert("This article hasn't been published in the print
version of the NY Times and isn't accessible through VCU Libraries.");
}
}
)
();
javascript:
(
function()
{
var source = document.documentElement.innerHTML;
var regex1 = /A version of this article appeared in print on ((January|February|March|April|May|June|July|August|September|October|November|December) ([1-2][0-9]|3[0-1]|0?[1-9]), ((19|20)[0-9][0-9])), on page (\w+) of the New York edition with the headline:(.*)</g;
var match = regex1.exec(source);
if (match)
{
var articleDate = new Date(match[2] + ' ' + match[3] + ', ' + match[4]);
var articleYear = articleDate.getFullYear();
var articleMonth = articleDate.getMonth() + 1;
var articleDay = articleDate.getDate();
var regex2 = /([A-Z]+)(\d+)/g;
var pageMatch = regex2.exec(match[6]);
window.open('https://proxy.libraries.uc.edu/login?url=http://proquest.umi.com/pqdweb?RQT=305&SQ=issn%2803624331%29%20and%20ti%28' + match[7] + '%29%20and%20pdn%28' + articleMonth + '%2F' + articleDay + '%2F' + articleYear + '%29%20and%20startpage%28' + pageMatch[1] + '.' + pageMatch[2] + '%29');
}
else
{
alert("This article hasn't been published in the print version of the NY Times and isn't accessible through the UC Libraries.");
}
}
)
();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment