Storm8 Functions

Auto functions for all Storm8 games

  1. // ==UserScript==
  2. // @name Storm8 Functions
  3. // @namespace Green flamingo
  4. // @description Auto functions for all Storm8 games
  5. // @copyright 2014
  6. // @version 2.2
  7. // @include http://*.storm8.com/*
  8. // ==/UserScript==
  9.  
  10. var game = String(location).split('/')[2].split('.')[0];
  11. var homelink = "http://" + game + ".storm8.com/home.php";
  12. var hitlistlink = "http://" + game + ".storm8.com/hitlist.php";
  13. var hospitallink = "http://" + game + ".storm8.com/hospital.php";
  14. var banklink = "http://" + game + ".storm8.com/bank.php";
  15.  
  16. // GM variables
  17. var curVer = "2.2";
  18. var autobank = GM_getValue("autobank", false);
  19. var autoheal = GM_getValue("autoHeal", false);
  20. var healthLimit = parseInt(GM_getValue("healthLimit", 60));
  21. var healthTimer = GM_getValue("healthTimer", "5-10");
  22. var ahd = parseInt(GM_getValue("ahd", randomFromInterval(5000, 10000)));
  23. var healing = GM_getValue("healing", false);
  24. var bounty = GM_getValue("bounty", false);
  25. var bountyLevel = GM_getValue("bountyLevel", 150);
  26. var bountyAmmo = GM_getValue("bountyAmmo", 1);
  27. var autosancNum = GM_getValue("autosancNum", 0);
  28. var resanc = GM_getValue("resanc", false);
  29. if (game == "wwar") {
  30. var sancCountry = GM_getValue("sancCountry", 1);
  31. }
  32. var autoAttack = GM_getValue("autoAttack", false);
  33. var PUID = GM_SuperValue.get("PUID", "");
  34. var cleanWall = GM_getValue('cleanWall', false);
  35. var messageBox = GM_getValue('messageBox', true);
  36. var missionId = GM_getValue('missionId', "");
  37. var amount = parseInt(GM_getValue("amount", 2500000));
  38. var showorhide = GM_getValue("showorhide", "block");
  39. var puidArray = GM_SuperValue.get('puidArray', []);
  40. var puidSelected = GM_getValue('puidSelected', null);
  41. var killAfterLose = GM_getValue('killAfterLose', false);
  42. var csearch = GM_getValue("csearch", "");
  43. var dosearch = GM_getValue("dosearch", false);
  44. var bountykill = GM_getValue("bountykill", false);
  45. var missiont = GM_getValue('missiont', 'best');
  46. var missiono = GM_getValue('missiono', 'off');
  47. var mcat = parseInt(GM_getValue('mcat', '1'));
  48. var mnum = parseInt(GM_getValue('mnum', '1'));
  49. var missionl = GM_getValue('mission' + game, 0);
  50. var mscat = 1;
  51. var ransanc = GM_getValue('ransanc',false);
  52. var ransancnum = GM_getValue('ransancnum',0);
  53. var ransancmeth = GM_getValue('ransancmeth','fight');
  54. var hideorshow = GM_getValue("hideorshow", "none");
  55. var page = String(location).split('/')[3].split('.php')[0];
  56. var need2heal = GM_getValue('need2heal', 0);
  57.  
  58. if (page == "home") {
  59. getTxtFile("https://dl.dropboxusercontent.com/s/7gg9luhmklkfo01/version.txt?token_hash=AAHC1-m6s7X8ILr-zXrsMh3h2cUIWh2CClRZlqGXdYigbA&dl=1", true);
  60. }
  61.  
  62. //Super-quick Make it bank
  63. if (page == "hospital") {
  64. var htmlsearch = document.getElementsByTagName('body')[0].innerHTML;
  65. if (htmlsearch.indexOf('to pay for that.') != -1) {
  66. GM_setValue('need2bank', true);
  67. document.location = banklink;
  68. return;
  69. }
  70. }
  71. if (GM_getValue('need2bank', false)) {
  72. var cash = getCash();
  73. if (cash > 0) postwith("bank.php", ['depositAmount', '1000000000', 'action', 'Deposit']);
  74. else alert('You are broke!');
  75. GM_setValue('need2bank', false);
  76. GM_setValue('justbank', true);
  77. return;
  78. }
  79. if (GM_getValue('justbank', false)) {
  80. GM_setValue('justbank', false);
  81. setTimeout(function(){document.location = hospitallink;}, 500);
  82. return;
  83. }
  84. if (page == "help") {
  85. var d = confirm('Press OK to clear all settings.');
  86. if (d) {
  87. var variablesdel = GM_listValues();
  88. for (var fuckit = 0;fuckit<variablesdel.length;fuckit++) {
  89. GM_deleteValue(variablesdel[fuckit]);
  90. }
  91. document.location = 'http://'+game+'.storm8.com/home.php';
  92. }
  93. }
  94. if (hideorshow == "none") GM_setValue('showorhide','block');
  95. // Menu builder
  96. var bchecked = "";
  97. var ichecked = "";
  98. var dchecked = "";
  99. var hchecked = "";
  100. var schecked = "";
  101. var zchecked = "";
  102. var achecked = "";
  103. var cchecked = "";
  104. var rchecked = "";
  105. var mchecked = messageBox ? " checked" : "";
  106. var ralchecked = "";
  107. var bkchecked = "";
  108. var mochecked = "";
  109. var ransancchecked = "";
  110. if (autobank) bchecked = " checked";
  111. if (autoheal) hchecked = " checked";
  112. if (bounty) schecked = " checked";
  113. if (autoAttack) achecked = " checked";
  114. if (cleanWall) cchecked = " checked";
  115. if (killAfterLose) ralchecked = " checked";
  116. if (dosearch) zchecked = " checked";
  117. if (bountykill) bkchecked = " checked";
  118. if (missiono == "on") mochecked = " checked";
  119. if (ransanc) ransancchecked = " checked";
  120. var menu = document.createElement('div');
  121. menu.setAttribute("id", "s8fixermenu");
  122. menu.innerHTML = "\
  123. <input type=\"checkbox\" id=\"autobank\" " + bchecked + " /> Bank \
  124. <input type=\"checkbox\" id=\"autoAttack\" " + achecked + " /> Attack <input type=\"checkbox\" id=\"ral\" " + ralchecked + " />W/O</BR> \
  125. <input type=\"checkbox\" id=\"autoheal\" " + hchecked + " /> Heal <input type=\"text\" style=\"border: 1px solid green; width: 2em; color: #00ff00; background: black; text-align: center;\" id=\"healthlimit\" value=\"" + healthLimit + "\" /> <input type=\"text\" style=\"border: 1px solid green; width: 4em; color: #00ff00; background: black; text-align: center;\" id=\"healthtimer\" value=\"" + healthTimer + "\" /> </BR> \
  126. <input type=\"checkbox\" id=\"bounty\" " + schecked + " /> Kill <input type=\"text\" style=\"border: 1px solid green; width: 2em; color: #00ff00; background: black; text-align: center;\" id=\"bountylevel\" value=\"" + bountyLevel + "\" /> <input type=\"text\" style=\"border: 1px solid green; width: 2em; color: #00ff00; background: black; text-align: center;\" id=\"bountyammo\" value=\"" + bountyAmmo + "\" /> \
  127. <span id=\"ntk\">NoKill <select style=\"border: 1px solid green; background: black; color: #00ff00; text-align: left;\" id=\"sancCountry\"> \
  128. <option value=\"1\">Germany</option> \
  129. <option value=\"2\">UK</option> \
  130. <option value=\"3\">USA</option> \
  131. <option value=\"4\">China</option> \
  132. <option value=\"5\">Russia</option> \
  133. </select> </span> <br>\
  134. <input type=\"checkbox\" id=\"cleanWall\" " + cchecked + " /> CleanWall \
  135. <input type=\"checkbox\" id=\"messageBox\" " + mchecked + " /> MessageBox <BR/> \
  136. Hitlist <input type=\"text\" style=\"border: 1px solid green; width: 2em; color: #00ff00; background: black; text-align: center;\" id=\"autosancNum\" value=\"" + autosancNum + "\" /> times for <input type=\"text\" style=\"border: 1px solid green; width: 5em; color: #00ff00; background: black; text-align: center;\" id=\"amount\" value=\"" + amount + "\" /> <input type=\"checkbox\" id=\"bk\" " + bkchecked + " /> K@B <br> \
  137. PUID <select style=\"border: 1px solid green; width: 23em; background: black; text-align: left; color: #00ff00;\" id=\"selectboxPUID\" /> </select><br><input type=\"button\" value=\"GET\" input id=\"btnGETPUID\" /> <INPUT type=\"button\" value=\"CLR\" input id=\"btnCLRPUID\" /> <INPUT type=\"button\" value=\"CLR ALL\" input id=\"btnCLRALL\" /> <INPUT type=\"button\" value=\"SET\" input id=\"btnSET\" /> <br>\
  138. <input type=\"checkbox\" id=\"ransanc\" " + ransancchecked + " /> RanSanc \
  139. <input type=\"text\" style=\"border: 1px solid green; width: 2em; color: #00ff00; background: black; text-align: center;\" id=\"ransancnum\" value=\"" + ransancnum + "\" /> \
  140. <select style=\"border: 1px solid green; background: black; color: #00ff00; text-align: left;\" id=\"ransancmeth\"> \
  141. <option value=\"fight\">Fight</option> \
  142. <option value=\"list\">List</option> \
  143. </select> \
  144. <INPUT type=\"button\" value=\"Income ROI\" input id=\"roido\" /> <br>\
  145. <input type=\"checkbox\" id=\"missiono\" " + mochecked + " /> Missions \
  146. <select style=\"border: 1px solid green; background: black; color: #00ff00; text-align: left;\" id=\"missiont\"> \
  147. <option value=\"best\">Best</option> \
  148. <option value=\"specific\">Specific</option> \
  149. </select> \
  150. <input type=\"text\" style=\"border: 1px solid green; width: 2em; color: #00ff00; background: black; text-align: center;\" id=\"mcat\" value=\"" + mcat + "\" />T#\
  151. <input type=\"text\" style=\"border: 1px solid green; width: 2em; color: #00ff00; background: black; text-align: center;\" id=\"mnum\" value=\"" + mnum + "\" />M#<br>\
  152. <input type=\"checkbox\" id=\"dosearch\" " + zchecked + " /> Search <input type=\"text\" style=\"border: 1px solid green; width: 8em; color: #00ff00; background: black; text-align: center;\" id=\"csearch\" value=\"" + csearch + "\" /> \
  153. <input type=\"button\" value=\"Hide\" id=\"menutog\" style=\"border: 1px solid red; background: blue; text-align: center;\" /> <input type=\"button\" value=\" ? \" id=\"faq\" style=\"border: 1px solid blue; background: red; text-align: center;\"/>";
  154. menu.style.padding = '10px';
  155. menu.style.display = showorhide;
  156. menu.style.position = 'fixed';
  157. menu.style.background = 'black';
  158. menu.style.top = '16%';
  159. menu.style.zIndex = '1001';
  160. menu.style.backgroundImage = "url('https://dl.dropboxusercontent.com/s/d18bcq32y4bcghk/rotten4pple.png?token_hash=AAG0lWdWvI1srfu5R9PsBwf44qhQbR3b4aIvsv3sA4RkQA&dl=1')";
  161. menu.style.backgroundRepeat = "no-repeat";
  162. menu.style.backgroundPosition = "top right";
  163. document.body.insertBefore(menu, document.body.firstChild);
  164. var displaytoggle = document.createElement('input');
  165. displaytoggle.setAttribute('id', 'hiddentog');
  166. displaytoggle.setAttribute('type', 'button');
  167. displaytoggle.setAttribute('value', '-->');
  168. displaytoggle.style.display = hideorshow;
  169. displaytoggle.style.padding = '10px';
  170. displaytoggle.style.position = 'fixed';
  171. displaytoggle.style.top = '33%';
  172. displaytoggle.style.background = 'green';
  173. displaytoggle.style.border = '1px solid yellow';
  174. displaytoggle.style.zIndex = '1001';
  175. document.body.insertBefore(displaytoggle, document.body.firstChild);
  176. if (game != "wwar") {
  177. var nke = document.getElementById("ntk");
  178. nke.parentNode.removeChild(nke);
  179. }
  180. setSelect('missiont', missiont);
  181. setSelect('ransancmeth',ransancmeth);
  182. if (game == "zl") {
  183. mcat = mcat + 4;
  184. mscat = mscat + 4;
  185. }
  186. if (game == "vl") {
  187. mcat = mcat + 10;
  188. mscat = mscat + 10;
  189. }
  190. if (game == "zl" || game == "kl" || game == "rol") {
  191. document.getElementById('missiont').disabled = true;
  192. GM_setValue('missiont', 'specific');
  193. }
  194. var mtogbtn = document.getElementById('menutog');
  195. var htogbtn = document.getElementById('hiddentog');
  196. var faqbtn = document.getElementById('faq');
  197. mtogbtn.addEventListener('click', togglevisibility);
  198. htogbtn.addEventListener('click', togglevisibility);
  199. faqbtn.addEventListener('click', function() {
  200. getTxtFile("https://dl.dropboxusercontent.com/s/sf0tvy1csm3jpcf/scriptfaq.txt?token_hash=AAFBe2BjEG683BFHvtzUJJs4wOosCTbKrhchzt5B6SGp1g&dl=1", false)
  201. });
  202. if (game == "wwar") {
  203. setSelect('sancCountry', sancCountry);
  204. }
  205. var roiBtn = document.getElementById('roido');
  206. roiBtn.addEventListener('click', function() {
  207. GM_setValue('doingroi',true);
  208. document.location = 'http://'+game+'.storm8.com/investment.php';
  209. });
  210.  
  211. //Unhide names
  212. if (page == "home") setTimeout(unHideNames,1500);
  213. else unHideNames();
  214.  
  215. function checkOptions() {
  216. // autobanking
  217. if (document.getElementById('autobank').checked) GM_setValue("autobank", true);
  218. else GM_setValue("autobank", false);
  219. // auto healing
  220. if (document.getElementById('autoheal').checked) GM_setValue("autoHeal", true);
  221. else GM_setValue("autoHeal", false);
  222. var oldhealth = healthLimit;
  223. var newhealth = document.getElementById('healthlimit').value;
  224. if (oldhealth != newhealth) {
  225. healthLimit = newhealth;
  226. GM_setValue("healthLimit", parseInt(healthLimit));
  227. }
  228. //search
  229. if (document.getElementById('dosearch').checked) GM_setValue("dosearch", true);
  230. else GM_setValue("dosearch", false);
  231. var strSearch = document.getElementById('csearch').value;
  232. GM_setValue("csearch", strSearch);
  233. //health time
  234. var oldtimer = healthTimer;
  235. var newtimer = document.getElementById('healthtimer').value;
  236. if (oldtimer != newtimer) {
  237. healthTimer = newtimer;
  238. GM_setValue("healthTimer", newtimer);
  239. healmeth();
  240. }
  241. // autokill bounty
  242. if (document.getElementById('bounty').checked) GM_setValue("bounty", true);
  243. else GM_setValue("bounty", false);
  244. var oldsanc = bountyLevel;
  245. var newsanc = document.getElementById('bountylevel').value;
  246. if (oldsanc != newsanc) {
  247. bountyLevel = newsanc;
  248. GM_setValue("bountyLevel", parseInt(bountyLevel));
  249. }
  250. var oldammo = bountyAmmo;
  251. var newammo = document.getElementById('bountyammo').value;
  252. if (oldammo != newammo) {
  253. bountyAmmo = newammo;
  254. GM_setValue("bountyAmmo", parseInt(bountyAmmo));
  255. }
  256. // sancCountry
  257. if (game == "wwar") {
  258. var oldcountry = sancCountry;
  259. var newcountry = document.getElementById('sancCountry').value;
  260. if (oldcountry != newcountry) {
  261. sancCountry = newcountry;
  262. GM_setValue("sancCountry", sancCountry);
  263. }
  264. }
  265. // autosanc
  266. var oldNum = autosancNum;
  267. var newNum = document.getElementById('autosancNum').value;
  268. if (oldNum != newNum) {
  269. autosancNum = newNum;
  270. GM_setValue("autosancNum", parseInt(autosancNum));
  271. }
  272. var oldbounty = amount;
  273. var newbounty = document.getElementById('amount').value;
  274. if (oldbounty != newbounty) {
  275. amount = newbounty;
  276. GM_setValue("amount", parseInt(amount));
  277. }
  278. // auto re-attack
  279. if (document.getElementById('autoAttack').checked) GM_setValue("autoAttack", true);
  280. else GM_setValue("autoAttack", false);
  281. //ral
  282. if (document.getElementById('ral').checked) GM_setValue("killAfterLose", true);
  283. else GM_setValue("killAfterLose", false);
  284. //bk
  285. if (document.getElementById('bk').checked) GM_setValue("bountykill", true);
  286. else GM_setValue("bountykill", false);
  287. // auto clean-wall
  288. if (document.getElementById('cleanWall').checked) GM_setValue("cleanWall", true);
  289. else GM_setValue("cleanWall", false);
  290. // show message-box?
  291. GM_setValue("messageBox", document.getElementById('messageBox').checked);
  292. if (document.getElementById('missiono').checked) {
  293. GM_setValue("missiono", "on");
  294. } else GM_setValue("missiono", "off");
  295. var oldcat = mcat;
  296. var newcat = document.getElementById('mcat').value;
  297. if (oldcat != newcat) {
  298. GM_setValue("mcat", parseInt(newcat));
  299. }
  300. var oldnum = mnum;
  301. var newnum = document.getElementById('mnum').value;
  302. if (oldnum != newnum) {
  303. GM_setValue("mnum", parseInt(newnum));
  304. }
  305. var oldmt = missiont;
  306. var newmt = document.getElementById('missiont').value;
  307. if (oldmt != newmt) GM_setValue("missiont", newmt);
  308. if (document.getElementById('ransanc').checked) {
  309. GM_setValue("ransanc", true);
  310. } else GM_setValue("ransanc", false);
  311. var oldrn = ransancnum;
  312. var newrn = parseInt(document.getElementById('ransancnum').value);
  313. if (oldrn != newrn) GM_setValue("ransancnum",newrn);
  314. var oldrm = ransancmeth;
  315. var newrm = document.getElementById('ransancmeth').value;
  316. if (oldrm != newrm) GM_setValue("ransancmeth", newrm);
  317. }
  318.  
  319. // AutoHeal
  320. if (autoheal) {
  321. var healthCurrent = parseInt(document.getElementById('healthCurrent').innerHTML);
  322. var healthMax = parseInt(document.getElementById('healthMax').innerHTML);
  323. if (ahd > 0) setTimeout(function(){document.location = hospitallink;}, ahd);
  324. if (healthCurrent < healthLimit && healthCurrent < healthMax) {
  325. if (page != "hospital") document.location = hospitallink;
  326. else setTimeout(function(){document.location = document.getElementsByClassName('tac healBtn')[0].getElementsByTagName('a')[0].href;},randomFromInterval(1000,2000));
  327. }
  328. }
  329.  
  330. // CleanWall
  331. if (cleanWall) {
  332. var postComment = document.getElementsByClassName('btnMed btnPostComment');
  333. if (page == "profile" && postComment != null && postComment.length > 0) {
  334. var messages = document.getElementsByClassName('newsFeedItemMsg');
  335. if (messages.length > 0) {
  336. var lnks = messages[0].getElementsByTagName("a");
  337. var mPuid = getQueryVariable(lnks[0].href, 'puid');
  338. if (PUID == mPuid || (PUID == '' && mPuid == null)) {
  339. cleanWall = false;
  340. GM_setValue('cleanWall', false);
  341. } else {
  342. if (lnks.length > 1) document.location = lnks[1];
  343. else document.location = lnks[0];
  344. }
  345. } else {
  346. cleanWall = false;
  347. GM_setValue('cleanWall', false);
  348. }
  349. }
  350. }
  351.  
  352. var arrayPuid = puidArray;
  353. var selBox = document.getElementById('selectboxPUID');
  354. var getBtn = document.getElementById('btnGETPUID');
  355. var clrBtn = document.getElementById('btnCLRPUID');
  356. var clrAll = document.getElementById('btnCLRALL');
  357. var btnSet = document.getElementById('btnSET');
  358. var searchBox = document.getElementById('csearch');
  359. selBox.addEventListener('change', function() {
  360. checkOpts(arrayPuid);
  361. }, true);
  362. getBtn.addEventListener('click', function() {
  363. getPuid(false);
  364. }, true);
  365. clrBtn.addEventListener('click', function() {
  366. clrPuid(false);
  367. }, true);
  368. clrAll.addEventListener('click', function() {
  369. clrPuid(true);
  370. }, true);
  371. btnSet.addEventListener('click', function() {
  372. getPuid(true);
  373. }, true);
  374. searchBox.addEventListener('change', function() {
  375. GM_setValue('csearch', searchBox.value);
  376. if (searchBox.value == "") btnSet.disabled = true;
  377. else btnSet.disabled = false;
  378. }, true);
  379. getBtn.disabled = true;
  380. clrBtn.disabled = true;
  381. clrAll.disabled = true;
  382. btnSet.disabled = true;
  383. if (page == "profile") getBtn.disabled = false;
  384. if (searchBox.value != "" && GM_getValue('puidSet', '') != searchBox.value) btnSet.disabled = false;
  385. if (arrayPuid != "") {
  386. clrBtn.disabled = false;
  387. clrAll.disabled = false;
  388. createOpts(arrayPuid, false);
  389. setSelect('selectboxPUID', puidSelected);
  390. if (page == "profile") {
  391. checkOpts(arrayPuid);
  392. }
  393. }
  394.  
  395. if (GM_getValue('doingroi',false) && page == "investment") doroistuff();
  396.  
  397. if (page == "profile" && ransanc && ransancnum > 0) {
  398. if (ransancmeth == "fight" || (ransancmeth == "list" && GM_getValue('ransancrdy',false))) {
  399. GM_setValue('ransancrdy',false);
  400. var buttons = document.getElementsByClassName('buttonHolder')[0].getElementsByTagName('input');
  401. click(buttons[buttons.length - 1]);
  402. }
  403. if (ransancmeth == "list" && GM_getValue('ransancprof',false)) {
  404. var links = document.getElementsByTagName('a');
  405. if (links) {
  406. var j = 0;
  407. for (var i=0; i<links.length; i++) {
  408. var plink = links[i].href.indexOf('puid');
  409. var chance = randomFromInterval(0,5);
  410. var newsitem = document.getElementsByClassName('newsFeedItem');
  411. if (plink != -1) {
  412. j++;
  413. if (chance == 5) {
  414. GM_setValue('ransancprof',false);
  415. GM_setValue('ransancrdy',true);
  416. click(links[i]);
  417. }
  418. }
  419. if (j == newsitem.length) {
  420. GM_setValue('ransancprof',false);
  421. document.location = "http://"+game+".storm8.com/hitlist.php";
  422. }
  423. }
  424. } else {
  425. GM_setValue('ransancprof',false);
  426. document.location = "http://"+game+".storm8.com/hitlist.php";
  427. }
  428. }
  429. if (ransancmeth == "list" && GM_getValue('ransanchit',false)) {
  430. var comtab = document.getElementById('sectionTabs').getElementsByTagName('a')[1].href;
  431. GM_setValue('ransanchit',false);
  432. GM_setValue('ransancprof',true);
  433. document.location = comtab;
  434. }
  435. }
  436.  
  437. if (page == "bounty" && ransanc && ransancnum > 0) {
  438. var failed = document.getElementsByClassName('messageBoxFail')[0];
  439. if (failed) {
  440. var failr = failed.innerHTML;
  441. if (failr.indexOf('too many people') != -1) {
  442. GM_setValue('ransancoff',true);
  443. document.location = "http://"+game+".storm8.com/home.php";
  444. } else {
  445. if (ransancmeth == "fight") document.location = "http://"+game+".storm8.com/fight.php";
  446. if (ransancmeth == "list") document.location = "http://"+game+".storm8.com/hitlist.php";
  447. }
  448. }
  449. var form = document.getElementById('bountyForm');
  450. if (game == "im" || game == "rl") {
  451. var minpay = parseInt(form.getElementsByTagName('span')[0].innerHTML.replace(/,/g,'').replace(/[$]/g,''));
  452. }
  453. else var minpay = parseInt(form.getElementsByTagName('span')[0].childNodes[1].nodeValue.replace(/,/g,''));
  454. form.getElementsByTagName('input')[0].value = minpay;
  455. if (!failed) {
  456. click_sanc();
  457. GM_setValue('ransancgo',true);
  458. }
  459. }
  460.  
  461. if (page == "hitlist" && ransanc && GM_getValue('ransancgo',false)) {
  462. GM_setValue('ransancnum',ransancnum-1);
  463. GM_setValue('ransancgo',false);
  464. if (ransancmeth == "fight") document.location = "http://"+game+".storm8.com/fight.php";
  465. if (ransancmeth == "list") document.location = "http://"+game+".storm8.com/hitlist.php";
  466. }
  467.  
  468. if (page == "home" && GM_getValue('ransancoff',false)) {
  469. GM_setValue('ransancoff',false);
  470. document.getElementById('ransanc').checked = false;
  471. }
  472.  
  473. if (((page == "fight" && ransancmeth == "fight") || (page == "hitlist" && ransancmeth == "list")) && ransanc && ransancnum > 0) {
  474. var links = document.getElementsByTagName('a');
  475. if (links) {
  476. var j = 0;
  477. for (var i=0; i<links.length; i++) {
  478. var plink = links[i].href.indexOf('puid');
  479. var chance = randomFromInterval(0,5);
  480. var fighttable = document.getElementsByClassName('fightTable');
  481. if (plink != -1) {
  482. j++;
  483. if (chance == 5) {
  484. if (ransancmeth == "list") GM_setValue('ransanchit',true);
  485. click(links[i]);
  486. }
  487. }
  488. if (j > 9) location.reload();
  489. if (j == fighttable.length) setTimeout(function(){location.reload();},randomFromInterval(1000,2500));
  490. }
  491. } else setTimeout(function(){location.reload();},randomFromInterval(1000,2500));
  492. }
  493.  
  494. if (page == "missions" && missiono == "on") {
  495. var energy = document.getElementById("energyCurrent").innerHTML;
  496. if (missionl == 708 || missionl == 4316) {
  497. var mt = document.getElementsByClassName('missionTable')[2];
  498. var energyneed = mt.getElementsByClassName("requiredEnergy")[0].innerHTML;
  499. if (energy == energyneed) {
  500. click(document.getElementsByClassName('actionButton')[2]);
  501. GM_setValue('mission' + game, 0);
  502. return;
  503. } else {
  504. var ut = randomFromInterval(600000, 900000);
  505. setTimeout(function(){location.reload();}, ut);
  506. return;
  507. }
  508. }
  509. if (missionl == 759 || missionl == 8810 || missionl == 617 || missionl == 738) {
  510. var mt = document.getElementsByClassName('missionTable')[3];
  511. var energyneed = mt.getElementsByClassName("requiredEnergy")[0].innerHTML;
  512. if (energy == energyneed) {
  513. click(document.getElementsByClassName('actionButton')[3]);
  514. GM_setValue('mission' + game, 0);
  515. return;
  516. } else {
  517. var ut = randomFromInterval(600000, 900000);
  518. setTimeout(function(){location.reload();}, ut);
  519. return;
  520. }
  521. }
  522. if (missionl == 829 || missionl == 102) {
  523. var mt = document.getElementsByClassName('missionTable')[5];
  524. var energyneed = mt.getElementsByClassName("requiredEnergy")[0].innerHTML;
  525. if (energy == energyneed) {
  526. click(document.getElementsByClassName('actionButton')[5]);
  527. GM_setValue('mission' + game, 0);
  528. return;
  529. } else {
  530. var ut = randomFromInterval(600000, 900000);
  531. setTimeout(function(){location.reload();}, ut);
  532. return;
  533. }
  534. }
  535. if (missionl == 9010 || missionl == 9310 || missionl == 4516) {
  536. var mt = document.getElementsByClassName('missionTable')[9];
  537. var energyneed = mt.getElementsByClassName("requiredEnergy")[0].innerHTML;
  538. if (energy == energyneed) {
  539. click(document.getElementsByClassName('actionButton')[9]);
  540. GM_setValue('mission' + game, 0);
  541. return;
  542. } else {
  543. var ut = randomFromInterval(600000, 900000);
  544. setTimeout(function(){location.reload();}, ut);
  545. return;
  546. }
  547. }
  548. if (missionl == 9510 || missionl == 153 || missionl == 1012 || missionl == 6914) {
  549. var mt = document.getElementsByClassName('missionTable')[7];
  550. var energyneed = mt.getElementsByClassName("requiredEnergy")[0].innerHTML;
  551. if (energy == energyneed) {
  552. click(document.getElementsByClassName('actionButton')[7]);
  553. GM_setValue('mission' + game, 0);
  554. return;
  555. } else {
  556. var ut = randomFromInterval(600000, 900000);
  557. setTimeout(function(){location.reload();}, ut);
  558. return;
  559. }
  560. }
  561. if (missionl == 486 || missionl == 6714 || missionl == 2616) {
  562. var mt = document.getElementsByClassName('missionTable')[4];
  563. var energyneed = mt.getElementsByClassName("requiredEnergy")[0].innerHTML;
  564. if (energy == energyneed) {
  565. click(document.getElementsByClassName('actionButton')[4]);
  566. GM_setValue('mission' + game, 0);
  567. return;
  568. } else {
  569. var ut = randomFromInterval(600000, 900000);
  570. setTimeout(function(){location.reload();}, ut);
  571. return;
  572. }
  573. }
  574. if (missionl == 768949) {
  575. var mt = document.getElementsByClassName('missionTable')[11];
  576. var energyneed = mt.getElementsByClassName("requiredEnergy")[0].innerHTML;
  577. if (energy == energyneed) {
  578. click(document.getElementsByClassName('actionButton')[11]);
  579. GM_setValue('mission' + game, 0);
  580. return;
  581. } else {
  582. var ut = randomFromInterval(600000, 900000);
  583. setTimeout(function(){location.reload();}, ut);
  584. return;
  585. }
  586. }
  587. if (missionl == 889) {
  588. var mt = document.getElementsByClassName('missionTable')[0];
  589. var energyneed = mt.getElementsByClassName("requiredEnergy")[0].innerHTML;
  590. if (energy == energyneed) {
  591. click(document.getElementsByClassName('actionButton')[0]);
  592. GM_setValue('mission' + game, 0);
  593. return;
  594. } else {
  595. var ut = randomFromInterval(600000, 900000);
  596. setTimeout(function(){location.reload();}, ut);
  597. return;
  598. }
  599. }
  600. if (missionl == 1714) {
  601. var mt = document.getElementsByClassName('missionTable')[8];
  602. var energyneed = mt.getElementsByClassName("requiredEnergy")[0].innerHTML;
  603. if (energy == energyneed) {
  604. click(document.getElementsByClassName('actionButton')[8]);
  605. GM_setValue('mission' + game, 0);
  606. return;
  607. } else {
  608. var ut = randomFromInterval(600000, 900000);
  609. setTimeout(function(){location.reload();}, ut);
  610. return;
  611. }
  612. }
  613. var mission = document.getElementsByClassName("boxedItem");
  614. for (var i=0;i<mission.length;i++) {
  615. var fail = document.getElementsByClassName("fail").length;
  616. var htmldump = document.getElementsByTagName('body')[0].innerHTML;
  617. if (fail && (htmldump.indexOf('to complete the mission') != -1 || htmldump.indexOf('Buy the cars/parts for'))) {
  618. var buyunits = document.getElementsByClassName('btnMed btnDoAgain')[0];
  619. if (buyunits) {
  620. click(buyunits);
  621. return;
  622. }
  623. if (!buyunits) {
  624. var cat = String(location).split('cat=')[1].split('&')[0];
  625. var job = String(location).split('jid=')[1].split('&')[0];
  626. if (job == "16" && cat == "3" && game == "wwar") {
  627. click(document.getElementsByClassName('actionButton')[0]);
  628. return;
  629. }
  630. if (job == "20" && cat == "4" && game == "wwar") {
  631. click(document.getElementsByClassName('actionButton')[2]);
  632. return;
  633. }
  634. if (job == "104" && cat == "5" && game == "wwar") {
  635. click(document.getElementsByClassName('actionButton')[1]);
  636. return;
  637. }
  638. if (job == "70" && cat == "8" && game == "wwar") {
  639. document.location = 'http://wwar.storm8.com/missions.php?cat=6';
  640. GM_setValue('mission' + game, 708);
  641. return;
  642. }
  643. if (job == "75" && cat == "9" && game == "wwar") {
  644. document.location = 'http://wwar.storm8.com/missions.php?cat=7';
  645. GM_setValue('mission' + game, 759);
  646. return;
  647. }
  648. if (job == "82" && cat == "9" && game == "wwar") {
  649. document.location = 'http://wwar.storm8.com/missions.php?cat=6';
  650. GM_setValue('mission' + game, 829);
  651. return;
  652. }
  653. if (job == "88" && cat == "10" && game == "wwar") {
  654. document.location = 'http://wwar.storm8.com/missions.php?cat=8';
  655. GM_setValue('mission' + game, 8810);
  656. return;
  657. }
  658. if (job == "90" && cat == "10" && game == "wwar") {
  659. document.location = 'http://wwar.storm8.com/missions.php?cat=8';
  660. GM_setValue('mission' + game, 9010);
  661. return;
  662. }
  663. if (job == "93" && cat == "10" && game == "wwar") {
  664. document.location = 'http://wwar.storm8.com/missions.php?cat=9';
  665. GM_setValue('mission' + game, 9310);
  666. return;
  667. }
  668. if (job == "95" && cat == "10" && game == "wwar") {
  669. document.location = 'http://wwar.storm8.com/missions.php?cat=6';
  670. GM_setValue('mission' + game, 9510);
  671. return;
  672. }
  673. if (job == "10" && cat == "2" && game == "im") {
  674. document.location = 'http://im.storm8.com/missions.php?cat=1';
  675. GM_setValue('mission' + game, 102);
  676. return;
  677. }
  678. if (job == "13" && cat == "2" && game == "im") {
  679. click(document.getElementsByClassName('actionButton')[3]);
  680. return;
  681. }
  682. if (job == "15" && cat == "3" && game == "im") {
  683. document.location = 'http://im.storm8.com/missions.php?cat=2';
  684. GM_setValue('mission' + game, 153);
  685. return;
  686. }
  687. if (job == "48" && cat == "6" && game == "im") {
  688. document.location = 'http://im.storm8.com/missions.php?cat=5';
  689. GM_setValue('mission' + game, 486);
  690. return;
  691. }
  692. if (job == "61" && cat == "7" && game == "im") {
  693. document.location = 'http://im.storm8.com/missions.php?cat=6';
  694. GM_setValue('mission' + game, 617);
  695. return;
  696. }
  697. if (job == "73" && cat == "8" && game == "im") {
  698. document.location = 'http://im.storm8.com/missions.php?cat=7';
  699. GM_setValue('mission' + game, 738);
  700. return;
  701. }
  702. if (((job == "76" && cat == "8") || (job == "94" && cat == "9")) && game == "im") {
  703. document.location = 'http://im.storm8.com/missions.php?cat=7';
  704. GM_setValue('mission' + game, 768949);
  705. return;
  706. }
  707. if (job == "88" && cat == "9" && game == "im") {
  708. document.location = 'http://im.storm8.com/missions.php?cat=4';
  709. GM_setValue('mission' + game, 889);
  710. return;
  711. }
  712. if (job == "61" && cat == "11" && game == "vl") {
  713. click(document.getElementsByClassName('actionButton')[2]);
  714. return;
  715. }
  716. if (job == "6" && cat == "11" && game == "vl") {
  717. click(document.getElementsByClassName('actionButton')[3]);
  718. return;
  719. }
  720. if (job == "10" && cat == "12" && game == "vl") {
  721. document.location = 'http://vl.storm8.com/missions.php?cat=11';
  722. GM_setValue('mission' + game, 1012);
  723. return;
  724. }
  725. if (job == "11" && cat == "12" && game == "vl") {
  726. click(document.getElementsByClassName('actionButton')[0]);
  727. return;
  728. }
  729. if (job == "13" && cat == "13" && game == "vl") {
  730. click(document.getElementsByClassName('actionButton')[1]);
  731. return;
  732. }
  733. if (job == "67" && cat == "14" && game == "vl") {
  734. document.location = 'http://vl.storm8.com/missions.php?cat=13';
  735. GM_setValue('mission' + game, 6714);
  736. return;
  737. }
  738. if (job == "69" && cat == "14" && game == "vl") {
  739. document.location = 'http://vl.storm8.com/missions.php?cat=13';
  740. GM_setValue('mission' + game, 6914);
  741. return;
  742. }
  743. if (job == "17" && cat == "14" && game == "vl") {
  744. document.location = 'http://vl.storm8.com/missions.php?cat=13';
  745. GM_setValue('mission' + game, 1714);
  746. return;
  747. }
  748. if (job == "71" && cat == "14" && game == "vl") {
  749. click(document.getElementsByClassName('actionButton')[7]);
  750. return;
  751. }
  752. if (job == "43" && cat == "16" && game == "vl") {
  753. document.location = 'http://vl.storm8.com/missions.php?cat=14';
  754. GM_setValue('mission' + game, 4316);
  755. return;
  756. }
  757. if (job == "26" && cat == "16" && game == "vl") {
  758. document.location = 'http://vl.storm8.com/missions.php?cat=15';
  759. GM_setValue('mission' + game, 2616);
  760. return;
  761. }
  762. if (job == "45" && cat == "16" && game == "vl") {
  763. document.location = 'http://vl.storm8.com/missions.php?cat=15';
  764. GM_setValue('mission' + game, 4516);
  765. return;
  766. }
  767. if (job == "92" && cat == "17" && game == "vl") {
  768. click(document.getElementsByClassName('actionButton')[4]);
  769. return;
  770. }
  771. if (job == "114" && cat == "19" && game == "vl") {
  772. click(document.getElementsByClassName('actionButton')[4]);
  773. return;
  774. } else {
  775. if (parseInt(job) > 0 && parseInt(cat) > 0 && htmldump.indexOf('Refill') == -1) {
  776. alert('You are missing a loot item and it has not been coded to go collect it automatically.');
  777. return;
  778. } else {
  779. var ut = randomFromInterval(600000, 900000);
  780. setTimeout(function(){document.location='http://'+game+'.storm8.com/missions.php?cat='+cat;}, ut);
  781. return;
  782. }
  783. }
  784. }
  785. }
  786. if ((String(location).indexOf('cat=') == -1 && String(location).indexOf('jid=') == -1) || (String(location).indexOf('buyMissingItems') != -1 && String(location).indexOf('cat=') == -1) || htmldump.indexOf('mastery for this category') != -1) {
  787. var tab = document.getElementsByClassName('selected')[0];
  788. if (tab) {
  789. var ttab = tab.getElementsByTagName('a')[0];
  790. click(ttab);
  791. return;
  792. } else {
  793. document.location = 'http://'+game+'.storm8.com/missions.php?cat='+mscat;
  794. return;
  795. }
  796. }
  797. if ((String(location).indexOf('cat=') != -1 && parseInt(String(location).split('cat=')[1].split('&')[0]) > 25)) {
  798. document.location = 'http://'+game+'.storm8.com/missions.php?cat='+mscat;
  799. return;
  800. }
  801. var missionpart = mission[i].getElementsByClassName("missionTable")[0];
  802. var energyneed = missionpart.getElementsByClassName("requiredEnergy")[0].innerHTML;
  803. var doit = missionpart.getElementsByClassName("actionButton")[0];
  804. if (game != "zl" && game != "kl" && game != "rol") {
  805. var percentdone = missionpart.getElementsByClassName("masteryBarProgress")[0].innerHTML.split('%')[0];
  806. if (missiont == "best") {
  807. if (percentdone != "100" && parseInt(energy) >= parseInt(energyneed)) {
  808. click(doit);
  809. return;
  810. }
  811. if (percentdone != "100" && parseInt(energy) < parseInt(energyneed) && (i+1) == mission.length) {
  812. var cat = String(location).split('cat=')[1].split('&')[0];
  813. var ut = randomFromInterval(600000, 900000);
  814. setTimeout(function(){document.location='http://'+game+'.storm8.com/missions.php?cat='+cat;}, ut);
  815. return;
  816. }
  817. var temp = document.getElementsByTagName('body')[0].innerHTML;
  818. var count = temp.replace(/(<([^>]+)>)/ig,'');
  819. var count2 = count.match(/100%.Rank/g);
  820. if(count2) {
  821. if (count2.length == mission.length) switchmission();
  822. }
  823. }
  824. }
  825. if (missiont == "specific") {
  826. var cat = String(location).split('cat=')[1].split('&')[0];
  827. if (cat == mcat) {
  828. var f = mnum - 1;
  829. var missionpart = mission[f].getElementsByClassName("missionTable")[0];
  830. var energyneed = missionpart.getElementsByClassName("requiredEnergy")[0].innerHTML;
  831. var doit = missionpart.getElementsByClassName("actionButton")[0];
  832. if (parseInt(energy) >= parseInt(energyneed)) {
  833. click(doit);
  834. return;
  835. }
  836. if (parseInt(energy) < parseInt(energyneed)) {
  837. var ut = randomFromInterval(600000, 900000);
  838. setTimeout(function(){document.location='http://'+game+'.storm8.com/missions.php?cat='+cat;}, ut);
  839. return;
  840. }
  841. }
  842. }
  843. }
  844. }
  845.  
  846. function switchmission() {
  847. var cat = parseInt(String(location).split('cat=')[1].split('&')[0]);
  848. var nextcat = cat+1;
  849. document.location = 'http://'+game+'.storm8.com/missions.php?cat='+nextcat;
  850. }
  851.  
  852. //puidkill and search
  853. if (dosearch || puidArray != "" || bountykill) {
  854. var postComment = document.getElementsByClassName('btnMed btnPostComment');
  855. if (dosearch && page == "profile" && postComment != null && postComment.length > 0 && cleanwall == false) {
  856. var lnks = document.links;
  857. var wasfound = false;
  858. var mystring = csearch;
  859. for (i = 0; i < lnks.length; i++) {
  860. var tPuid = getQueryVariable(lnks[i].href, 'puid');
  861. if (tPuid == null) continue;
  862. var test = lnks[i].href;
  863. if (test.indexOf(csearch) >= 0) {
  864. wasfound = true;
  865. document.location = lnks[i];
  866. break;
  867. }
  868. if (puidArray != "") {
  869. for (j = 0; j < puidArray.length; ++j) {
  870. if (test.indexOf(csearch) >= 0 || parseInt(puidArray[j]) == tPuid) {
  871. wasfound = true;
  872. document.location = lnks[i];
  873. break;
  874. }
  875. }
  876. }
  877. }
  878. if (!wasfound) {
  879. for (j = lnks.length - 1; j >= 0; j--) {
  880. var test2 = lnks[j].innerHTML;
  881. if (test2.indexOf("Next") == 0) {
  882. document.location = lnks[j];
  883. break;
  884. }
  885. }
  886. }
  887. }
  888. if (page == "hitlist") {
  889. if (parseInt(document.getElementById('healthCurrent').innerHTML) <= 26) {
  890. GM_setValue('akheal', true);
  891. }
  892. if (!dosearch) {
  893. var wasfound = false;
  894. var ammo = parseInt(document.getElementById('staminaCurrent').innerHTML);
  895. if (!healing) {
  896. var alive = document.getElementsByClassName('doAgainTxt');
  897. if (alive.length > 0) {
  898. var next = alive[0].getElementsByTagName('input')[0];
  899. if (ammo >= bountyAmmo) click(next);
  900. return;
  901. }
  902. var sancList = document.getElementsByClassName('fightTable');
  903. for (i = 0; i < sancList.length; i++) {
  904. var fields = sancList[i].getElementsByTagName('td');
  905. if (game == "wwar" || game == "vl" || game == "zl" || game == "rl") {
  906. var name = fields[1].getElementsByTagName('a')[0].innerHTML;
  907. var tPuid = getQueryVariable(String(fields[1].getElementsByTagName('a')[0]), 'puid');
  908. for (j = 0; j < puidArray.length; ++j) {
  909. var PUID = parseInt(puidArray[j]);
  910. if (PUID == tPuid) {
  911. wasfound = true;
  912. }
  913. }
  914. if (bountykill && amount != 0) {
  915. if (game != "rl") {
  916. var cash = fields[3].getElementsByClassName('cash')[0].getElementsByTagName('span')[0].innerHTML.split('>')[1];
  917. if (cash == amount) wasfound = true;
  918. var cash2 = cash.replace(/\,/g, "");
  919. if (cash2.indexOf('K') != -1) {
  920. var cashK = cash2.split('K')[0] * 1000;
  921. if (cashK == amount) wasfound = true;
  922. }
  923. if (cash2.indexOf('M') != -1) {
  924. var cashM = cash2.split('M')[0] * 1000000;
  925. if (cashM == amount) wasfound = true;
  926. } else if (cash2 == amount) wasfound = true;
  927. } else {
  928. var cashD = fields[3].getElementsByClassName('cash')[0].getElementsByTagName('span')[0].innerHTML.split('$')[1];
  929. if (cashD == amount) wasfound = true;
  930. var cash3 = cashD.replace(/\,/g, "");
  931. if (cash3.indexOf('K') != -1) {
  932. var cashK = cash3.split('K')[0] * 1000;
  933. if (cashK == amount) wasfound = true;
  934. }
  935. if (cash3.indexOf('M') != -1) {
  936. var cashM = cash3.split('M')[0] * 1000000;
  937. if (cashM == amount) wasfound = true;
  938. } else if (cash3 == amount) wasfound = true;
  939. }
  940. }
  941. if (wasfound) {
  942. var AttackButton = fields[5].getElementsByTagName('a')[0];
  943. if (ammo >= bountyAmmo) click(AttackButton);
  944. break;
  945. }
  946. } else {
  947. var name = fields[0].getElementsByTagName('a')[0].innerHTML;
  948. var tPuid = getQueryVariable(String(fields[0].getElementsByTagName('a')[0]), 'puid');
  949. for (j = 0; j < puidArray.length; ++j) {
  950. var PUID = parseInt(puidArray[j]);
  951. if (PUID == tPuid) {
  952. wasfound = true;
  953. }
  954. }
  955. if (bountykill && amount != 0) {
  956. if (game != "im") {
  957. var cash = fields[2].getElementsByClassName('cash')[0].getElementsByTagName('span')[0].innerHTML.split('>')[1];
  958. if (cash == amount) wasfound = true;
  959. var cash2 = cash.replace(/\,/g, "");
  960. if (cash2.indexOf('K') != -1) {
  961. var cashK = cash2.split('K')[0] * 1000;
  962. if (cashK == amount) wasfound = true;
  963. }
  964. if (cash2.indexOf('M') != -1) {
  965. var cashM = cash2.split('M')[0] * 1000000;
  966. if (cashM == amount) wasfound = true;
  967. } else if (cash2 == amount) wasfound = true;
  968. } else {
  969. var cashD = fields[2].getElementsByClassName('cash')[0].getElementsByTagName('span')[0].innerHTML.split('$')[1];
  970. if (cashD == amount) wasfound = true;
  971. var cash3 = cashD.replace(/\,/g, "");
  972. if (cash3.indexOf('K') != -1) {
  973. var cashK = cash3.split('K')[0] * 1000;
  974. if (cashK == amount) wasfound = true;
  975. }
  976. if (cash3.indexOf('M') != -1) {
  977. var cashM = cash3.split('M')[0] * 1000000;
  978. if (cashM == amount) wasfound = true;
  979. } else if (cash3 == amount) wasfound = true;
  980. }
  981. }
  982. if (wasfound) {
  983. var AttackButton = fields[4].getElementsByTagName('a')[0];
  984. if (ammo >= bountyAmmo) click(AttackButton);
  985. break;
  986. }
  987. }
  988. }
  989. if (!wasfound) {
  990. var tabs = document.getElementById('sectionTabs');
  991. setTimeout(function(){document.location = tabs.getElementsByTagName("a")[1];}, randomFromInterval(250, 1000));
  992. }
  993. }
  994. } else {
  995. var lnks = document.links;
  996. var wasfound = false;
  997. var mystring = csearch;
  998. for (i = 0; i < lnks.length; i++) {
  999. var test = lnks[i].href;
  1000. if (test.indexOf(csearch) >= 0) {
  1001. wasfound = true;
  1002. document.location = lnks[i];
  1003. break;
  1004. }
  1005. }
  1006. if (!wasfound) {
  1007. setTimeout(function(){document.location = hitlistlink;}, randomFromInterval(250, 1000));
  1008. }
  1009. }
  1010. }
  1011. }
  1012.  
  1013. // AutoBank
  1014. function bankIt() {
  1015. if (GM_getValue("autobank", false)) {
  1016. var cash = getCash();
  1017. if (cash > 0) postwith("bank.php", ['depositAmount', cash, 'action', 'Deposit']);
  1018. }
  1019. }
  1020.  
  1021. // MessageBox
  1022. if (messageBox == true) {
  1023. // Remove messageBox
  1024. var messageBox = document.getElementsByClassName('messageBox infoBox');
  1025. if (messageBox.length > 0) {
  1026. for (i = messageBox.length - 1; i >= 0; i--) {
  1027. messageBox[i].parentNode.removeChild(messageBox[i]);
  1028. }
  1029. }
  1030. // Remove ads
  1031. var successMsg = document.getElementsByClassName('messageBoxSuccess')[0];
  1032. if (successMsg != null) {
  1033. var installAction = successMsg.getElementsByClassName('installAction')[0];
  1034. if (installAction != null) {
  1035. successMsg.parentNode.removeChild(successMsg);
  1036. }
  1037. }
  1038. }
  1039.  
  1040. if (autoAttack) {
  1041. var healthCurrent = parseInt(document.getElementById('healthCurrent').innerHTML);
  1042. if (page == "fight" && autoAttack && healthCurrent > 26) {
  1043. var elementBtnMed = document.getElementsByClassName('btnMed')[2];
  1044. var attackurl = elementBtnMed.getAttribute('onclick').split("href='/")[1].split("';")[0];
  1045. attackurl = "http://"+game+".storm8.com/"+attackurl;
  1046. var won = document.getElementsByClassName('lostFight').length;
  1047. if (!killAfterLose && won && elementBtnMed != null) {
  1048. document.location = attackurl;
  1049. }
  1050. if (killAfterLose && won) {
  1051. return;
  1052. } else if (elementBtnMed != null) {
  1053. document.location = attackurl;
  1054. }
  1055. } else if (page == "fight" && healthCurrent <= 26) {
  1056. GM_setValue('need2heal', 1);
  1057. document.location = hospitallink;
  1058. } else if (page == "hospital" && healthCurrent <= 26 && need2heal == 1) {
  1059. GM_setValue('need2heal', 2);
  1060. document.location = document.getElementsByClassName('tac healBtn')[0].getElementsByTagName('a')[0].href;
  1061. } else if (page == "hospital" && healthCurrent > 26 && need2heal == 2) {
  1062. GM_setValue('need2heal', 0);
  1063. window.history.go(-3);
  1064. }
  1065. }
  1066.  
  1067. // Autokill
  1068. if (page == "hitlist" && GM_getValue("bounty", false)) attackSanc(killAfterLose);
  1069.  
  1070. if (GM_getValue('akheal', false)) {
  1071. var healthCurrent = parseInt(document.getElementById('healthCurrent').innerHTML);
  1072. if (page == "hitlist" && healthCurrent <= 26) {
  1073. document.location = hospitallink;
  1074. } else if (page == "hospital" && healthCurrent <= 26) {
  1075. document.location = document.getElementsByClassName('tac healBtn')[0].getElementsByTagName('a')[0].href;
  1076. } else if (page == "hospital" && healthCurrent > 26) {
  1077. document.location = hitlistlink;
  1078. GM_setValue('akheal', false);
  1079. }
  1080. }
  1081.  
  1082. function attackSanc(noReattack) {
  1083. // Check health
  1084. if (parseInt(document.getElementById('healthCurrent').innerHTML) <= 26) {
  1085. GM_setValue('akheal', true);
  1086. return;
  1087. }
  1088. // Check ammo
  1089. if (document.getElementById('staminaCurrent').innerHTML == 0) {
  1090. var delay = Math.random() * 5;
  1091. var time = document.getElementById('staminaType').innerHTML.split(':');
  1092. var seconds = parseInt(time[0]) * 60 + parseInt(time[1]) + delay;
  1093. bountyAmmo = Math.max(1, bountyAmmo);
  1094. seconds = seconds + 100 * (bountyAmmo - 1);
  1095. setTimeout(function(){document.location = hitlistlink;}, Math.floor(1000 * seconds));
  1096. return;
  1097. }
  1098. // Check for reattack
  1099. if (!noReattack) {
  1100. var won = document.getElementsByClassName('lostFight').length;
  1101. var alive = document.getElementsByClassName('doAgainTxt');
  1102. if (won && alive.length > 0) {
  1103. var next = alive[0].getElementsByTagName('input')[0];
  1104. click(next);
  1105. return;
  1106. }
  1107. }
  1108. // Find a new person to attack
  1109. var people = document.getElementsByClassName("fightTable");
  1110. var found = false;
  1111. for (i = 0; i < people.length; i++) {
  1112. var fields = people[i].getElementsByTagName("td");
  1113. if (game == "wwar" || game == "vl" || game == "zl" || game == "rl") {
  1114. var level = parseInt(fields[1].getElementsByTagName("div")[1].innerHTML.substr(6));
  1115. if (game == "wwar") {
  1116. var country = fields[0].getElementsByTagName("img")[0].src.split("/")[6].substr(0, 1);
  1117. if (level < bountyLevel && country != sancCountry) {
  1118. var link = fields[5].getElementsByTagName('a')[0];
  1119. click(link);
  1120. clink(link);
  1121. found = true;
  1122. break;
  1123. }
  1124. }
  1125. if (game == "vl" || game == "zl") {
  1126. var level = parseInt(fields[1].getElementsByTagName("div")[1].innerHTML.substr(4));
  1127. if (level < bountyLevel) {
  1128. var link = fields[5].getElementsByTagName('a')[0];
  1129. click(link);
  1130. clink(link);
  1131. found = true;
  1132. break;
  1133. }
  1134. }
  1135. if (game == "rl") {
  1136. if (level < bountyLevel) {
  1137. var link = fields[5].getElementsByTagName('a')[0];
  1138. click(link);
  1139. clink(link);
  1140. found = true;
  1141. break;
  1142. }
  1143. }
  1144. } else {
  1145. var level = parseInt(fields[0].getElementsByTagName("div")[1].innerHTML.substr(6));
  1146. if (level < bountyLevel) {
  1147. var link = fields[4].getElementsByTagName('a')[0];
  1148. click(link);
  1149. clink(link);
  1150. found = true;
  1151. break;
  1152. }
  1153. }
  1154. }
  1155. if (!found) setTimeout(function() {document.location = hitlistlink;}, randomFromInterval(250, 1000));
  1156. }
  1157.  
  1158. if (resanc) {
  1159. if (page == "hitlist") {
  1160. document.location = homelink;
  1161. }
  1162. if (page == "home") {
  1163. setTimeout(resanc_home, 1000);
  1164. }
  1165. if (page == "profile") {
  1166. var buttons = document.getElementsByClassName('buttonHolder')[0].getElementsByTagName('input');
  1167. click(buttons[buttons.length - 1]);
  1168. }
  1169. }
  1170.  
  1171. function resanc_home() {
  1172. var a = document.getElementsByTagName('a');
  1173. var found = false;
  1174. for (i = 0; i < a.length; i++) {
  1175. if (a[i].innerHTML == resanc) {
  1176. found = true;
  1177. break;
  1178. }
  1179. }
  1180. if (GM_getValue('rechecksanchome', false) && !found) {
  1181. GM_setValue('resanc', false);
  1182. GM_setValue('rechecksanchome', false);
  1183. }
  1184. if (!found) {
  1185. setTimeout(function(){location.reload();}, randomFromInterval(1000, 3000));
  1186. GM_setValue('rechecksanchome', true);
  1187. } else {
  1188. GM_setValue('rechecksanchome', false);
  1189. document.location = a[i];
  1190. }
  1191. }
  1192.  
  1193. // AutoBounty
  1194. if (page == "bounty" && !ransanc) {
  1195. GM_setValue("resanc", false);
  1196. var form = document.getElementById('bountyForm');
  1197. var target = document.getElementsByClassName('sectionHeader')[0].innerHTML.split('"')[1];
  1198. form.getElementsByTagName('input')[0].value = amount;
  1199. if (autosancNum > 0) {
  1200. GM_setValue('resanc', target);
  1201. GM_setValue('autosancNum', autosancNum - 1);
  1202. // See if it failed to sanction
  1203. var n = 0;
  1204. var fails = document.getElementsByClassName('messageBoxFail');
  1205. if (fails.length > 0) {
  1206. GM_setValue('autosancNum', autosancNum);
  1207. if (fails[0].innerHTML.length == 114 + resanc.length || fails[0].innerHTML.length == 110 + resanc.length) {
  1208. // Too many sancs for today
  1209. GM_setValue('resanc', false);
  1210. return;
  1211. }
  1212. n = randomFromInterval(3000, 10000);
  1213. }
  1214. setTimeout(click_sanc, n);
  1215. }
  1216. }
  1217.  
  1218. function click_sanc() {
  1219. click(document.getElementById('bountyForm').getElementsByClassName('btnBroadcast')[0]);
  1220. }
  1221.  
  1222. function click(e, type) {
  1223. if (!e) {
  1224. return;
  1225. }
  1226. if (typeof e == 'string') e = document.getElementById(e);
  1227. var evObj = document.createEvent('MouseEvents');
  1228. evObj.initMouseEvent((type || 'click'), true, true, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null);
  1229. e.dispatchEvent(evObj);
  1230. }
  1231.  
  1232. function togglevisibility() {
  1233. var vismenu = document.getElementById('s8fixermenu');
  1234. var btnshow = document.getElementById('hiddentog');
  1235. var vismenudisp = window.getComputedStyle(vismenu, null).getPropertyValue("display");
  1236. if (vismenudisp == "block") {
  1237. vismenu.style.display = 'none';
  1238. btnshow.style.display = 'block';
  1239. GM_setValue("showorhide", "none");
  1240. GM_setValue("hideorshow", "block");
  1241. }
  1242. if (vismenudisp == "none") {
  1243. vismenu.style.display = 'block';
  1244. btnshow.style.display = 'none';
  1245. GM_setValue("showorhide", "block");
  1246. GM_setValue("hideorshow", "none");
  1247. }
  1248. }
  1249.  
  1250. function getTxtFile(url, isUpdate) {
  1251. var txtFile = new XMLHttpRequest();
  1252. txtFile.open("GET", url, true);
  1253. txtFile.onreadystatechange = function() {
  1254. if (txtFile.readyState === 4) {
  1255. if (txtFile.status === 200) {
  1256. if (!isUpdate) {
  1257. alert(txtFile.responseText);
  1258. }
  1259. if (isUpdate && txtFile.responseText != curVer) {
  1260. getTxtFile('https://dl.dropboxusercontent.com/s/8s2p7yf0dr1bfyg/update.txt?token_hash=AAFAdZsSJHwlOsImrRrKmT9rfPXwy4ZB3QIL5LXhOrzZwA&dl=1', false);
  1261. }
  1262. }
  1263. }
  1264. }
  1265. txtFile.send(null);
  1266. }
  1267.  
  1268. function getQueryVariable(query, variable) {
  1269. var qm = query.indexOf('?');
  1270. if (qm >= 0) query = query.substring(qm + 1);
  1271. var vars = query.split("&");
  1272. for (var i = 0; i < vars.length; i++) {
  1273. var pair = vars[i].split("=");
  1274. if (pair[0] == variable) return pair[1];
  1275. }
  1276. }
  1277.  
  1278. function healmeth() {
  1279. var box = document.getElementById('healthtimer').value;
  1280. var fn = box.split('-')[0] * 1000;
  1281. var sn = box.split('-')[1] * 1000;
  1282. var ahd = randomFromInterval(fn, sn);
  1283. GM_setValue("ahd", ahd);
  1284. }
  1285.  
  1286. function randomFromInterval(from, to) {
  1287. return Math.floor(Math.random() * (to - from + 1) + from);
  1288. }
  1289.  
  1290. function postwith(to, p) {
  1291. var myForm = document.createElement("form");
  1292. myForm.method = "post";
  1293. myForm.action = to;
  1294. for (var k = 0; k < p.length; k += 2) {
  1295. var myInput = document.createElement("input");
  1296. myInput.setAttribute("name", p[k]);
  1297. myInput.setAttribute("value", p[k + 1]);
  1298. myForm.appendChild(myInput);
  1299. }
  1300. document.body.appendChild(myForm);
  1301. myForm.submit();
  1302. document.body.removeChild(myForm);
  1303. }
  1304.  
  1305. function fixNum(n) {
  1306. n += '';
  1307. var rgx = /(\d+)(\d{3})/;
  1308. while (rgx.test(n)) {
  1309. n = n.replace(rgx, '$1' + ',' + '$2');
  1310. }
  1311. return n;
  1312. }
  1313.  
  1314. function getCash() {
  1315. var cfield = document.getElementById('cashCurrent');
  1316. var cash = 0;
  1317. if (cfield.getElementsByTagName('a').length > 0) return parseInt(cfield.getElementsByTagName('a')[0].innerHTML.replace(/,/g, ''));
  1318. else return parseInt(cfield.innerHTML.replace(/,/g, ''));
  1319. }
  1320.  
  1321. function getPuid(setBox) {
  1322. if (setBox) {
  1323. if (GM_getValue('cleared', false)) {
  1324. arrayPuid = [];
  1325. GM_setValue('cleared', false);
  1326. arrayPuid.push(searchBox.value);
  1327. GM_SuperValue.set('puidArray', arrayPuid);
  1328. createOpts(arrayPuid, false);
  1329. setSelect('selectboxPUID', searchBox.value);
  1330. GM_setValue('puidSelected', searchBox.value);
  1331. GM_setValue('puidSet', searchBox.value);
  1332. clrBtn.disabled = false;
  1333. clrAll.disabled = false;
  1334. btnSet.disabled = true;
  1335. } else {
  1336. arrayPuid.push(searchBox.value);
  1337. GM_SuperValue.set('puidArray', arrayPuid);
  1338. createOpts(arrayPuid, false);
  1339. setSelect('selectboxPUID', searchBox.value);
  1340. GM_setValue('puidSelected', searchBox.value);
  1341. GM_setValue('puidSet', searchBox.value);
  1342. clrBtn.disabled = false;
  1343. clrAll.disabled = false;
  1344. btnSet.disabled = true;
  1345. }
  1346. } else {
  1347. if (GM_getValue('cleared', false)) {
  1348. arrayPuid = [];
  1349. GM_setValue('cleared', false);
  1350. if (game == "wwar" || game == "vl" || game == "zl" || game == "rl") {
  1351. var profileName = document.getElementsByClassName('profileRight')[0].getElementsByTagName('b')[0].innerHTML;
  1352. var puidAndName = String(location).split('=')[1].split('&')[0] + " - " + profileName;
  1353. arrayPuid.push(puidAndName);
  1354. GM_SuperValue.set('puidArray', arrayPuid);
  1355. createOpts(arrayPuid, true);
  1356. clrBtn.disabled = false;
  1357. clrAll.disabled = false;
  1358. getBtn.disabled = true;
  1359. } else {
  1360. var profileName = document.getElementsByClassName('profileHeader')[0].getElementsByTagName('span')[0].innerHTML;
  1361. var puidAndName = String(location).split('=')[1].split('&')[0] + " - " + profileName;
  1362. arrayPuid.push(puidAndName);
  1363. GM_SuperValue.set('puidArray', arrayPuid);
  1364. createOpts(arrayPuid, true);
  1365. clrBtn.disabled = false;
  1366. clrAll.disabled = false;
  1367. getBtn.disabled = true;
  1368. }
  1369. } else {
  1370. if (game == "wwar" || game == "vl" || game == "zl" || game == "rl") {
  1371. var profileName = document.getElementsByClassName('profileRight')[0].getElementsByTagName('b')[0].innerHTML;
  1372. var puidAndName = String(location).split('=')[1].split('&')[0] + " - " + profileName;
  1373. arrayPuid.push(puidAndName);
  1374. GM_SuperValue.set('puidArray', arrayPuid);
  1375. createOpts(arrayPuid, true);
  1376. clrBtn.disabled = false;
  1377. clrAll.disabled = false;
  1378. getBtn.disabled = true;
  1379. } else {
  1380. var profileName = document.getElementsByClassName('profileHeader')[0].getElementsByTagName('span')[0].innerHTML;
  1381. var puidAndName = String(location).split('=')[1].split('&')[0] + " - " + profileName;
  1382. arrayPuid.push(puidAndName);
  1383. GM_SuperValue.set('puidArray', arrayPuid);
  1384. createOpts(arrayPuid, true);
  1385. clrBtn.disabled = false;
  1386. clrAll.disabled = false;
  1387. getBtn.disabled = true;
  1388. }
  1389. }
  1390. }
  1391. }
  1392.  
  1393. function clrPuid(all) {
  1394. if (all) {
  1395. selBox.innerHTML = '';
  1396. GM_SuperValue.set('puidArray', []);
  1397. GM_setValue('cleared', true);
  1398. GM_setValue('puidSet', '');
  1399. clrBtn.disabled = true;
  1400. clrAll.disabled = true;
  1401. if (searchBox.value != "") btnSet.disabled = false;
  1402. } else {
  1403. var selectedPuid = selBox.options[selBox.selectedIndex].text;
  1404. var puidToRemove = arrayPuid.indexOf(selectedPuid);
  1405. arrayPuid.splice(puidToRemove, 1);
  1406. GM_SuperValue.set('puidArray', arrayPuid);
  1407. if (GM_getValue('puidSet', '') == selectedPuid) GM_setValue('puidSet', '');
  1408. deleteOpts(arrayPuid);
  1409. if (arrayPuid == "") {
  1410. clrBtn.disabled = true;
  1411. clrAll.disabled = true;
  1412. }
  1413. }
  1414. if (searchBox.value == selectedPuid) btnSet.disabled = false;
  1415. getBtn.disabled = false;
  1416. checkOpts(arrayPuid);
  1417. if (page != "profile") getBtn.disabled = true;
  1418. }
  1419.  
  1420. function createOpts(array, firstTime) {
  1421. if (game == "wwar" || game == "vl" || game == "zl" || game == "rl") {
  1422. selBox.innerHTML = "";
  1423. for (var i = 0; i < array.length; i++) {
  1424. var opt = document.createElement('option');
  1425. opt.innerHTML = array[i];
  1426. opt.value = array[i];
  1427. selBox.appendChild(opt);
  1428. }
  1429. if (firstTime) {
  1430. var profileName = document.getElementsByClassName('profileRight')[0].getElementsByTagName('b')[0].innerHTML;
  1431. var puidCreated = String(location).split('=')[1].split('&')[0] + " - " + profileName;
  1432. setSelect('selectboxPUID', puidCreated);
  1433. GM_setValue('puidSelected', puidCreated);
  1434. }
  1435. } else {
  1436. selBox.innerHTML = "";
  1437. for (var i = 0; i < array.length; i++) {
  1438. var opt = document.createElement('option');
  1439. opt.innerHTML = array[i];
  1440. opt.value = array[i];
  1441. selBox.appendChild(opt);
  1442. }
  1443. if (firstTime) {
  1444. var profileName = document.getElementsByClassName('profileHeader')[0].getElementsByTagName('span')[0].innerHTML;
  1445. var puidCreated = String(location).split('=')[1].split('&')[0] + " - " + profileName;
  1446. setSelect('selectboxPUID', puidCreated);
  1447. GM_setValue('puidSelected', puidCreated);
  1448. }
  1449. }
  1450. }
  1451.  
  1452. function deleteOpts(array) {
  1453. var selectedPuid = selBox.options[selBox.selectedIndex].text;
  1454. var opts = selBox.getElementsByTagName('option');
  1455. for (i in opts) {
  1456. if (opts[i].value == selectedPuid) {
  1457. optSelected = opts[i];
  1458. optSelected.parentNode.removeChild(optSelected);
  1459. }
  1460. }
  1461. }
  1462.  
  1463. function checkOpts(array) {
  1464. if (game == "wwar" || game == "vl" || game == "zl" || game == "rl") {
  1465. var oldPuidSelected = puidSelected;
  1466. var newPuidSelected = selBox.value;
  1467. if (oldPuidSelected != newPuidSelected) {
  1468. GM_setValue("puidSelected", newPuidSelected);
  1469. setSelect('selectboxPUID', newPuidSelected);
  1470. }
  1471. var opts = selBox.getElementsByTagName('option');
  1472. for (i = 0; i < opts.length; i++) {
  1473. optsUnallowed = opts[i].innerHTML;
  1474. var profileName = document.getElementsByClassName('profileRight')[0].getElementsByTagName('b')[0].innerHTML;
  1475. if (String(location).split('=')[1].split('&')[0] + " - " + profileName == optsUnallowed) {
  1476. getBtn.disabled = true;
  1477. }
  1478. }
  1479. } else {
  1480. var oldPuidSelected = puidSelected;
  1481. var newPuidSelected = selBox.value;
  1482. if (oldPuidSelected != newPuidSelected) {
  1483. GM_setValue("puidSelected", newPuidSelected);
  1484. setSelect('selectboxPUID', newPuidSelected);
  1485. }
  1486. var opts = selBox.getElementsByTagName('option');
  1487. for (i = 0; i < opts.length; i++) {
  1488. optsUnallowed = opts[i].innerHTML;
  1489. var profileName = document.getElementsByClassName('profileHeader')[0].getElementsByTagName('span')[0].innerHTML;
  1490. if (String(location).split('=')[1].split('&')[0] + " - " + profileName == optsUnallowed) {
  1491. getBtn.disabled = true;
  1492. }
  1493. }
  1494. }
  1495. }
  1496.  
  1497. function setSelect(id, val) {
  1498. var elem = document.getElementById(id);
  1499. for (n = elem.length - 1; n >= 0; n--) {
  1500. if (elem.options[n].value == val) {
  1501. elem.options[n].selected = true;
  1502. }
  1503. }
  1504. }
  1505.  
  1506. function encodeHTML(str) {
  1507. var buf = [];
  1508. for (var i = str.length - 1; i >= 0; i--) {
  1509. buf.unshift(['&#', str[i].charCodeAt(), ';'].join(''));
  1510. }
  1511. return buf.join('');
  1512. }
  1513.  
  1514. function unHideNames() {
  1515. if (page == "home" || page == "group" || page == "group_member" || page == "fight" || page == "hitlist" || (page == "profile" && String(location).indexOf('selectedTab=comment') != -1)) {
  1516. var allLinks = document.getElementsByTagName('a');
  1517. if (allLinks) {
  1518. for (var i=0; i<allLinks.length; i++) {
  1519. if (allLinks[i].href.indexOf('puid') != -1) {
  1520. var namecheck = allLinks[i].innerHTML;
  1521. var entityoutput = String(encodeHTML(namecheck));
  1522. var namechar = entityoutput.match(/;/g).length;
  1523. if (namechar <= 2) allLinks[i].innerHTML = 'CLICK ME!';
  1524. if (entityoutput.split('#')[1].split(';')[0] == "12288") allLinks[i].innerHTML = 'CLICK ME!';
  1525. }
  1526. }
  1527. }
  1528. }
  1529. }
  1530.  
  1531. function doroistuff() {
  1532. //Basic setup
  1533. var coh = GM_SuperValue.get('coh', 0);
  1534. var owned = [];
  1535. var buy = [];
  1536. var cost = [];
  1537. var roi = [];
  1538. var eids = [];
  1539. var inames = [];
  1540.  
  1541. //Setup for different games
  1542. var game = String(location).split('/')[2].split('.')[0];
  1543. if (game == "vl") {
  1544. var income = [50, 250, 800, 5000, 10000, 16000, 50000, 100000, 160000, 250000, 350000, 410000];
  1545. var initCost = [2000, 10000, 30000, 200000, 500000, 1100000, 4000000, 10000000, 20000000, 40000000, 75000000, 90000000];
  1546. }
  1547. if (game == "wwar") {
  1548. var income = [1000, 6500, 16500, 56000, 270000, 500000, 700000, 1200000, 1400000];
  1549. var initCost = [25000, 220000, 800000, 4000000, 30000000, 90000000, 150000000, 500000000, 1200000000];
  1550. }
  1551. if (game == "im") {
  1552. var income = [50, 250, 800, 5000, 10000, 16000, 50000, 100000, 160000, 250000, 275000, 300000, 350000, 375000, 400000, 430000];
  1553. var initCost = [2000, 10000, 30000, 200000, 500000, 1100000, 4000000, 10000000, 20000000, 40000000, 55000000, 75000000, 105000000, 150000000, 250000000, 420000000];
  1554. }
  1555. if (game == "zl") {
  1556. var income = [1, 5, 10, 25, 65, 110, 200, 350, 590, 900, 1500, 2700, 4200];
  1557. var initCost = [40, 220, 500, 1500, 5000, 11000, 25000, 54000, 110000, 200000, 360000, 700000, 1200000];
  1558. }
  1559. if (game == "rl") {
  1560. var income = [50, 100, 200, 400, 1000, 1500, 2700, 4800, 7500, 11500, 28000, 32000, 34000];
  1561. var initCost = [3000, 7000, 15000, 55000, 175000, 330000, 700000, 1100000, 2000000, 3250000, 8500000, 12500000, 15000000];
  1562. }
  1563. if (game == "kl") {
  1564. var income = [1, 5, 12, 50, 150, 250, 800, 1400, 2200, 3200, 4500, 6200, 15000];
  1565. var initCost = [50, 250, 650, 2800, 9000, 14000, 50000, 100000, 180000, 320000, 540000, 1250000, 4000000];
  1566. }
  1567. if (game == "rol") {
  1568. var income = [20, 40, 75, 240, 700, 1200, 2000, 2700, 5000, 7500, 12500];
  1569. var initCost = [800, 1700, 3800, 14000, 50000, 100000, 200000, 330000, 720000, 1250000, 2500000];
  1570. }
  1571. if (game == "nl") {
  1572. var income = [];
  1573. var initCost = [];
  1574. }
  1575. if (game == "pl") {
  1576. var income = [];
  1577. var initCost = [];
  1578. }
  1579.  
  1580. var investitem = document.getElementsByClassName('investItem');
  1581. for (var i = 0; i < investitem.length; i++) {
  1582. var numown = investitem[i].getElementsByClassName('ownedNum')[0];
  1583. if (numown) {
  1584. var info = investitem[i].getElementsByClassName("reInfoItem")[0];
  1585. var type = info.innerHTML.substr(0, 1);
  1586. var investname = investitem[i].getElementsByClassName('reName')[0].innerHTML;
  1587. if (type == "I") {
  1588. var invid = investitem[i].getElementsByClassName('reBuyAction')[0].getElementsByTagName('a')[0].href.split('inv_id=')[1].split('&')[0];
  1589. var rno = parseInt(numown.innerHTML.replace(/,/g, ''));
  1590. if (rno < 32767) owned.push(rno);
  1591. if (rno >= 32767) owned.push(1000000000000);
  1592. inames.push(investname);
  1593. buy.push(0);
  1594. eids.push(parseInt(invid));
  1595. }
  1596. }
  1597. }
  1598.  
  1599. function askCash() {
  1600. var cash = prompt('How much would you like to spend?', '0');
  1601. if (cash != null && cash != "" && parseInt(cash) <= 5000000000000) {
  1602. GM_SuperValue.set('coh', parseInt(cash));
  1603. document.location = 'http://' + game + '.storm8.com/investment.php';
  1604. }
  1605. if (parseInt(cash) > 5000000000000) {
  1606. alert("Don't spend more than 5T at once");
  1607. document.location = 'http://' + game + '.storm8.com/investment.php';
  1608. }
  1609. if (cash == null) GM_setValue('doingroi', false);
  1610. }
  1611.  
  1612. function getClosestValue(a, x) {
  1613. var lo, hi;
  1614. for (var i = a.length; i--;) {
  1615. if (a[i] <= x && (lo === undefined || lo < a[i])) lo = a[i];
  1616. if (a[i] >= x && (hi === undefined || hi > a[i])) hi = a[i];
  1617. }
  1618. return [lo];
  1619. }
  1620.  
  1621. function whatToBuy() {
  1622. for (var j = 0; j < owned.length; j++) {
  1623. cost.push((1 + 0.1 * (owned[j] + buy[j])) * initCost[j]);
  1624. roi.push(income[j] / cost[j]);
  1625. }
  1626. var toh = coh;
  1627. while (toh > 0) {
  1628. var wtb = getClosestValue(roi, 1);
  1629. for (var i = 0; i < roi.length; i++) {
  1630. if (wtb == roi[i]) {
  1631. toh = toh - cost[i];
  1632. if (toh > 0) {
  1633. buy[i] = buy[i] + 1;
  1634. cost[i] = (1 + 0.1 * (owned[i] + buy[i])) * initCost[i];
  1635. roi[i] = income[i] / cost[i];
  1636. if ((buy[i] + owned[i]) >= 32767) owned[i] = 1000000000000;
  1637. } else {
  1638. GM_SuperValue.set('coh', 0);
  1639. break;
  1640. }
  1641. }
  1642. }
  1643. }
  1644. var allz = 0;
  1645. for (var z = 0; z < buy.length; z++) {
  1646. if (buy[z] == 0) allz++;
  1647. }
  1648. if (allz == buy.length) {
  1649. alert('You cannot afford to buy the best ROI.');
  1650. GM_setValue('doingroi', false);
  1651. } else {
  1652. GM_SuperValue.set('buy', buy);
  1653. document.location = 'http://' + game + '.storm8.com/investment.php';
  1654. }
  1655. }
  1656.  
  1657. function formulateBuy() {
  1658. var buyarray = GM_SuperValue.get('buy', null);
  1659. var timetr = 0;
  1660. var waitbitch = 0;
  1661. for (var i = 0; i < buyarray.length; i++) {
  1662. if (buyarray[i] > 0 && waitbitch == 0) {
  1663. waitbitch = 1;
  1664. var numofinv = buyarray[i];
  1665. var invidtobuy = eids[i];
  1666. var p = confirm('You are about to buy ' + numofinv + ' ' + inames[i] + "'s.");
  1667. if (p) {
  1668. postwith("investment.php", ['inv_id', invidtobuy, 'action', 'buy', 'numberOfInv', numofinv]);
  1669. buyarray[i] = 0;
  1670. GM_SuperValue.set('buy', buyarray);
  1671. } else {
  1672. GM_SuperValue.set('buy', null);
  1673. GM_setValue('doingroi', false);
  1674. return;
  1675. }
  1676. }
  1677. if (buyarray[i] == 0) timetr++;
  1678. if (timetr == buyarray.length) {
  1679. GM_SuperValue.set('buy', null);
  1680. GM_setValue('doingroi', false);
  1681. }
  1682. }
  1683. }
  1684. if (coh > 0 && GM_SuperValue.get('buy', null) == null) whatToBuy();
  1685. if (coh <= 0 && GM_SuperValue.get('buy', null) == null) askCash();
  1686. if (GM_SuperValue.get('buy', null) != null) formulateBuy();
  1687. }
  1688.  
  1689. if (!window.closed) {
  1690. setInterval(bankIt, 60 * 1000 * 30);
  1691. setInterval(checkOptions, 100);
  1692. }