// ==UserScript==
// @name ZouZhiZhangBM
// @version 1.21
// @namespace zouzhizhang
// @description bm
// @include http://www.erepublik.com/*
// @include http://www// ==UserScript==
// @name ZouZhiZhangBM
// @namespace zouzhizhang
// @description bm
// @include http://www.erepublik.com/*
// @include http://www.*.lindasc.com/*
// @include https://www.erepublik.com/*
// @grant GM_wait
// @downloadURL none
// ==/UserScript==
var onBattlePage = false;
var onHttps = false;
var multiHitRunning = false;
var multiHitCount = 0;
var multiHitDone = 0;
var multiHitModeEnergy = true;
var multiHitEnemyKill = 0;
var multiHitLastKilled = false;
var multiHitLoopId = 0;
var foodUrl1 = '';
var foodUrl2 = '&buttonColor=';
var foodUrl3 = '&jsoncallback=?';
var currentHealth = unsafeWindow.SERVER_DATA.health;
var fireAll = false;
function canGetWell() {
var h = $j('#heal_btn');
var trigger = $j('#DailyConsumtionTrigger');
if ($j('#heal_btn small') .html() != '0' && !h.hasClass('disabled')) {
return true
}
if ($j('input#multihit_food') .is(':checked') && !trigger.hasClass('disabled') && !trigger.hasClass('buy') && !trigger.hasClass('energy')) {
return true
}
if ($j('input#multihit_energy') .is(':checked') && !trigger.hasClass('disabled') && trigger.hasClass('energy')) {
return true
}
return false
}
function GM_wait() {
var onNewBattlePage = location.href.match(/^(.*military\/battlefield)(\-new)(\/[0-9]+.*)$/);
if (!!onNewBattlePage && onNewBattlePage[2] == '-new') {
location.href = onNewBattlePage[1] + onNewBattlePage[3];
return ;
}
if (typeof unsafeWindow.jQuery == 'undefined') {
window.setTimeout(GM_wait, 100)
} else {
$j = unsafeWindow.jQuery;
letsJQuery()
}
}
function letsJQuery() {
if (typeof unsafeWindow == 'undefined') {
unsafeWindow = window
}
onBattlePage = !!location.href.match(/^.*(military\/battlefield(?:|\-new)\/[0-9]+).*$/);
onHttps = !!location.href.match(/^https\:\/\/(.*)$/);
$j('a[href]') .each(function () {
var delete_new = this.href.match(/^(.*military\/battlefield)(\-new)(\/[0-9]+.*)$/);
if (!!delete_new && delete_new[2] == '-new') {
this.href = delete_new[1] + delete_new[3];
}
var parse_https = this.href.match(/^http\:\/\/(.*)$/);
if (onHttps && !!parse_https) {
this.href = 'https://' + parse_https[1];
}
});
if (!onBattlePage) {
return ;
}
unsafeWindow.jQuery.fx.off = true;
foodUrl1 = location.href.match(/^(.*)military\/battlefield\/\d+.*$/) [1] + 'main/eat?format=json&_token=' + $j('#' + $j('div.user_health input[type=hidden]') .attr('id')) .val();
fireAll = !!location.href.match(/^.*(\#BM_FIRE_ALL)$/);
$j('div#enemy_defeated') .before('
' + 'Delay:
' + ' Consumed:
X
' + '
' + '
' + (fireAll ? '
Fire All Mode ON !!!' : '') + '
');
if (unsafeWindow.SERVER_DATA.battleFinished != 0) {
$j('div#MHP') .hide()
}
$j('#blue_domination') .css({
'opacity': '1',
'color': '#fff'
});
$j('#red_domination') .css({
'opacity': '1',
'color': '#fff'
});
$j('b.pdomi_left') .css({
'width': '67px'
});
$j('b.pdomi_right') .css({
'width': '67px'
});
$j('b.pdomi_left em') .css({
'right': '5px',
'opacity': '1',
'color': '#fff'
});
$j('b.pdomi_right em') .css({
'left': '5px',
'opacity': '1',
'color': '#fff'
});
$j('#drop_part') .css({
'z-index': '3'
});
$j(document) .ready(function () {
clearInterval(unsafeWindow.globalSleepInterval);
unsafeWindow.shootLockout = 1
});
setInterval(function () {
var h = $j('#heal_btn');
if ($j('#heal_btn small') .html() != '0' && !h.hasClass('disabled') && unsafeWindow.SERVER_DATA.onlySpectator == 0) {
unsafeWindow.useHospital()
}
}, 250);
unsafeWindow.battleFX.hit = function () {
if (multiHitRunning) {
multiHitDone = multiHitDone + (currentHealth - unsafeWindow.SERVER_DATA.health) / 10;
currentHealth = unsafeWindow.SERVER_DATA.health;
$j('div#multihit_message') .html('Energy consumed: ' + multiHitDone * 10 + ' Kills: ' + multiHitEnemyKill + ' (' + (multiHitLastKilled ? 'Last Enemy killed!' : 'Last Enemy alive!') + ')');
multiHitLastKilled = false;
clearTimeout(multiHitLoopId);
multiHitLoopId = setTimeout('jQuery.fn.multiHIT()', $j('input#multihit_delay') .val())
}
return false
};
unsafeWindow.battleFX.blow = function () {
if (multiHitRunning) {
multiHitEnemyKill++;
multiHitLastKilled = true
}
return false
};
unsafeWindow.battleFX.pop = function (target, width) {
if (target == 'enemy_defeated') {
unsafeWindow.closeAddDamagePopup()
} else if (target == 'rank_up') {
unsafeWindow.closeAddRankPopup()
} else {
if (typeof width == 'undefined' || typeof width == undefined)
width = '396px';
var useTarget = $j('#' + target) [0];
$j('#pvp') .block({
message: useTarget,
overlayCSS: {
backgroundColor: '#000207',
opacity: 0.5
},
css: {
width: width
}
})
}
return false
};
unsafeWindow.battleFX.countNextBattle = function (time) {
if (isNaN(time.getMonth())) {
setTimeout(function () {
top.location.href = document.location.href
}, 1000);
return false
}
$j('#time_until') .countdown({
until: time,
format: 'MS',
compact: true,
description: '',
onTick: checkTime
});
function checkTime(periods) {
if ($j.countdown.periodsToSeconds(periods) == 0) {
$j('#waiting') .fadeOut('fast');
$j('#waiting') .removeClass('clock');
$j('#notify_link') .fadeIn('fast');
$j('#notify_link') .click();
setTimeout(function () {
top.location.href = document.location.href
}, 2000)
}
}
return false
};
unsafeWindow.jQuery.fn.getWell = function () {
var h = $j('#heal_btn');
var trigger = $j('#DailyConsumtionTrigger');
if ($j('#heal_btn small') .html() != '0' && !h.hasClass('disabled') && unsafeWindow.SERVER_DATA.onlySpectator == 0) {
unsafeWindow.useHospital()
} else if ($j('input#multihit_food') .is(':checked') && !trigger.hasClass('disabled') && !trigger.hasClass('buy') && !trigger.hasClass('energy') || $j('input#multihit_energy') .is(':checked') && !trigger.hasClass('disabled') && trigger.hasClass('energy')) {
$j('#heal_btn small') .hide();
h.removeClass('hospital_btn');
h.attr('title', 'Consume Food');
unsafeWindow.ERPK.disableHealButton();
$j('#DailyConsumtionTrigger') .addClass('load');
$j.getJSON(foodUrl1 + foodUrl2 + (trigger.hasClass('energy') ? 'orange' : 'blue') + foodUrl3, {
}, function (data) {
$j('#DailyConsumtionTrigger') .removeClass('load');
data.health = parseFloat(data.health);
var wellInc = data.health - unsafeWindow.SERVER_DATA.health;
currentHealth = data.health;
unsafeWindow.energy.processResponse(data);
clearTimeout(multiHitLoopId);
multiHitLoopId = setTimeout('jQuery.fn.multiHIT()', 250)
})
}
};
unsafeWindow.jQuery.fn.changeWeapon = function () {
var url = '/en/military/change-weapon';
unsafeWindow.ERPK.disableAllButtons();
$j.post(url, {
_token: unsafeWindow.SERVER_DATA.csrfToken,
battleId: unsafeWindow.SERVER_DATA.battleId
}, function (response) {
unsafeWindow.updateFighterWeapon($j('#scroller') .data('scrollable'), response);
unsafeWindow.ERPK.enableAllButtons();
if ($j('.listing span img') .eq( - 1) .attr('src') .indexOf('q10') !== - 1) {
multiHitRunning = false;
$j('button#multihit_start') .html('HIT!');
return
} else {
clearTimeout(multiHitLoopId);
multiHitLoopId = setTimeout('jQuery.fn.multiHIT()', 250);
return
}
}, 'json')
};
unsafeWindow.jQuery.fn.multiHIT = function () {
if (unsafeWindow.globalStop || multiHitCount <= (multiHitModeEnergy ? multiHitDone : multiHitEnemyKill)) {
multiHitRunning = false;
$j('button#multihit_start') .html('HIT!');
return
}
if (unsafeWindow.ERPK.canFire()) {
if ($j('input#multihit_bazooka') .is(':checked') && $j('.listing span img') .eq( - 1) .attr('src') .indexOf('q10') !== - 1) {
unsafeWindow.jQuery.fn.changeWeapon()
} else {
unsafeWindow.shoot()
}
} else if (canGetWell()) {
unsafeWindow.jQuery.fn.getWell()
} else {
multiHitRunning = false;
$j('button#multihit_start') .html('HIT!');
return
}
};
$j('button#multihit_start') .click(function () {
if (multiHitRunning) {
clearTimeout(multiHitLoopId);
multiHitRunning = false;
$j('button#multihit_start') .html('HIT!')
} else {
multiHitCount = $j('input#multihit_count') .val();
if (multiHitCount > 0) {
currentHealth = Number($j('strong#current_health') .text() .split('/') [0]);
multiHitDone = 0;
multiHitEnemyKill = 0;
multiHitLastKilled = false;
multiHitRunning = true;
$j('button#multihit_start') .html('
STOP!');
unsafeWindow.jQuery.fn.multiHIT()
}
}
});
$j('button#multihit_mode') .click(function () {
if (multiHitModeEnergy) {
multiHitModeEnergy = false;
$j('button#multihit_mode') .html('Enemy');
} else {
multiHitModeEnergy = true;
$j('button#multihit_mode') .html('10 Energy')
}
});
if (fireAll) {
setInterval(function () {
if (!multiHitRunning) {
$j('button#multihit_start') .click()
}
setTimeout(2000, callback)
}, 2000)
}
}
GM_wait()
.*.lindasc.com/*
// @include https://www.erepublik.com/*
// @grant GM_wait
// ==/UserScript==
var onBattlePage = false;
var onHttps = false;
var multiHitRunning = false;
var multiHitCount = 0;
var multiHitDone = 0;
var multiHitModeEnergy = true;
var multiHitEnemyKill = 0;
var multiHitLastKilled = false;
var multiHitLoopId = 0;
var foodUrl1 = '';
var foodUrl2 = '&buttonColor=';
var foodUrl3 = '&jsoncallback=?';
var currentHealth = unsafeWindow.SERVER_DATA.health;
var fireAll = false;
function canGetWell() {
var h = $j('#heal_btn');
var trigger = $j('#DailyConsumtionTrigger');
if ($j('#heal_btn small') .html() != '0' && !h.hasClass('disabled')) {
return true
}
if ($j('input#multihit_food') .is(':checked') && !trigger.hasClass('disabled') && !trigger.hasClass('buy') && !trigger.hasClass('energy')) {
return true
}
if ($j('input#multihit_energy') .is(':checked') && !trigger.hasClass('disabled') && trigger.hasClass('energy')) {
return true
}
return false
}
function GM_wait() {
var onNewBattlePage = location.href.match(/^(.*military\/battlefield)(\-new)(\/[0-9]+.*)$/);
if (!!onNewBattlePage && onNewBattlePage[2] == '-new') {
location.href = onNewBattlePage[1] + onNewBattlePage[3];
return ;
}
if (typeof unsafeWindow.jQuery == 'undefined') {
window.setTimeout(GM_wait, 100)
} else {
$j = unsafeWindow.jQuery;
letsJQuery()
}
}
function letsJQuery() {
if (typeof unsafeWindow == 'undefined') {
unsafeWindow = window
}
onBattlePage = !!location.href.match(/^.*(military\/battlefield(?:|\-new)\/[0-9]+).*$/);
onHttps = !!location.href.match(/^https\:\/\/(.*)$/);
$j('a[href]') .each(function () {
var delete_new = this.href.match(/^(.*military\/battlefield)(\-new)(\/[0-9]+.*)$/);
if (!!delete_new && delete_new[2] == '-new') {
this.href = delete_new[1] + delete_new[3];
}
var parse_https = this.href.match(/^http\:\/\/(.*)$/);
if (onHttps && !!parse_https) {
this.href = 'https://' + parse_https[1];
}
});
if (!onBattlePage) {
return ;
}
unsafeWindow.jQuery.fx.off = true;
foodUrl1 = location.href.match(/^(.*)military\/battlefield\/\d+.*$/) [1] + 'main/eat?format=json&_token=' + $j('#' + $j('div.user_health input[type=hidden]') .attr('id')) .val();
fireAll = !!location.href.match(/^.*(\#BM_FIRE_ALL)$/);
$j('div#enemy_defeated') .before('
' + 'Delay:
' + ' Consumed:
X
' + '
' + '
' + (fireAll ? '
Fire All Mode ON !!!' : '') + '
');
if (unsafeWindow.SERVER_DATA.battleFinished != 0) {
$j('div#MHP') .hide()
}
$j('#blue_domination') .css({
'opacity': '1',
'color': '#fff'
});
$j('#red_domination') .css({
'opacity': '1',
'color': '#fff'
});
$j('b.pdomi_left') .css({
'width': '67px'
});
$j('b.pdomi_right') .css({
'width': '67px'
});
$j('b.pdomi_left em') .css({
'right': '5px',
'opacity': '1',
'color': '#fff'
});
$j('b.pdomi_right em') .css({
'left': '5px',
'opacity': '1',
'color': '#fff'
});
$j('#drop_part') .css({
'z-index': '3'
});
$j(document) .ready(function () {
clearInterval(unsafeWindow.globalSleepInterval);
unsafeWindow.shootLockout = 1
});
setInterval(function () {
var h = $j('#heal_btn');
if ($j('#heal_btn small') .html() != '0' && !h.hasClass('disabled') && unsafeWindow.SERVER_DATA.onlySpectator == 0) {
unsafeWindow.useHospital()
}
}, 250);
unsafeWindow.battleFX.hit = function () {
if (multiHitRunning) {
multiHitDone = multiHitDone + (currentHealth - unsafeWindow.SERVER_DATA.health) / 10;
currentHealth = unsafeWindow.SERVER_DATA.health;
$j('div#multihit_message') .html('Energy consumed: ' + multiHitDone * 10 + ' Kills: ' + multiHitEnemyKill + ' (' + (multiHitLastKilled ? 'Last Enemy killed!' : 'Last Enemy alive!') + ')');
multiHitLastKilled = false;
clearTimeout(multiHitLoopId);
multiHitLoopId = setTimeout('jQuery.fn.multiHIT()', $j('input#multihit_delay') .val())
}
return false
};
unsafeWindow.battleFX.blow = function () {
if (multiHitRunning) {
multiHitEnemyKill++;
multiHitLastKilled = true
}
return false
};
unsafeWindow.battleFX.pop = function (target, width) {
if (target == 'enemy_defeated') {
unsafeWindow.closeAddDamagePopup()
} else if (target == 'rank_up') {
unsafeWindow.closeAddRankPopup()
} else {
if (typeof width == 'undefined' || typeof width == undefined)
width = '396px';
var useTarget = $j('#' + target) [0];
$j('#pvp') .block({
message: useTarget,
overlayCSS: {
backgroundColor: '#000207',
opacity: 0.5
},
css: {
width: width
}
})
}
return false
};
unsafeWindow.battleFX.countNextBattle = function (time) {
if (isNaN(time.getMonth())) {
setTimeout(function () {
top.location.href = document.location.href
}, 1000);
return false
}
$j('#time_until') .countdown({
until: time,
format: 'MS',
compact: true,
description: '',
onTick: checkTime
});
function checkTime(periods) {
if ($j.countdown.periodsToSeconds(periods) == 0) {
$j('#waiting') .fadeOut('fast');
$j('#waiting') .removeClass('clock');
$j('#notify_link') .fadeIn('fast');
$j('#notify_link') .click();
setTimeout(function () {
top.location.href = document.location.href
}, 2000)
}
}
return false
};
unsafeWindow.jQuery.fn.getWell = function () {
var h = $j('#heal_btn');
var trigger = $j('#DailyConsumtionTrigger');
if ($j('#heal_btn small') .html() != '0' && !h.hasClass('disabled') && unsafeWindow.SERVER_DATA.onlySpectator == 0) {
unsafeWindow.useHospital()
} else if ($j('input#multihit_food') .is(':checked') && !trigger.hasClass('disabled') && !trigger.hasClass('buy') && !trigger.hasClass('energy') || $j('input#multihit_energy') .is(':checked') && !trigger.hasClass('disabled') && trigger.hasClass('energy')) {
$j('#heal_btn small') .hide();
h.removeClass('hospital_btn');
h.attr('title', 'Consume Food');
unsafeWindow.ERPK.disableHealButton();
$j('#DailyConsumtionTrigger') .addClass('load');
$j.getJSON(foodUrl1 + foodUrl2 + (trigger.hasClass('energy') ? 'orange' : 'blue') + foodUrl3, {
}, function (data) {
$j('#DailyConsumtionTrigger') .removeClass('load');
data.health = parseFloat(data.health);
var wellInc = data.health - unsafeWindow.SERVER_DATA.health;
currentHealth = data.health;
unsafeWindow.energy.processResponse(data);
clearTimeout(multiHitLoopId);
multiHitLoopId = setTimeout('jQuery.fn.multiHIT()', 250)
})
}
};
unsafeWindow.jQuery.fn.changeWeapon = function () {
var url = '/en/military/change-weapon';
unsafeWindow.ERPK.disableAllButtons();
$j.post(url, {
_token: unsafeWindow.SERVER_DATA.csrfToken,
battleId: unsafeWindow.SERVER_DATA.battleId
}, function (response) {
unsafeWindow.updateFighterWeapon($j('#scroller') .data('scrollable'), response);
unsafeWindow.ERPK.enableAllButtons();
if ($j('.listing span img') .eq( - 1) .attr('src') .indexOf('q10') !== - 1) {
multiHitRunning = false;
$j('button#multihit_start') .html('HIT!');
return
} else {
clearTimeout(multiHitLoopId);
multiHitLoopId = setTimeout('jQuery.fn.multiHIT()', 250);
return
}
}, 'json')
};
unsafeWindow.jQuery.fn.multiHIT = function () {
if (unsafeWindow.globalStop || multiHitCount <= (multiHitModeEnergy ? multiHitDone : multiHitEnemyKill)) {
multiHitRunning = false;
$j('button#multihit_start') .html('HIT!');
return
}
if (unsafeWindow.ERPK.canFire()) {
if ($j('input#multihit_bazooka') .is(':checked') && $j('.listing span img') .eq( - 1) .attr('src') .indexOf('q10') !== - 1) {
unsafeWindow.jQuery.fn.changeWeapon()
} else {
unsafeWindow.shoot()
}
} else if (canGetWell()) {
unsafeWindow.jQuery.fn.getWell()
} else {
multiHitRunning = false;
$j('button#multihit_start') .html('HIT!');
return
}
};
$j('button#multihit_start') .click(function () {
if (multiHitRunning) {
clearTimeout(multiHitLoopId);
multiHitRunning = false;
$j('button#multihit_start') .html('HIT!')
} else {
multiHitCount = $j('input#multihit_count') .val();
if (multiHitCount > 0) {
currentHealth = Number($j('strong#current_health') .text() .split('/') [0]);
multiHitDone = 0;
multiHitEnemyKill = 0;
multiHitLastKilled = false;
multiHitRunning = true;
$j('button#multihit_start') .html('
STOP!');
unsafeWindow.jQuery.fn.multiHIT()
}
}
});
$j('button#multihit_mode') .click(function () {
if (multiHitModeEnergy) {
multiHitModeEnergy = false;
$j('button#multihit_mode') .html('Enemy');
} else {
multiHitModeEnergy = true;
$j('button#multihit_mode') .html('10 Energy')
}
});
if (fireAll) {
setInterval(function () {
if (!multiHitRunning) {
$j('button#multihit_start') .click()
}
setTimeout(2000, callback)
}, 2000)
}
}
GM_wait()