access_to_erep

用https://访问游戏时,各个功能正常

Versione datata 22/10/2014. Vedi la nuova versione l'ultima versione.

Dovrai installare un'estensione come Tampermonkey, Greasemonkey o Violentmonkey per installare questo script.

You will need to install an extension such as Tampermonkey to install this script.

Dovrai installare un'estensione come Tampermonkey o Violentmonkey per installare questo script.

Dovrai installare un'estensione come Tampermonkey o Userscripts per installare questo script.

Dovrai installare un'estensione come ad esempio Tampermonkey per installare questo script.

Dovrai installare un gestore di script utente per installare questo script.

(Ho già un gestore di script utente, lasciamelo installare!)

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

(Ho già un gestore di stile utente, lasciamelo installare!)

// ==UserScript==
// @name        access_to_erep
// @namespace   eChina_Victory
// @description 用https://访问游戏时,各个功能正常
// @include     https://www.erepublik.com/*
// @version     1.0
// @grant       none
// ==/UserScript==

(function(){
	GM_wait();
})();

// Check if jQuery's loaded
function GM_wait() {
	if (typeof unsafeWindow.jQuery == 'undefined') {
		window.setTimeout(GM_wait, 100);
	} else {
		$ = unsafeWindow.jQuery;
		letsJQuery();
	}
}

function letsJQuery() {
	
	// 将所有http://链接替换成https://
	$("a").each(function() {
		this.href = this.href.replace("http://www.erepublik.com", "https://www.erepublik.com");
	});


	// 无头鸡还使用了getJSON()和post(),需要先把参数中的http替换成https,再
	// 调用正常的函数。
	var f1 = unsafeWindow.jQuery.getJSON;
	unsafeWindow.jQuery.getJSON = function(e, t, n) {
		f1(e.replace("http://www.erepublik.com", "https://www.erepublik.com"), t, n);
	}

	var f2 = unsafeWindow.jQuery.post;
	unsafeWindow.jQuery.post = function(e, n) {
		f2(e.replace("http://www.erepublik.com", "https://www.erepublik.com"), n);
	}

}