Bestmoba_FastBattle

Ускорение боев без благославленя валькирий (доната) в игре Хроники Хаоса

질문, 리뷰하거나, 이 스크립트를 신고하세요.
// ==UserScript==
// @name			Bestmoba_FastBattle
// @namespace		Bestmoba_FastBattle
// @version			0.16
// @description		Ускорение боев без благославленя валькирий (доната) в игре Хроники Хаоса
// @author			ZingerY
// @homepage		http://ilovemycomp.narod.ru/Bestmoba_FastBattle.user.js
// @icon			http://ilovemycomp.narod.ru/VaultBoyIco16.ico
// @icon64			http://ilovemycomp.narod.ru/VaultBoyIco64.png
// @encoding		utf-8
// @include			https://*.nextersglobal.com/*
// @include			https://*.hero-wars.com/*
// ==/UserScript==

(function() {
	/** Стартуем скрипт */
	console.log('Start ' + GM_info.script.name + ', v' + GM_info.script.version);

	const originalOpen = XMLHttpRequest.prototype.open;
	const originalSend = XMLHttpRequest.prototype.send;

	let apiUrl = '';
	let sNetwork = '';
	let socials = {
		vk: 1, // vk.com
		ok: 2, // ok.ru
		mm: 3, // my.mail.ru
		mg: 5, // store.my.games
		fb: 4, // apps.facebook.com
		wb: 6, // hero-wars.com
	}

	XMLHttpRequest.prototype.open = function (method, url, async, user, password) {
		this.checkOn = false;
		if (url.includes('.nextersglobal.com/api/')) {
			this.checkOn = true;
			if (!apiUrl) {
				apiUrl = url;
				socialInfo = /heroes-(.+?)\./.exec(apiUrl);
				sNetwork = socialInfo ? socialInfo[1] : 'vk';
			}
		}
		return originalOpen.call(this, method, url, async, user, password);
	};

	XMLHttpRequest.prototype.send = function (data) {
		if (this.checkOn) {
			var oldReady = this.onreadystatechange;
			this.onreadystatechange = function (e) {
				if(this.readyState == 4) {
					var responseText = this.responseText;
					Object.defineProperty(this, 'responseText', {writable: true});
					var ctime = Math.round(Date.now()/1000);
					var renewTime = ctime + 100 * 24 * 60 * 60;
					var endTime = ctime + 100 * 24 * 60 * 60;
					var seach = /{"ident":"subscriptionGetInfo","result":{"response":{.+?(}}}})/;
					var replace ='{"ident":"subscriptionGetInfo","result":{"response":{"subscription":{"level":1,"status":1,"type":'+socials[sNetwork]+',"endTime":'+endTime+',"lastFarm":"20214","ctime":'+ctime+',"daysLeft":100,"mayRenew":false,"renewTime":'+renewTime+',"pendingCancel":0,"endLoginTime":0,"vkSubscriptionId":"715870"},"dailyReward":{"availableFarm":false,"currentReward":{"coin":{"14":"400"}},"notFarmedDays":0}}}}';
					// Активируем вальку
					responseText = responseText.replace(seach, replace);
					// Фикс экспедиции вальки
					responseText = responseText.replace(/("id":5.+?status":)0/, '$13');
					this.responseText = responseText;
				}
				if (oldReady) {
					return oldReady.apply(this, arguments);
				}
			}
		}
		return originalSend.call(this, data);
	};
})();