access_to_erep

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

Mint 2014.10.23.. Lásd a legutóbbi verzió

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

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 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.

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

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.1
// @grant       none
// ==/UserScript==

(function(){

	// 必须载入reward.js,否则每日任务奖励无法领取
	var scriptElement = document.createElement( "script" );
	scriptElement.type = "text/javascript";
	scriptElement.src = "https://www.erepublik.com/js/citizen/reward.js";
	document.body.appendChild( scriptElement );

	// 将所有http://链接替换成https://
	var links = document.getElementsByTagName("a");
	var t;
	for(var i = 0; i < links.length; i++) 	{
		t = links[i];
		t.href = t.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, r, i, s) {
		f2(e.replace("http://www.erepublik.com", "https://www.erepublik.com"), r, i, s);
	}

})();