Skip to content

Instantly share code, notes, and snippets.

@958
Created January 28, 2009 07:55
Show Gist options
  • Save 958/53860 to your computer and use it in GitHub Desktop.
Save 958/53860 to your computer and use it in GitHub Desktop.
[Sleipnir]twitter show conversation for SeaHorse
// ==UserScript==
// @name twitter show conversation for SeaHorse
// @namespace http://mattn.kaoriya.net/
// @description twitter show conversation
// @include http://twitter.com/*
// @type SleipnirScript
// ==/UserScript==
// modified for seahorse by 958
// base on http://mattn.kaoriya.net/software/firefox/greasemonkey/20090127172930.htm
(function() {
if ((!_document) || (!_document.body) || (_window.__twitter_show_conversation) || (typeof(_window.execScript) != 'object')) return;
_window.sleipnir = sleipnir;
try {
_window.execScript('('+function() {
var sleipnir = window.sleipnir;
window.sleipnir = null;
window.__twitter_show_conversation = true;
jQuery('.hentry.reply').each(function() {
var id = jQuery('a[rel="bookmark"]', this).get()[0].href.replace(/^.*\/(\d+)$/, '$1');
jQuery('span.entry-meta', this).get()[0].innerHTML += [' ',
'<span>',
'<a id="show_thr', id, '" class="show-conversation" href="javascript:void 0">',
'<img src="http://search.twitter.com/images/thread.png" border="0"/>',
'Show Conversation',
'</a>',
'</span>',
'<br />',
'<div id="show-conversation-', id,'" />',
].join('');
});
jQuery('a.show-conversation').each(function() {
jQuery(this).one('click', function(e) {
var n = e.target;
var id = n.id.replace(/show_thr/, '');
var uri = 'http://search.twitter.com/search/thread/' + id;
var c = jQuery('#show-conversation-' + id).get()[0];
c.style.border = '1px black dotted';
c.style.padding = '1em';
GM_xmlhttpRequest({
method : "GET",
url : uri,
onload : function (req) { c.innerHTML = req.responseText },
onerror : function (e) { }
});
}, false);
});
function GM_xmlhttpRequest(opt) {
var http = null;
if (opt.redirect)
http = sleipnir.CreateObject('MSXML2.ServerXMLHTTP');
else
http = sleipnir.CreateObject('Microsoft.XMLHTTP');
http.open(opt.method.toUpperCase(), opt.url, true);
if (opt.headers) {
for (var i in opt.headers) {
if (!opt.headers.hasOwnProperty(i)) continue;
http.setRequestHeader(i, opt.headers[i]);
}
}
http.onreadystatechange = function() {
if(http.readyState == 4){
if(http.status == 200){//succeed
if (opt.onload) opt.onload(http);
} else {
if (opt.onerror) opt.onerror(http);
}
http = null;
}
};
var send = null;
if (opt.data) send = opt.data;
http.send(send);
}
}+')()');
}catch(e){}
_window.sleipnir = null;
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment