Created
June 26, 2010 13:59
-
-
Save os0x/454071 to your computer and use it in GitHub Desktop.
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
| // ==UserScript== | |
| // @name hitode pack | |
| // @namespace http://ss-o.net | |
| // @include http://twitter.com/* | |
| // ==/UserScript== | |
| function hitode_pack(){ | |
| Array.prototype.forEach.call(document.querySelectorAll('.entry-content, .status') , function(a){ | |
| var text = a.innerHTML.trim(); | |
| if (text[0] === text[1]) { | |
| var l = 0; | |
| var html = text.match(/(.)\1*/g).map(function(s,i,a){ | |
| l += s.length / a.length; | |
| return {c:s[0],l:s.length}; | |
| }).map(function(v){ | |
| if (v.l > l * 1.7){ | |
| return v.c + v.c; | |
| } else { | |
| return v.c; | |
| } | |
| }).join(''); | |
| if(l < 1.7) return; | |
| a.innerHTML = html.replace(/https?:\/\/[^\s\])'")」】]+/g,function(h){ | |
| return '<a href="'+h+'">'+h+'</a>'; | |
| }).replace(/@(\w+)/g,'<a href="$1">$&</a>') + '<br><br>' + a.innerHTML; | |
| } | |
| }); | |
| } | |
| var t = document.getElementById('timeline') || document.getElementById('permalink'); | |
| if (t) { | |
| hitode_pack(); | |
| t.addEventListener('DOMNodeInserted', function F() { | |
| t.removeEventListener('DOMNodeInserted', F, false); | |
| setTimeout(function(){ | |
| hitode_pack(); | |
| t.addEventListener('DOMNodeInserted', F, false); | |
| },1000); | |
| }, false); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment