Tuesday, July 10, 2012

Tweaks to Instapaper "Read Later" Button

I love Instapaper (please support it by becoming a premium member!). Being able to easily save articles for reading later lets me move the article-reading time from when I shouldn't be getting distracted to when I'm happy to relax on the couch (or train, or airplane, or line at the coffee shop, ...) with an interesting article.

Tonight I worked on fixing two small things that were bugging me:

  1. When I'm reading an article, I'd like to know where I came across it. The code below uses the javasript "document.referrer" property and adds a link back to the referrer, before saving to Instapaper.
  2. I don't like when I hit "Read Later" before the page has finished loading and get a complaint that I should wait for the page to load. This lets me hit "Read Later" while it's loading and get back to ordering my coffee.
You can use the code below just like the original "Read Later" link, but I'll warn you it's had about 5 minutes of testing. Please give me any feedback you have! 

I'd like to have much more extensive history/referral tracking, and even what it's supposed to do now doesn't always work. Let me know if you can help!

/* Tweaks by David Chudzicki (www.learnfromdata.com) to "Read Later" button from Marco Arment's Instapaper*/
/* Regarding copies, you have all permission that I'm in a position to give*/
function iprl5(){
var d=document, z=d.createElement('script'),b=d.body,l=d.location;
d.title='(Saving...) '+d.title;
var _div = d.createElement('div');
var _text = d.createTextNode("################### Referred from:  ");
var link = document.createElement('a');
link.innerHTML = d.referrer;
link.href = d.referrer;
hmm = l.protocol+'//www.instapaper.com/j/EPD0QeYgeyGE?u='+encodeURIComponent(l.href)+'&t='+(new Date().getTime());
catch(e){alert('Please wait until the page has loaded.');}
if(document.body) {
} else {
    if (window.addEventListener) {
        window.addEventListener('load', iprl5, false);
    } else {
        window.attachEvent('onload', iprl5);
/* Thanks to Jman: http://stackoverflow.com/questions/978740/javascript-how-to-detect-if-document-has-loaded-ie-7-firefox-3 */

No comments:

Post a Comment