Skip to content

Instantly share code, notes, and snippets.

View odiak's full-sized avatar

Kaido Iwamoto odiak

View GitHub Profile
@odiak
odiak / gist:1091777
Created July 19, 2011 09:01 — forked from namusyaka/gist:1091385
外部リンク自動検出のやつ source:rskull
(function () {
var regex = /^(https?:\/\/(?:[0-9a-z\-]\.?)+(?::\d+)?)(?:\/.*)?$/,
replace = "$1",
baseURL = location.href.replace(regex, replace),
links = document.links,
i, len, href;
for (i = 0, len = links.length; i < len; i ++) {
href = links[i].href;
if (regex.test(href) && href.replace(regex, replace) !== baseURL) {