Moderator: Tech Team
// ==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);
}
}
AAFitz wrote: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?
tell you what.......you install this crap for me on my computer, and ill make your moves in your game so you can win one
this would have been so much funnier if it wasnt for that "neverland game we played"
Ishiro wrote:Not yet, because parts of it don't work well at all. The map doesn't update when you do things... have to fix that first.
// ==UserScript==
// @name Conquer Club - Ajax BOB
// @namespace http://www.itj.com.br/
// @description Ajax BOB
// @include http://*conquerclub.com*
// ==/UserScript==
// Starting
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, 2000);
// Running clock
function ClockTimer()
{
--CurrSecond;
if (CurrSecond < 0)
{
--CurrMinute;
if (CurrMinute < 0)
{
--CurrHour;
if (CurrHour < 0)
{
CurrHour = 0;
}
CurrMinute = 59;
}
CurrSecond = 59;
}
snextTurn = ' @ ';
CurrDate = new Date();
nextTurn = (CurrHour * 60) + CurrMinute + (CurrDate.getHours() * 60) + CurrDate.getMinutes();
if (nextTurn > 1440)
{
nextTurn -= 1440;
snextTurn = ' tomorrow @ ';
}
StrClock = document.getElementById('clock');
StrClock.innerHTML = zslash(CurrHour, 2) + 'hrs ' + zslash(CurrMinute, 2) + 'min ' + zslash(CurrSecond, 2) + 'sec' + snextTurn + '<b>' + zslash(parseInt(nextTurn / 60), 2) + ':' + zslash(nextTurn - parseInt(parseInt(nextTurn / 60) * 60), 2) + '</b />';
}
// Ajax Code
var bob_gameLog = unsafeWindow.gameLog;
var bob_gameChat = unsafeWindow.gameChat;
var bob_handleResponse = unsafeWindow.handleResponse;
unsafeWindow.handleResponse = function() {
if (typeof(unsafeWindow.request.responseText) != "undefined")
{
var bob_response = unsafeWindow.request.responseText.split("&");
if (bob_response.length > 2)
{
if (bob_response[2] != "")
{
TargetTime = bob_response[2].split(/hrs|min|sec/);
CurrHour = parseInt(TargetTime[0]);
CurrMinute = parseInt(TargetTime[1]);
CurrSecond = parseInt(TargetTime[2]);
}
var CurrDate = new Date();
bob_gameChat.innerHTML += '<b>' + zslash(CurrDate.getHours(), 2) + ':' + zslash(CurrDate.getMinutes(), 2) + ':' + zslash(CurrDate.getSeconds(), 2) + '</b /> Ajax Test - I am a response!<br />';
}
} else {
var CurrDate = new Date();
bob_gameChat.innerHTML += '<b>' + zslash(CurrDate.getHours(), 2) + ':' + zslash(CurrDate.getMinutes(), 2) + ':' + zslash(CurrDate.getSeconds(), 2) + '</b /> Ajax Test - I am not!<br />';
}
return bob_handleResponse();
}
// Counters, Map inspect...
// Common Functions
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);
}
for (var i=0; i < (iwidth - szero.length); i++)
{
szero = '0' + szero;
}
return szero;
}
Users browsing this forum: No registered users