Moderators: Tech Team, Global Moderators
// ==UserScript==
// @name Conquer Club - Ajax BOB
// @namespace http://www.itj.com.br/
// @description Ajax BOB
// @include http://*conquerclub.com*
// ==/UserScript==
var TimeStr = document.getElementById('clock').innerHTML;
var TargetTime = TimeStr.split(/hrs\n|min\n|sec/);
var CurrHour = parseInt(TargetTime[0]);
var CurrMinute = parseInt(TargetTime[1]);
var CurrSecond = parseInt(TargetTime[2]);
ClockInterval = window.setInterval(ClockTimer, 1000);
function ClockTimer()
{
--CurrSecond;
if(CurrSecond < 0 ){
--CurrMinute;
if( CurrMinute < 0 ){
--CurrHour;
if( CurrHour < 0 ){
CurrHour = 0;
}
CurrMinute = 59;
}
CurrSecond = 59;
}
StrClock = document.getElementById('clock');
if (CurrHour < 10) {
StrClock.innerHTML = '0' + CurrHour + 'hrs ';
} else {
StrClock.innerHTML = CurrHour + 'hrs ';
}
if (CurrMinute < 10) {
StrClock.innerHTML += '0' + CurrMinute + 'min ';
} else {
StrClock.innerHTML += CurrMinute + 'min ';
}
if (CurrSecond < 10) {
StrClock.innerHTML += '0' + CurrSecond + 'sec ';
} else {
StrClock.innerHTML += CurrSecond + 'sec ';
}
var CurrDate = new Date();
if (CurrDate.getHours() < 10) {
StrClock.innerHTML += ' @ <b>0' + (CurrDate.getHours()) + ':</b>';
} else {
StrClock.innerHTML += ' @ <b>' + (CurrDate.getHours()) + ':</b>';
}
if (CurrDate.getMinutes() < 10) {
StrClock.innerHTML += '<b>0' + (CurrDate.getMinutes()) + '</b>';
} else {
StrClock.innerHTML += '<b>' + (CurrDate.getMinutes()) + '</b>';
}
}
var handleResponse = function()
{
alert('Nothing will happen');
}
function handleResponse()
{
alert('Nothing will happen');
}var handleResponse = function()
{
alert('Nothing will happen');
}
lackattack wrote:Here's a tip for anyone trying to fix BOB. There is an function I put in called handleResponse() that runs each time an AJAX response comes in. Perhaps the GM script could re-define that function to call gm_ConquerClubGame() at the end?
var bob_gameLog = unsafeWindow.gameLog;
var newhandleResponse = unsafeWindow.handleResponse;
unsafeWindow.handleResponse = function() {
bob_gameLog.innerHTML += 'I am here!<br>';
return newhandleResponse();
}
lackattack wrote:What if you had
- Code: Select all
function handleResponse()
{
alert('Nothing will happen');
}
instead of
- Code: Select all
var handleResponse = function()
{
alert('Nothing will happen');
}
mfontolan wrote:Here is where I think we can go for...
- Code: Select all
var bob_gameLog = unsafeWindow.gameLog;
var newhandleResponse = unsafeWindow.handleResponse;
unsafeWindow.handleResponse = function() {
bob_gameLog.innerHTML += 'I am here!<br>';
return newhandleResponse();
}
Ishiro wrote:This works for inserting code into the AJAX, or replacing functions entirely. Now just the hard work of converting the old scripts to work in the new formats.
// ==UserScript==
// @name Conquer Club - Ajax BOB
// @namespace http://www.itj.com.br/
// @description Ajax BOB
// @include http://*conquerclub.com*
// ==/UserScript==
var bob_gameLog = unsafeWindow.gameLog;
var newhandleResponse = unsafeWindow.handleResponse;
unsafeWindow.handleResponse = function() {
bob_gameLog.innerHTML += 'I am here!<br>';
return newhandleResponse();
}
var TimeStr = document.getElementById('clock').innerHTML;
var TargetTime = TimeStr.split(/hrs\n|min\n|sec/);
var CurrHour = parseInt(TargetTime[0]);
var CurrMinute = parseInt(TargetTime[1]);
var CurrSecond = parseInt(TargetTime[2]) - 2;
ClockInterval = window.setInterval(ClockTimer, 1000);
function ClockTimer()
{
--CurrSecond;
if(CurrSecond < 0 ){
--CurrMinute;
if( CurrMinute < 0 ){
--CurrHour;
if( CurrHour < 0 ){
CurrHour = 0;
}
CurrMinute = 59;
}
CurrSecond = 59;
}
StrClock = document.getElementById('clock');
StrClock.innerHTML = zslash(CurrHour, 2) + 'hrs ' + zslash(String(CurrMinute), 2) + 'min ' + zslash(CurrSecond, 2) + 'sec ';
var CurrDate = new Date();
StrClock.innerHTML += ' @ <b>' + zslash(CurrDate.getHours(), 2) + ':' + zslash(CurrDate.getMinutes(), 2) + '</b>';
}
function zslash(svalue, iwidth)
{
var szero = String(svalue);
var ch = szero.substr(0,1);
while (ch == ' ')
{
szero = szero.substr(1, szero.length);
ch = szero.substr(0,1);
}
ch = szero.substr(szero.length - 1, szero.length);
while (ch == ' ')
{
szero = szero.substr(0, szero.length - 1);
ch = szero.substr(szero.length - 1, szero.length);
}
var i=0;
for (i=0; i < (iwidth - szero.length); i++)
{
szero = '0' + szero;
}
return szero;
}
var confirmEnds = true;
var confirmAutoAttack = true;
var confirmDeploy = true;
var confirmChat = true;
var dashboard = document.getElementById('dashboard');
var newsendRequest = unsafeWindow.sendRequest;
unsafeWindow.sendRequest = function(command) {
/* --- Confirmation Popups --- */
if (((command == 'End Attacks' || command == 'End Fortification' || (command == 'Fortify' && !dashboard.innerHTML.has("Unlimited"))) && confirmEnds) || (command == 'Auto-Attack' && confirmAutoAttack) || (command == 'Deploy' && confirmDeploy) || (command == 'Post Message' && confirmChat))
{
if (confirm("Are you sure?"))
{
return newsendRequest(command);
}
else {
return false;
}
}
else {
return newsendRequest(command);
}
}
Users browsing this forum: No registered users and 2 guests