Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ==UserScript==
- // @name BlueprintPrototype
- // @namespace http://tampermonkey.net/
- // @version 0.1
- // @description try to take over the world!
- // @author stronzio
- // @match https://game288398.konggames.com/gamez/0028/8398/live/*
- // @grant none
- // ==/UserScript==
- (function() {
- 'use strict';
- // what does this script do?
- // it adds two buttons on the planet interface (also called planet overview).
- // the leftmost toggles between different modes. the rightmost executes the blueprinting according to the mode selected.
- // 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).
- // MODES
- // *import from prototype* => imports the blueprint from the prototype. No effect if invoked on the prototype itself.
- // TBD?*prototype to galaxy* => exports this planet's blueprint to all planets of the same type in the same galaxy.
- // *prototype to empire* => exports this planet's blueprint to all planets of the same type in all the galaxies.
- // TBD?*export everywhere* => export this planet's blueprint to all planets.
- // ALWAYS BACKUP YOUR SAVE: this script interacts with game code. While it shouldnt cause any catastrophe, better safe than sorry.
- //////////
- var protonames = ["promision", "vasilis", "aequoreas", "orpheus", "antirion", "lone nassaus", "epsilon rutheni", "xenovirgo", "magellan", "auriga", "forax"];
- var protoimport = true; //true => enable *import from prototype* mode
- var protoempire = true; //true => enable *export to empire* mode
- //////////
- var config = { subtree: true, childList: true};
- var ele = document.getElementById("planet_interface");
- var cname = "action_proto404";
- var cname2 = "mode_proto404";
- var modes = {};
- modes.import = protoimport;
- modes.empire = protoempire;
- var modesNames = {};
- modesNames.import = "Import from Prototype";
- modesNames.empire = "Export to Empire";
- var activeModes = [];
- for(let key in modes){
- if(modes[key] == true) activeModes.push(key);
- }
- if( activeModes.length == 0) {
- console.log("BlueprintPrototype: all modes deactivated");
- return;
- }
- var prototypes = {};
- protonames.forEach((s) => {
- let p = game.planets.filter((item) => planets[item].name.toLowerCase() == s.toLowerCase());
- if( p.length != 1) console.log("error in prototypes"); //need a better idea for those checks
- else prototypes[planets[p[0]].type] = p[0]; //store planet id for ease.
- });
- let currentMode = activeModes[0];
- var obs = new MutationObserver(function(mutation) {
- if(document.getElementById(cname)) return;
- if(!document.getElementById("action_b")) return;
- var b_btn = document.getElementById("action_b");
- var bpp_btn = document.createElement("button");
- var bpp_mode_btn = document.createElement("button");
- bpp_btn.innerText = "Do it!";
- bpp_mode_btn.innerText = modesNames[currentMode];
- bpp_btn.id = cname;
- bpp_mode_btn.id = cname2;
- bpp_btn.onclick = executeMode;
- bpp_mode_btn.onclick = toggleMode;
- b_btn.parentNode.insertBefore(bpp_mode_btn,b_btn);
- b_btn.parentNode.insertBefore(bpp_btn,b_btn);
- return;
- function toggleMode(){
- let next = activeModes.indexOf(currentMode) +1;
- if(next >= activeModes.length) next = 0;
- currentMode = activeModes[next];
- bpp_mode_btn.innerText = modesNames[currentMode];
- }
- function findPrototypeBP(){
- let type = planets[currentPlanet.id].type;
- return planets[prototypes[type]].exportBlueprint();
- }
- function executeMode(){
- //console.log(currentMode); //import, empire
- switch(currentMode) {
- case "import":
- planets[currentPlanet.id].importBlueprint(findPrototypeBP());
- return;
- case "empire":
- game.planets.filter((item) => planets[item].type == planets[currentPlanet.id].type).forEach((item) => planets[item].importBlueprint(planets[currentPlanet.id].exportBlueprint()));
- return;
- }
- }
- });
- obs.observe(ele,config);
- })();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement