Last active
October 12, 2015 01:36
-
-
Save davemasse/1199557 to your computer and use it in GitHub Desktop.
jQuery bookmarklet using Ben Alman's generator
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Makes local newspaper archives accessible by altering archive links (PDFs are not password-protected!) | |
(function($) { | |
monthArray = { | |
January: '01', | |
February: '02', | |
March: '03', | |
April: '04', | |
May: '05', | |
June: '06', | |
July: '07', | |
August: '08', | |
September: '09', | |
October: '10', | |
November: '11', | |
December: '12' | |
}; | |
$('a[href*="1communityindexbody.lasso"]:gt(0)').each(function() { | |
var href = $(this).attr('href').split('&'); | |
var pub = href[1].replace('pub=', ''); | |
var date = $(this).text().split(' '); | |
var year = date[2].replace(/[^\d]/g, ''); | |
var month = date[0].replace(/[^a-z]/gi, ''); | |
var day = date[1].replace(/[^\d]/g, ''); | |
if (day.length == 1) | |
day = '0' + day; | |
$(this).attr('href', '/pdf/' + pub + '.' + year + '.' + monthArray[month] + '.' + day + '.pdf'); | |
$(this).attr('target', '_blank'); | |
}); | |
})(jQuery) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment