Created
November 26, 2010 11:33
-
-
Save edvakf/716590 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== | |
| // @include http://a.hatena.ne.jp/* | |
| // ==/UserScript== | |
| (function() { | |
| function replaceLinks() { | |
| Array.prototype.forEach.call( | |
| document.querySelectorAll('a[href^="http://a.st-hatena.com/go?"]'), | |
| function(a) { | |
| var num, frag = ''; | |
| a.href = a.href | |
| .replace('http://a.st-hatena.com/go?', '') | |
| .replace(/\d{14}$/, function(n) {num = n; return ''}) | |
| .replace(/#.*/, function(f) {frag = f; return ''}); | |
| if (frag) { | |
| a.href += (a.href.indexOf('?') >= 0 ? '&' : '?') + num + frag; | |
| } else { | |
| a.href += '#' + num; | |
| } | |
| } | |
| ); | |
| } | |
| var loaded = false; | |
| window.addEventListener('DOMContentLoaded', function(){loaded = true;}, false); | |
| var timer = setInterval(function() { | |
| replaceLinks(); | |
| if (loaded) clearInterval(timer); | |
| }, 10); | |
| }()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment