Created
January 31, 2011 08:00
-
-
Save orangain/803759 to your computer and use it in GitHub Desktop.
A greasemonkey script to replace a link to copy site of Stack Overflow with a link to the original page
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 Link to Stack Overflow | |
// @namespace http://capybala.com/ | |
// @description Replace a link to copy site of Stack Overflow with a link to the original page | |
// @include http://www.google.co.jp/search* | |
// ==/UserScript== | |
var regex_list = [ | |
/^http:\/\/ja\.w3support\.net\/.*db=(\w+).*id=(\w+)/ | |
]; | |
var dbs = { | |
so: 'http://stackoverflow.com/questions/', | |
su: 'http://superuser.com/questions/' | |
}; | |
var i, j; | |
for (i = 0; i < document.links.length; i++) { | |
var link = document.links[i]; | |
for (j = 0; j < regex_list.length; j++) { | |
var match = link.href.match(regex_list[j]); | |
if (match != null) { | |
var db = match[1]; | |
var id = match[2]; | |
if (!dbs[db]) { | |
break; | |
} | |
link.href = dbs[db] + id; | |
break; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment