Last active
August 30, 2016 19:05
-
-
Save rizenine/ee0c5f2a56050fbc01fa4ca65cd51aa7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name Custom TA Script | |
// @namespace http://tampermonkey.net/ | |
// @version 0.13 | |
// @description Making life easier on TA | |
// @author rizenine | |
// @match https://prodgame16.alliances.commandandconquer.com/346/index.aspx | |
// @namespace https://prodgame*.alliances.commandandconquer.com/*/index.aspx* | |
// @include https://prodgame*.alliances.commandandconquer.com/*/index.aspx* | |
// @grant none | |
// ==/UserScript== | |
(function() { | |
'use strict'; | |
function triggerAll(){ | |
console.log("#######################BEGIN###############################"); | |
var AllCities = ClientLib.Data.MainData.GetInstance().get_Cities().get_AllCities(); | |
var AllCitiesData = AllCities.d; | |
for (var CurrentCity in AllCitiesData) { | |
console.log("Processing city: " + AllCitiesData[CurrentCity].get_Name()); | |
console.log("Processing city: " + AllCitiesData[CurrentCity].CanRepairAllOffense()); | |
if(AllCitiesData[CurrentCity].CanRepairAllOffense()) { | |
AllCitiesData[CurrentCity].RepairAllOffense(); | |
console.log("Repaired offense."); | |
} else { | |
console.log("Nothing to repair on offense."); | |
} | |
if(AllCitiesData[CurrentCity].GetCollectableResourcePackageAmount() > 1) { | |
AllCitiesData[CurrentCity].CollectAllResources(); | |
console.log("Packages collected."); | |
} else { | |
console.log("Nothing to collect."); | |
} | |
if(AllCitiesData[CurrentCity].get_IsDamaged()) { | |
AllCitiesData[CurrentCity].RepairAll(); | |
console.log("Repaired."); | |
} else { | |
console.log("Nothing to repair."); | |
} | |
window.cityTestObj = AllCitiesData[CurrentCity]; // Set for testing | |
console.log("-----------------------------------------------"); | |
} | |
console.log("##########################END##############################"); | |
setTimeout(triggerAll, Math.random() * 60 * 3000); | |
} | |
function waitForGame() { | |
try | |
{ | |
if (typeof qx != 'undefined' && typeof qx.core != 'undfined' && typeof qx.core.Init != 'undefined') | |
{ | |
var app = qx.core.Init.getApplication(); | |
if (app.initDone == true) | |
{ | |
try | |
{ | |
setTimeout(triggerAll, 1000); | |
} | |
catch(e) | |
{ | |
console.log("Trigger initialization error:"); | |
console.log(e); | |
} | |
} | |
else | |
window.setTimeout(waitForGame, 1000); | |
} | |
else | |
{ | |
window.setTimeout(waitForGame, 1000); | |
} | |
} | |
catch (e) | |
{ | |
console.log("Trigger initialization error:"); | |
console.log(e); | |
} | |
} | |
window.setTimeout(waitForGame, 1000); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment