Planets.nu map printing

Allows opening a printable map

Tendrás que instalar una extensión para tu navegador como Tampermonkey, Greasemonkey o Violentmonkey si quieres utilizar este script.

You will need to install an extension such as Tampermonkey to install this script.

Necesitarás instalar una extensión como Tampermonkey o Violentmonkey para instalar este script.

Necesitarás instalar una extensión como Tampermonkey o Userscripts para instalar este script.

Necesitará instalar una extensión como Tampermonkey para instalar este script.

Necesitarás instalar una extensión para administrar scripts de usuario si quieres instalar este script.

(Ya tengo un administrador de scripts de usuario, déjame instalarlo)

Necesitará instalar una extensión como Stylus para instalar este estilo.

Necesitará instalar una extensión como Stylus para instalar este estilo.

Necesitará instalar una extensión como Stylus para instalar este estilo.

Necesitará instalar una extensión del gestor de estilos de usuario para instalar este estilo.

Necesitará instalar una extensión del gestor de estilos de usuario para instalar este estilo.

Necesitará instalar una extensión del gestor de estilos de usuario para instalar este estilo.

(Ya tengo un administrador de estilos de usuario, déjame instalarlo)

// ==UserScript==
// @name          Planets.nu map printing
// @namespace     planets.nu
// @description   Allows opening a printable map 
// @include       http://planets.nu/*
// @include       http://planets.nu/games/*
// @include       http://*.planets.nu/*
// @grant none
// @version 0.3
// ==/UserScript==
// later there will be svg-map animations - hopefully
// Version 0.3 - completely rewritten
// Version 0.2 - works with new servers
// Version 0.1 - created
function wrapper() {
  // wrapper for injection
  var plugin = {
    /*
			 * processload: executed whenever a turn is loaded: either the current turn or
			 * an older turn through time machine 
			 */
    processload: function () {
      //				console.log("ProcessLoad: plugin called.");
    },
    /*
			 * loaddashboard: executed to rebuild the dashboard content after a turn is loaded
			 */
    loaddashboard: function () {
      //				console.log("LoadDashboard: plugin called.");
    },
    /*
			 * showdashboard: executed when switching from starmap to dashboard
			 */
    showdashboard: function () {
      //				console.log("ShowDashboard: plugin called.");
    },
    /*
			 * showsummary: executed when returning to the main screen of the dashboard
			 */
    showsummary: function () {
      //				console.log("ShowSummary: plugin called.");
    },
    /*
			 * loadmap: executed after the first turn has been loaded to create the map
			 * as far as I can tell not executed again when using time machine
			 */
    loadmap: function () {
      vgap.map.addMapTool('Print Map', 'ShowMinerals', function () {
        vgap.plugins.PrintMap.openMap();
      });
    },
    /*
			 * showmap: executed when switching from dashboard to starmap
			 */
    showmap: function () {
      //				console.log("ShowMap: plugin called.");
    },
    /*
			 * draw: executed on any click or drag on the starmap
			 */
    draw: function () {
    },
    /*
			 * loadplanet: executed a planet is selected on dashboard or starmap
		 	 * loadstarbase: executed a planet is selected on dashboard or starmap
			 * Inside the function "load" of vgapPlanetScreen (vgapPlanetScreen.prototype.load) the normal planet screen 
			 * is set up. You can find the function in "nu.js" if you search for 'vgap.callPlugins("loadplanet");'.
			 * 
			 * Things accessed inside this function several variables can be accessed. Elements accessed as "this.X" 
			 * can be accessed here as "vgap.planetScreen.X".
			 */
    loadplanet: function () {
      //				console.log("LoadPlanet: plugin called.");
      //				console.log("Planet id: " + vgap.planetScreen.planet.id);
    },
    /*
			 * loadstarbase: executed a planet is selected on dashboard or starmap
			 * Inside the function "load" of vgapStarbaseScreen (vgapStarbaseScreen.prototype.load) the normal starbase screen 
			 * is set up. You can find the function in "nu.js" if you search for 'vgap.callPlugins("loadstarbase");'.
			 * 
			 * Things accessed inside this function several variables can be accessed. Elements accessed as "this.X" 
			 * can be accessed here as "vgap.starbaseScreen.X".
			 */
    loadstarbase: function () {
      //				console.log("LoadStarbase: plugin called.");
      //				console.log("Starbase id: " + vgap.starbaseScreen.starbase.id + " on planet id: " + vgap.starbaseScreen.planet.id);
    },
    /*
			 * loadship: executed a planet is selected on dashboard or starmap
			 * Inside the function "load" of vgapShipScreen (vgapShipScreen.prototype.load) the normal ship screen 
			 * is set up. You can find the function in "nu.js" if you search for 'vgap.callPlugins("loadship");'.
			 * 
			 * Things accessed inside this function several variables can be accessed. Elements accessed as "this.X" 
			 * can be accessed here as "vgap.shipScreen.X".
			 */
    loadship: function () {
    },
    // END PLUGIN FUNCS       			
    openMap: function ()
    {
      var canvas = vgap.map.canvas;
      //$(canvas).css('background-color', 'black');
      var imgURL = canvas.toDataURL('image/jpeg');
      var mapWindow = window.open(imgURL, 'MapWindow');
    }
  };
  // register your plugin with NU
  vgap.registerPlugin(plugin, 'PrintMap');
}
//wrapper for injection

var script = document.createElement('script');
script.type = 'application/javascript';
script.textContent = '(' + wrapper + ')();';
document.body.appendChild(script);
document.body.removeChild(script);