Created
October 28, 2014 19:57
-
-
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
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
// 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