-
-
Save anonymous/650b3226131a7c1db493 to your computer and use it in GitHub Desktop.
URL Replacement for BACKPACKINGLIGHT.COM forums
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
<script type="text/javascript" async defer> | |
$(function(){ | |
var regex = /\b(([\w-]+:\/\/?|www[.])[^\s()<>]+(?:\([\w\d]+\)|([^[:punct:]\s]|)))/gi; | |
$("td.body").each(function(i, elem){ | |
var $elem = $(elem); | |
var html = $elem.html(); | |
$elem.html(html.replace(regex, function(str){ | |
var index = html.indexOf(str, 0); | |
if (html[index - 1] != '"') { // make sure it's not already a link | |
return "<a href='" + str + "'>" + str + "</a>"; | |
} else { | |
return str; | |
} | |
})); | |
}); | |
})</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment