Created
September 18, 2009 05:32
-
-
Save edvakf/188895 to your computer and use it in GitHub Desktop.
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
/* "foobar RT @hoge : blah blah..." into "<q>blah blah... (<a>@hoge</a>)<q> foobar" */ | |
(function(){ | |
var re = /^([\s\S]*?)RT\s*(<[aA].*?>@\w+<\/[aA]>)[:\s]*(\S[\s\S]*)$/; | |
function semanticRT(html){ | |
return html.replace(re, function(str, $1, $2, $3){ | |
return '↪ <q class="retweet">' + semanticRT($3) + ' <cite>(' + $2 + ')</cite></q> ' + $1; | |
}) | |
} | |
function betterRT(elem){ | |
var st = elem.getElementsByClassName('status')[0]; | |
if (!re.test(st.innerHTML)) return; | |
st.innerHTML = semanticRT(st.innerHTML); | |
} | |
registerPlugin({ | |
newMessageElement : betterRT | |
}); | |
})() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment