Last active
December 22, 2015 03:19
-
-
Save AhmedNadar/6409477 to your computer and use it in GitHub Desktop.
JavaScript: jQuery Store all favorites Twitter in instapaper
This file contains 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
$ = 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