Created
May 24, 2009 02:27
-
-
Save maraigue/116915 to your computer and use it in GitHub Desktop.
Source code for Twitter "ReTweet" bookmarklet (use in Twitter status page)
This file contains hidden or 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
| (function(){ | |
| var h,x,b; | |
| if(location.href.match(/^https?:\/\/(m\.|explore\.)?twitter\.com\/([0-9A-Z_a-z]+)\/status/)){ | |
| h="RT+@"+RegExp.$2+":+"; | |
| }else{ | |
| alert("Not in a tweet page!"); | |
| return; | |
| } | |
| x=(document.getElementsByTagName("body"))[0].innerHTML.match(/<span class="?entry-content"?>(.+?)<\/span>/ig); | |
| if(x && x.length==1){ | |
| b=RegExp.$1; | |
| b=b.replace(/@<a href="?\/([0-9A-Z_a-z]+)"?>\1<\/a>/ig,function(s,p){return "@"+p;}); | |
| b=b.replace(/<a [^>]*?class="?hashtag"?[^>]*?>#(.+?)<\/a>/ig,function(s,p){return "#"+p;}); | |
| b=b.replace(/<a href="?(https?:\/\/.+?)"? rel="?nofollow"? target="?_blank"?>.+?<\/a>/ig,function(s,p){return p;}); | |
| location.href="http://twitter.com/?status="+h+encodeURIComponent(b); | |
| }else{ | |
| alert("Can not extract the tweet!"); | |
| } | |
| })(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment