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.

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 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;}");
					}
				}
			}
		}
	}
}