access_to_erep

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

Tính đến 22-10-2014. Xem phiên bản mới nhất.

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

Bạn sẽ cần cài đặt một tiện ích mở rộng như Tampermonkey hoặc Violentmonkey để cài đặt kịch bản này.

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

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

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

You will need to install a user script manager extension to install this script.

(Tôi đã có Trình quản lý tập lệnh người dùng, hãy cài đặt nó!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

// ==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);
	}

}