Skip to content

Instantly share code, notes, and snippets.

@paulirish
Created October 27, 2010 21:04
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save paulirish/649992 to your computer and use it in GitHub Desktop.
Save paulirish/649992 to your computer and use it in GitHub Desktop.
store all twitter favorites in instapaper
$ = window.jQuery;
var html = '' +
' <form action="//www.instapaper.com/bookmarklet/post_v5" method="post" id="instapaper"> \
<input type="hidden" name="p" value=""/> \
<input type="hidden" name="b" id="b" value=""/> \
</form>';
// grab links we want.
var links = jQuery('.tweet-text').find('a[target="_blank"]'),
length = links.length,
i = 0;
(function loopsiloop(){
$('#instaframe').remove();
var iframe = $('<iframe id="instaframe"></iframe>').appendTo('body').load(function(){
iframe.contents().find('body').append(html);
var elem = links.get(i);
var href = elem.href;
// get the name of the tweeter plus the text of the tweet
var title = jQuery(elem).closest('.tweet-row').prev().andSelf().text();
title = $.trim( title.replace(/\n/g,'').replace(/\s+/g,' ') );
var e = encodeURIComponent,
//href = document.location.href,
//title= document.title,
myspecialcode = 'QjlsvnomaRlR',
p = 'a=&k='+ myspecialcode +'&u=' + e(href) + '&t=' + e(title) + '&s=' + '';
$('#instaframe').contents().find('#instapaper')
.find('[name=p]').val(p).end()
.find('[name=b]').val('').end() // empty for that!
.submit();
if (links.eq(++i).length){
setTimeout(loopsiloop, 500);
}
}); // end of load
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment