GaiaOnline Link Fixer V2

Searches for links on GaiaOnline, then makes them open in the same window for on-site links and then alerts you based on the settings. This applies to user post.

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。

您需要先安装用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name	GaiaOnline Link Fixer V2
// @description Searches for links on GaiaOnline, then makes them open in the same window for on-site links and then alerts you based on the settings. This applies to user post.
// @include	http://gaiaonline.com/*
// @include	http://www.gaiaonline.com/*
// @version 0.0.1.20140525024112
// @namespace https://greasyfork.org/users/2178
// ==/UserScript==
///////////////////SETTINGS//////////////////////
var cl="off" // alerts to leaving site with confirm box
var wf="off" // alerts to leaving site with Gaia's warning frame
/////////////////////////////////////////////////
if ( !(cl == "off") && !(cl == "on") || !(wf == "off") && !(wf == "on") ) {
	alert('GaiaOnline Link Fixer V2 says:\nInvalid setting you must use "on" or "off".');
}
else {
	var redirect = "http://www.gaiaonline.com/gaia/redirect.php";
	var atags = document.getElementsByTagName('a');
	for (var x = 0; x < atags.length; x=x+1) {
		var atag = atags[x];
		for (var y = 0; y < 2; y=y+1) {
			if (atag.href.substr(0,43) == redirect) {
			  var url = atag.href.substr(46)
				if (url.substr(0,4)!='http'){
					url='http://'+url;
				}
				atag.href = unescape(url);
				var gaia=atag.hostname
				for (i=0;i<=i+1;i++){
					if(gaia.indexOf('.')!=gaia.lastIndexOf('.')){
						gaia=document.domain.slice(document.domain.indexOf('.')+1)
					}
					else{
						break;
					}
				}
				if (gaia == 'gaiaonline.com') {
					atag.removeAttribute('target');
				}
				else {
					if (wf=="on") {
						atag.href = redirect + "?r=" + atag.href;
					}
					if (cl=="on") {
						atag.setAttribute('onclick',"if (confirm('Go to:\\n" + atag.href + "')==true) {return true;} else {return false;}");
					}
				}
			}
		}
	}
}