Created
January 23, 2009 16:42
-
-
Save niku/51071 to your computer and use it in GitHub Desktop.
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 automatic moving @mixi | |
// @description automatic moving script to an external link | |
// @namespace http://niku.name/ | |
// @include http://mixi.jp/view_diary.pl?url=* | |
// @include http://mixi.jp/new_friend_diary.pl* | |
// ==/UserScript== | |
// style definition for external url | |
// Ex. | |
//var external_url_style = 'font-weight:bold; font-style:italic;'; | |
//var external_url_style = 'background-color:yellow;'; | |
var external_url_style = 'border-style:solid;border-width:1px 1px 0 1px;'; | |
(function (){ | |
var anchor = document.getElementsByTagName('A'); | |
if(document.URL.match(/new_friend_diary.pl/)) { | |
for(i=0; i<anchor.length; i++) { | |
var diary_url = anchor[i].href; | |
if(diary_url.match(/view_diary/)&&diary_url.match(/url=/)) { | |
anchor[i].innerHTML='<span style="'+external_url_style+'">'+anchor[i].innerHTML+'</span>'; | |
} | |
} | |
} | |
if(document.URL.match(/view_diary.pl/)) { | |
var start_external_url = document.URL.indexOf("http",4); | |
var end_external_url = document.URL.indexOf("&owner",0); | |
var external_url = unescape(document.URL.substring(start_external_url,end_external_url)); | |
for(i=0;i<anchor.length;i++) | |
if(anchor[i].href==external_url) location.replace(anchor[i].href); | |
} | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment