Advertisement
zyzzyzus

IGM multibuy mod

Jun 11th, 2014
35,325
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*
  2. Bookmarklet:
  3. javascript:(function(){with(document)(head.appendChild(createElement('script')).src='http://pastebin.com/raw.php?i=hCTuvzBf')._})();
  4. */
  5.  
  6. (function()
  7. {
  8. if(l('saveBox').innerHTML.indexOf('<select name="multibuy">') == -1)
  9. {
  10. var multbuyopt = '<select name="multibuy">';
  11.  
  12. for(i in Game.buildings)
  13. {
  14. if(Game.buildings[i].visible && Game.buildings[i].real)
  15. {
  16. multbuyopt+= "<option value=" + Game.buildings[i].key + '>' + Game.buildings[i].name + '</option>';
  17. }
  18. }
  19. multbuyopt+= '</select>';
  20. return l('saveBox').innerHTML += multbuyopt + "<div class='button' onclick='buylots(10);'>Buy 10</div>" + "<div class='button' onclick='buylots(100);'>Buy 100</div>" + "<div class='button' onclick='sellall();'>Sell all</div>";
  21. }
  22. }())
  23.  
  24. sellall = function()
  25. {
  26. var build = document.getElementsByName('multibuy')[0].selectedOptions[0].value;
  27. if(Game.cssData.indexOf(".sell") == -1 && Game.cssData.indexOf("#sell-" + Game.buildings[build].key) == -1)
  28. {
  29. if(confirm('Are you sure you want to sell all ' + Game.buildings[build].plural + '?'))
  30. {
  31. while(Game.buildings[build].amount > 0 && Game.buildings[build].visible)
  32. {
  33. Game.buildings[build].Sell();
  34. }
  35. }
  36. }
  37. }
  38.  
  39. buylots = function(amount)
  40. {
  41. var build = document.getElementsByName('multibuy')[0].selectedOptions[0].value;
  42. for(i=0;i<amount;i++)
  43. {
  44. if(Game.buildings[build].visible && Game.buildings[build].CanBuy())
  45. {
  46. Game.buildings[build].Buy();
  47. }
  48. }
  49. }
  50.  
  51. with(l('saveBox')){
  52. if(innerHTML.indexOf("confirm('Are you sure you want to reset?')") == -1) innerHTML = innerHTML.replace("Game.Reset()","if(confirm('Are you sure you want to reset?')){Game.Reset()}")}
  53.  
  54. document.getElementsByName('multibuy')[0].onfocus=function(){
  55. multbuyopt = '';
  56. for(i in Game.buildings)
  57. {
  58. if(Game.buildings[i].visible && Game.buildings[i].real)
  59. {
  60. multbuyopt+= "<option value=" + Game.buildings[i].key + '>' + Game.buildings[i].name + '</option>';
  61. }}
  62. document.getElementsByName('multibuy')[0].innerHTML = multbuyopt;}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement