Ship info

Adds beam target, crew xp and hull mass to ship screen

当前为 2015-09-08 提交的版本,查看 最新版本

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name			Ship info
// @description		Adds beam target, crew xp and hull mass to ship screen
// @author			Singularity (c) 2015
// @include			http://planets.nu/home
// @include			http://planets.nu/games/*
// @include			http://*.planets.nu/*
// @include			http://planets.nu/*
// @version			0.3
// @history         0.1 displayed crew xp
// @history         0.2 added ship mass
// @history         0.3 added beam transfer targets (foreign ships/planets)
// @namespace       https://greasyfork.org/en/users/15085-singularity
// ==/UserScript==


function wrapper () { // wrapper for injection

	if (vgap.version < 3) {
		console.log("Ship Info needs Nu version 3 or above");
		return;
	}

	var plugin = {
		draw: function() {

			try {
				//Try adding Ship info to the shipscreen. Briefly throws an exception during time machine use.

				if (vgap.shipScreenOpen) {
					var ship=vgap.shipScreen.ship;

					//Add crew experience
					$('td:contains("Crew:")').text('Crew: ('+ship.experience+' xp)');


					//Add hull mass
					$('td:contains("Damage:")').text('Damage: ('+vgap.shipScreen.hull.mass+' kt)');


					//Add foreign transfer target
					if ($('#TransferInfo').length===0) //add TransferInfo html
						$('#ShipCargo').append("<br><div id='TransferInfo'></div>");


					//Update the TransferInfo
					var xferType=ship.transfertargettype;
					var xferID=ship.transfertargetid;
					var xferInProgress=CheckForXfers(ship);

					var xferText="Beam Transfer: None";

					if (xferType===1 && xferInProgress)  //beaming to foreign planet
						xferText="Beam Transfer to Planet ("+vgap.getPlanet(xferID).name+")";

					if (xferType===2 && xferInProgress) //beaming to foreign ship
						xferText="Beam Transfer to Ship ("+xferID+": "+vgap.getShip(xferID).name+")";

					$('#TransferInfo').text(xferText);

				} //if ShipScreen open
			} //try
			catch(err) {
				console.log("exception in Ship Info draw()");
			}//catch

		}, //draw

	}; //plugin

	function CheckForXfers(ship) {
		if (ship.transferammo===0 &&
			ship.transfersupplies===0 &&
			ship.transferclans===0 &&
			ship.transferneutronium===0 &&
			ship.transferduranium===0 &&
			ship.transfertritanium===0 &&
			ship.transfermolybdenum===0) return false;

		return true;
	} //CheckForXfers


	// register your plugin with NU
	vgap.registerPlugin(plugin, "ShipInfo");


} //wrapper for injection

var script = document.createElement("script");
script.type = "application/javascript";
script.textContent = "(" + wrapper + ")();";

document.body.appendChild(script);