Skip to content

Instantly share code, notes, and snippets.

@juanbrujo
Created October 28, 2014 19:57
Show Gist options
  • Save juanbrujo/8b0744e341e4c5f4309e to your computer and use it in GitHub Desktop.
Save juanbrujo/8b0744e341e4c5f4309e to your computer and use it in GitHub Desktop.
Get Image from Twitter & Instagram : bookmarklet that get's the image shown on certain post on Twitter or Instagram
// The Code:
var url = window.location.host;
if (url.indexOf('twitter.com') != -1){
// is Twitter
var pic = $('.cards-media-container .media').attr('data-url');
if(pic){
window.open(pic,'_self');
} else {
alert('There\'s no photo.');
}
} else if (url.indexOf('instagram.com') != -1){
// is Instagram
var pic = $('.Item .iMedia .Image').attr('src');
if(pic){
window.open(pic,'_self');
} else {
alert('There\'s no photo.');
}
}
// The bookmarklet:
javascript:(function(e,a,g,h,f,c,b,d){if(!(f=e.jQuery)||g>f.fn.jquery||h(f)){c=a.createElement("script");c.type="text/javascript";c.src="http://ajax.googleapis.com/ajax/libs/jquery/"+g+"/jquery.min.js";c.onload=c.onreadystatechange=function(){if(!b&&(!(d=this.readyState)||d=="loaded"||d=="complete")){h((f=e.jQuery).noConflict(1),b=1);f(c).remove()}};a.documentElement.childNodes[0].appendChild(c)}})(window,document,"1.6.2",function($,L){var url = window.location.host;if (url.indexOf('twitter.com') != -1){ var pic = $('.cards-media-container .media').attr('data-url'); if(pic){ window.open(pic,'_self'); } else { alert('There\'s no photo.'); }} else if (url.indexOf('instagram.com') != -1){ var pic = $('.Item .iMedia .Image').attr('src'); if(pic){ window.open(pic,'_self'); } else { alert('There\'s no photo.'); }}});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment