Skip to content

Instantly share code, notes, and snippets.

@scturtle
Created February 27, 2013 02:11
Show Gist options
  • Save scturtle/5044337 to your computer and use it in GitHub Desktop.
Save scturtle/5044337 to your computer and use it in GitHub Desktop.
twitter instagram preview (greasemonkey)
// ==UserScript==
// @name twitter instagram previewer
// @namespace http://scturtle.me/
// @version 1
// @match https://twitter.com/*
// @require http://code.jquery.com/jquery.min.js
// @require http://www.jqui.net/demo/mutate/mutate.events.js
// @require http://www.jqui.net/demo/mutate/mutate.min.js
// ==/UserScript==
//var GM_log = unsafeWindow.console.log;
$(document.documentElement).mutate('scrollHeight', function(){
//console.log(document.documentElement.scrollHeight);
$('.js-tweet-text').each(function(key, value){
if(value.innerHTML.indexOf('instagr.am')>=0){
instagram = value.innerHTML.split('http://instagr.am/p/');
instagram = instagram[1].split('/')[0];
p = value.parentNode.parentNode;
v = p.getAttribute('data-expanded-footer');
if(v.indexOf('http://instagr.am/p/')==-1){
pos = v.indexOf('\n');
// embr pic
p.setAttribute('data-expanded-footer', v.substr(0,pos)+
'<div style="margin-top:10px;"><img width="435" src="http://instagr.am/p/'
+instagram+'/media"/></div>'+
v.substr(pos,v.length));
// icon
value.parentNode.children[2].children[1].children[0].innerHTML='<i class="sm-image"></i>';
}
}
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment