Advertisement
Guest User

Untitled

a guest
Jan 21st, 2019
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.45 KB | None | 0 0
  1. // ==UserScript==
  2. // @name BlueprintPrototype
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.1
  5. // @description try to take over the world!
  6. // @author stronzio
  7. // @match https://game288398.konggames.com/gamez/0028/8398/live/*
  8. // @grant none
  9. // ==/UserScript==
  10.  
  11. (function() {
  12. 'use strict';
  13.  
  14. // what does this script do?
  15.  
  16. // it adds two buttons on the planet interface (also called planet overview).
  17. // the leftmost toggles between different modes. the rightmost executes the blueprinting according to the mode selected.
  18. // prototypes are planets, specifically the first planet of each type (lava, terrestrial, ocean and so on) you encounter in ascending influence order. You may set a different list below (and should, if you make promision hub).
  19. // MODES
  20. // *import from prototype* => imports the blueprint from the prototype. No effect if invoked on the prototype itself.
  21. // TBD?*prototype to galaxy* => exports this planet's blueprint to all planets of the same type in the same galaxy.
  22. // *prototype to empire* => exports this planet's blueprint to all planets of the same type in all the galaxies.
  23. // TBD?*export everywhere* => export this planet's blueprint to all planets.
  24.  
  25. // ALWAYS BACKUP YOUR SAVE: this script interacts with game code. While it shouldnt cause any catastrophe, better safe than sorry.
  26.  
  27. //////////
  28.  
  29. var protonames = ["promision", "vasilis", "aequoreas", "orpheus", "antirion", "lone nassaus", "epsilon rutheni", "xenovirgo", "magellan", "auriga", "forax"];
  30. var protoimport = true; //true => enable *import from prototype* mode
  31. var protoempire = true; //true => enable *export to empire* mode
  32.  
  33. //////////
  34. var config = { subtree: true, childList: true};
  35. var ele = document.getElementById("planet_interface");
  36. var cname = "action_proto404";
  37. var cname2 = "mode_proto404";
  38. var modes = {};
  39. modes.import = protoimport;
  40. modes.empire = protoempire;
  41. var modesNames = {};
  42. modesNames.import = "Import from Prototype";
  43. modesNames.empire = "Export to Empire";
  44. var activeModes = [];
  45. for(let key in modes){
  46. if(modes[key] == true) activeModes.push(key);
  47. }
  48. if( activeModes.length == 0) {
  49. console.log("BlueprintPrototype: all modes deactivated");
  50. return;
  51. }
  52. var prototypes = {};
  53. protonames.forEach((s) => {
  54. let p = game.planets.filter((item) => planets[item].name.toLowerCase() == s.toLowerCase());
  55. if( p.length != 1) console.log("error in prototypes"); //need a better idea for those checks
  56. else prototypes[planets[p[0]].type] = p[0]; //store planet id for ease.
  57. });
  58. let currentMode = activeModes[0];
  59. var obs = new MutationObserver(function(mutation) {
  60. if(document.getElementById(cname)) return;
  61. if(!document.getElementById("action_b")) return;
  62. var b_btn = document.getElementById("action_b");
  63. var bpp_btn = document.createElement("button");
  64. var bpp_mode_btn = document.createElement("button");
  65. bpp_btn.innerText = "Do it!";
  66. bpp_mode_btn.innerText = modesNames[currentMode];
  67. bpp_btn.id = cname;
  68. bpp_mode_btn.id = cname2;
  69. bpp_btn.onclick = executeMode;
  70. bpp_mode_btn.onclick = toggleMode;
  71. b_btn.parentNode.insertBefore(bpp_mode_btn,b_btn);
  72. b_btn.parentNode.insertBefore(bpp_btn,b_btn);
  73. return;
  74.  
  75. function toggleMode(){
  76. let next = activeModes.indexOf(currentMode) +1;
  77. if(next >= activeModes.length) next = 0;
  78. currentMode = activeModes[next];
  79. bpp_mode_btn.innerText = modesNames[currentMode];
  80. }
  81.  
  82. function findPrototypeBP(){
  83. let type = planets[currentPlanet.id].type;
  84. return planets[prototypes[type]].exportBlueprint();
  85. }
  86.  
  87. function executeMode(){
  88. //console.log(currentMode); //import, empire
  89. switch(currentMode) {
  90. case "import":
  91. planets[currentPlanet.id].importBlueprint(findPrototypeBP());
  92. return;
  93. case "empire":
  94. game.planets.filter((item) => planets[item].type == planets[currentPlanet.id].type).forEach((item) => planets[item].importBlueprint(planets[currentPlanet.id].exportBlueprint()));
  95. return;
  96. }
  97. }
  98. });
  99. obs.observe(ele,config);
  100. })();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement