Created
January 28, 2009 08:08
-
-
Save 958/53864 to your computer and use it in GitHub Desktop.
[Sleipnir]Twitter favorites counter for SeaHorse
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
// ==UserScript== | |
// @name Twitter favorites counter for SeaHorse | |
// @include http://twitter.com/* | |
// @exclude http://twitter.com/home* | |
// @exlucde http://twitter.com/replies* | |
// @exclude http://twitter.com/favorites* | |
// @exclude http://twitter.com/public_timeline* | |
// ==/UserScript== | |
// modified for seahorse by 958 | |
// base on http://d.hatena.ne.jp/fuba/20080919/1221824120 | |
(function(){ | |
var id = ''; | |
var links = document.getElementsByTagName('link'); | |
for (var i = 0, l = links.length; i < l; i++) { | |
if (links[i].getAttribute('rel') == 'alternate') { | |
id = links[i].href.match(/\d+/); | |
break; | |
} | |
} | |
if ((id == null) || (id == '')) return; | |
var http = new ActiveXObject('Microsoft.XMLHTTP'); | |
http.open("GET", '/users/show/' + id + '.xml', true); | |
http.onreadystatechange = function() { | |
if (http.readyState == 4) { | |
if (http.status == 200) { | |
if (http.responseText.match(/<favourites_count>(\d+)<\/favourites_count>/)) { | |
var span = document.createElement('span'); | |
span.className = 'stat_count'; | |
span.appendChild(document.createTextNode(RegExp.$1)); | |
var link = document.getElementById('favorites_tab'); | |
link.insertBefore(span, link.childNodes[0]); | |
} | |
} | |
http = null; | |
} | |
} | |
http.send(null); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment