iShout MOD

Mass Shout in erepublik for e-Iran MOD

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey, Greasemonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

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

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

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

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्क्रिप्ट व्यवस्थापक एक्स्टेंशन इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्क्रिप्ट व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्टाईल व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

// ==UserScript==
// @author          iMan
// @name            iShout MOD
// @namespace       iShout for e-Iran MOD
// @description     Mass Shout in erepublik for e-Iran MOD
// @version         1.0.0
// @match           http://www.erepublik.com/en
// @match           https://www.erepublik.com/en
// @match           http://www.erepublik.com/fa
// @match           https://www.erepublik.com/fa
// @include         http://www.erepublik.com/en
// @include         https://www.erepublik.com/en
// @include         http://www.erepublik.com/fa
// @include         https://www.erepublik.com/fa
// @require         https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js
// ==/UserScript==

var LANG = typeof unsafeWindow.erepublik.settings.culture == "undefined" ? unsafeWindow.culture : unsafeWindow.erepublik.settings.culture;
var temp = $(".user_name").attr("href").split("/");
var citizenID = temp[temp.length-1];

function shout(){
	GM_xmlhttpRequest({
		method: "GET",
		url: "http://iran.erep.ir/MOD/ishoutmessage.php?UID="+citizenID,
		dataType: "html",
		onload: function (e) {
			var data = e.responseText;
			var strength = parseInt($(data).find(".citizen_military").eq(0).find(".stat small strong").text().split("/")[0].trim().replace(",", ""));
			var rank = img_rank[$(data).find(".citizen_military").eq(1).find("h4 img").attr("src").split("/")[6].split(".")[0]];
			var s = Math.round(10 * (1 + strength / 400) * (1 + rank / 5) * (1 + 200 / 100));
			shoutend(s,unsafeWindow.SERVER_DATA.csrfToken);
		}
	})
}
function shoutend(mes,tok){
	var name = $(".user_name").text();
	GM_xmlhttpRequest({
		method: "POST",
		url: "http://www.erepublik.com/en/main/wall-post/create/",
        data: "post_message="+mes+"&_token="+tok,
        headers: {
            "Content-Type": "application/x-www-form-urlencoded"
        },        
		onload: function (e) {
			var data = e.responseText;
			$("#iShout1").text("Ready");
			var currentTime = new Date().getTime();
			GM_setValue("iShoutReport",currentTime.toString());
			wait();
		}
	})	
}


function wait(){
	var timerSet = parseInt(GM_getValue("iShoutReport"));
	var nowTime = new Date();
	var diff = nowTime.getTime() - timerSet;
	if(diff <= 600000){		
		diff = Math.floor((600000 - diff)/1000);
		$("#iShout1").text("(شات شده) ("+diff+")");
		setTimeout(wait,1000);
	}
	else{
		reset();
	}
}

function reset(){
	$("#iShout1").removeAttr("disabled");
	$("#iShout1").text("ارسال شات");
}

var version = "0.0.1";

$(document).ready(function () {
	$(".user_identity").after('<div class="user_identity" style="text-align:center; margin:0;"><button id="iShout1">ارسال شات</button></div>');
	$("#iShout1").attr("disabled","disabled");
	$("#iShout1").click(function(){
		$(this).attr("disabled","disabled");
		$(this).text("لطفاً صبر کنید");
		shout();        
	});
	e = GM_getValue("iShoutReport");
	if(typeof e != "undefined"){
		$("#iShout1").text("Ready");
		wait();
	}
	else{
		$("#iShout1").removeAttr("disabled");
	}
})