Planets.nu - improved Planet List View

Miscellaneous Improvements to the Planet List View

目前為 2016-02-02 提交的版本,檢視 最新版本

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

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

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name           Planets.nu - improved Planet List View
// @description    Miscellaneous Improvements to the Planet List View
// @include        http://planets.nu/home
// @include        http://play.planets.nu/*
// @include        http://planets.nu/*
// @include	   http://test.planets.nu/*
// @version 0.2
// @namespace https://greasyfork.org/users/2860
// ==/UserScript==
// 0.1 - Includes warnings about unhappiness levels on the planet, dangerous planetary fc's, show how close planets are to producing SBs, What's Interesting View to highlight problems
// 0.2 - Planets at dangerous temperatures are flagged in red or blue (hot/cold). New Notes Tab
function wrapper () { // wrapper for injection
oldShowPlanets =  vgapDashboard.prototype.showPlanets;


vgapDashboard.prototype.showPlanets = function (view) {

if (vgaPlanets.prototype.version<3)
	{
		oldShowPlanets.apply(this,arguments);
        vgap.playSound("button");

        vgap.closeSecond();
        this.pane.remove();


        //filter messages
        var html = "";

        if (!view)
            view = 0;

		//html += "<ul class='FilterMenu'><li " + (view == 0 ? "class='SelectedFilter'" : "") + " onclick='vgap.dash.showPlanets(0);'>Colony View</li><li " + (view == 1 ? "class='SelectedFilter'" : "") + " onclick='vgap.dash.showPlanets(1);'>Resource View</li></ul>";
       html += "<ul class='FilterMenu'><li " + (view == 0 ? "class='SelectedFilter'" : "") + " onclick='vgap.dash.showPlanets(0);'>Colony View</li><li " + (view == 1 ? "class='SelectedFilter'" : "") + " onclick='vgap.dash.showPlanets(1);'>Resource View</li><li " + (view == 2 ? "class='SelectedFilter'" : "") + " onclick='vgap.dash.showPlanets(2);'>Notes View</li><li " + (view == 3 ? "class='SelectedFilter'" : "") + " onclick='vgap.dash.showPlanets(3);'>What's Interesting</li></ul>";

        //loop through all planets and show the ones owned by this player
        html += "<div class='DashPane' style='height:" + ($("#DashboardContent").height() - 30) + "px;'>";

        html += "<table id='PlanetTable' border='1' frame='void'  rules='rows' align='left' width='100%' style='cursor:pointer;'><thead>";
        html += "<th></th><th align='left'>Id</th><th align='left'>Name</th>";
        if (view == 1)
            html += "<th title='Megacredits' align='left'>MC</th><th title='Supplies' align='left'>S</th><th title='Neutronium' align='left'>N</th><th title='Duranium' align='left'>D</th><th title='Tritanium' align='left'>T</th><th title='Molybdenum' align='left'>M</th><th title='Ground Neutronium (unmined)' align='left'>GN</th><th title='Ground Duranium (unmined)' align='left'>GD</th><th title='Ground Tritanium (unmined)' align='left'>GT</th><th title='Ground Molybdenum (unmined)' align='left'>GM</th><th title='Neutronium Density' align='left'>DN</th><th title='Duranium Density' align='left'>DD</th><th title='Tritanium Density' align='left'>DT</th><th title='Molybdenum Density' align='left'>DM</th>";
        if ((view == 0 ) ||(view == 3))
            html += "<th title='Starbase' align='left'>SB</th><th align='left'>FC</th><th title='Temperature' align='left'>T</th><th title='Colonists' align='left'>Cols</th><th title='Colonist Tax Rate' align='left'>Tx</th><th title='Colonist Happiness' align='left'>Hp</th><th title='Colonist Happiness Change' align='left'>+/-</th><th title='Natives' align='left'>Natives</th><th title='Native Government' align='left'>Gov</th><th title='Native Population' align='left'>Pop</th><th title='Native Tax Rate' align='left'>Tx</th><th title='Native Happiness' align='left'>Hp</th><th title='Native Happiness Change' align='left'>+/-</th><th title='Ready Checkbox Status' align='left'>R</th>";
		if (view == 2)
			html += "<th title='Starbase' align='left'>SB</th><th align='left'>FC</th><th title='Colonists' align='left'>Cols</th><th title='Natives' align='left'>Natives</th><th title='Native Population' align='left'>Pop</th><th title='Notes' align='left'>Notes</th><th title='Ready Checkbox Status' align='left'>R</th>";

		
        html += "</thead><tbody>";
        for (var i = 0; i < vgap.myplanets.length; i++) {
            var planet = vgap.myplanets[i];
            //var base = vgap.getStarbase(planet.id) != null ? "X" : "";
			
			var show=0; //for what's interesting view
			var temphtml = "";
			
            temphtml += "<tr class='RowSelect' onclick='vgap.map.selectPlanet(" + planet.id + ");'><td><img class='TinyIcon' src='" + planet.img + "'/></td><td>" + planet.id + "</td><td>" + planet.name + "</td>";
            if (view ==2)
			{
				if (vgap.getStarbase(planet.id) != null)
						temphtml += "<td style='color:white' title='Planet has SB'>" + "X" + "</td>";
				else 
						temphtml += "<td>" + "" + "</td>";
				temphtml += "<td>" + planet.friendlycode + "</td><td>" + planet.clans * 100 + "</td>";
				
				if (planet.nativeclans > 0)
					temphtml += "<td>" + planet.nativeracename + "</td><td>" + planet.nativeclans * 100 + "</td>";
				else
					temphtml += "<td></td><td></td>";
				
				var note = vgap.getNote(planet.id, 1);
                    if (note != null) 
                        temphtml += '<td>' + note.body.replace(/\n/g, "<br/>") + '</td>';
                    else 
                        temphtml += '<td></td>';
					 temphtml += "<td>" + (planet.readystatus > 0 ? (planet.readystatus == 1 ? "-" : "+") : "") + "</td></tr>";
			}
			if (view == 1)
                temphtml += "<td>" + planet.megacredits + "</td><td>" + planet.supplies + "</td><td>" + planet.neutronium + "</td><td>" + planet.duranium + "</td><td>" + planet.tritanium + "</td><td>" + planet.molybdenum + "</td><td>" + planet.groundneutronium + "</td><td>" + planet.groundduranium + "</td><td>" + planet.groundtritanium + "</td><td>" + planet.groundmolybdenum + "</td><td>" + planet.densityneutronium + "</td><td>" + planet.densityduranium + "</td><td>" + planet.densitytritanium + "</td><td>" + planet.densitymolybdenum + "</td></tr>";
            if ((view == 0)||(view==3)) {
				//-------------------Star Base-------------------------
				if (vgap.getStarbase(planet.id) != null)
						temphtml += "<td style='color:white' title='Planet has SB'>" + "X" + "</td>";
				else 
					{
					var count=5;
					if ((planet.megacredits+planet.supplies)>=900) count--;
					if (planet.duranium>=120) count--;
					if (planet.tritanium>=402) count--;
					if (planet.molybdenum>=340) count--;
					if (count==1)
					{
						temphtml += "<td style='color:green' title='Planet has resources to produce SB'>" + "*" + "</td>";
						show=1;
					}
					else if (count==2)
						temphtml += "<td style='color:yellow' title='Planet is missing only one resource to produce SB'>" + "*" + "</td>";
					else if (count==3)
						temphtml += "<td style='color:red' title='Planet is missing only two resources to produce SB'>" + "*" + "</td>";
					else 
						temphtml += "<td>" + "" + "</td>";
					}
				//-------------------Star Base-------------------------
				//-------------------Dangerous FCs---------------------
				
				if (((planet.friendlycode.charAt(0)=='m') || (planet.friendlycode.charAt(0)=='M')) && ((planet.friendlycode.charAt(1)=='f') || (planet.friendlycode.charAt(1)=='F')))
					{
						temphtml += "<td style='color:red' title='WARNING: MFx Friendly Code set. This can leave minefield vulnerable to enemies'>" + planet.friendlycode + "</td>";
						show=1;
					}
				else if  (((planet.friendlycode.charAt(0)=='b') || (planet.friendlycode.charAt(0)=='B')) && ((planet.friendlycode.charAt(1)=='u') || (planet.friendlycode.charAt(1)=='U')) && ((planet.friendlycode.charAt(2)=='m') || (planet.friendlycode.charAt(2)=='M')))
					{
						temphtml += "<td style='color:yellow' title='WARNING: BUM Friendly Code set. This will beam up money to all ships in orbit'>" + planet.friendlycode + "</td>";
						show=1;
					}
				else 
					temphtml += "<td>" + planet.friendlycode + "</td>";
				//-------------------Dangerous FCs---------------------
				//-------------------Dangerous Temps-------------------
				if (planet.temp<15)	temphtml += "<td style='color:aqua' title='Planet is Arctic temperature'>" + planet.temp + "</td>";
				else if (planet.temp>84)	temphtml += "<td style='color:red' title='Planet is Desert temperature'>" + planet.temp + "</td>";
				else  temphtml += "<td>" + planet.temp + "</td>";
				//-------------------Dangerous Temps-------------------
				temphtml +="<td>" + planet.clans * 100 + "</td><td>" + planet.colonisttaxrate + "</td>";
				//-------------------Unhappy Colonists---------------------
				if (((planet.colonisthappypoints<70)&&(planet.colhappychange < 0)) || (planet.colonisthappypoints<40)) show=1;
				if (planet.colonisthappypoints<40)
					temphtml += "<td style='color:red' title='Colonists are destroying the planet!'>" + planet.colonisthappypoints + "</td>";
				else if (planet.colonisthappypoints<70)
					temphtml += "<td style='color:yellow' title='Colonists are getting dangerously unhappy, and will no longer grow in population'>" + planet.colonisthappypoints + "</td>";
				else
				//-------------------Unhappy Colonists---------------------	
					temphtml += "<td>" + planet.colonisthappypoints + "</td>";
				temphtml += "<td" + (planet.colhappychange < 0 ? " class='WarnText' " : "") + ">" + planet.colhappychange + "</td>";
                if (planet.nativeclans > 0)
				{
					temphtml += "<td>" + planet.nativeracename + "</td><td>" + planet.nativegovernmentname + "</td><td>" + planet.nativeclans * 100 + "</td><td>" + planet.nativetaxrate + "</td>";
					//-------------------Unhappy Natives---------------------	
					if (((planet.nativehappypoints<70)&&(planet.nativehappychange<0)) || (planet.nativehappypoints<40)) show=1;
					if (planet.nativehappypoints<40)
						temphtml += "<td style='color:red' title='Natives are destroying the planet!'>" + planet.nativehappypoints + "</td>";
					if (planet.nativehappypoints<70)
						temphtml += "<td style='color:yellow' title='Natives are getting dangerously unhappy, and will no longer grow in population'>" + planet.nativehappypoints + "</td>";
					else
					//-------------------Unhappy Natives---------------------	
						temphtml += "<td>" + planet.nativehappypoints + "</td>";
					temphtml += "<td" + (planet.nativehappychange < 0 ? " class='WarnText' " : "") + ">" + planet.nativehappychange + "</td>";

				}
				else
                    temphtml += "<td></td><td></td><td></td><td></td><td></td><td></td>";
                temphtml += "<td>" + (planet.readystatus > 0 ? (planet.readystatus == 1 ? "-" : "+") : "") + "</td></tr>";
            }
		if ((view!=3)||(show==1))
				html+=temphtml;   
        }
        html += "</tbody></table>";
        html += "</div>";
        this.pane = $(html).appendTo(this.content);
        //this.content.fadeIn();
        $("#PlanetTable").tablesorter();
        this.pane.jScrollPane();


        // vgap.action added for the assistant (Alex):
        vgap.CurrentView = "showPlanets";
        vgap.showPlanetsViewed = 1;
        vgap.action();
	}
else
	{
	vgap.playSound("button");

        vgap.closeSecond();
        this.content.empty();

        //filter messages
        var html = "";

        if (!view)
            view = 0;

        var filterMenu = $("<ul class='FilterMenu'></ul>").appendTo(this.content);
        $("<li " + (view == 0 ? "class='SelectedFilter'" : "") + ">Colony View</li>").tclick(function() { vgap.dash.showPlanets(0); }).appendTo(filterMenu);
        $("<li " + (view == 1 ? "class='SelectedFilter'" : "") + ">Resource View</li>").tclick(function() { vgap.dash.showPlanets(1); }).appendTo(filterMenu);
		$("<li " + (view == 2 ? "class='SelectedFilter'" : "") + ">Notes View</li>").tclick(function() { vgap.dash.showPlanets(2); }).appendTo(filterMenu);
		$("<li " + (view == 3 ? "class='SelectedFilter'" : "") + ">What's Interesting</li>").tclick(function() { vgap.dash.showPlanets(3); }).appendTo(filterMenu);
		
        //loop through all planets and show the ones owned by this player
        html = "<div class='DashPane' style='height:" + ($("#DashboardContent").height() - 70) + "px;'>";

        html += "<table id='PlanetTable' align='left' class='CleanTable' border='0' width='100%' style='cursor:pointer;'><thead>";
        html += "<th></th><th align='left'>Id</th><th align='left'>Name</th>";
        if (view == 1)
            html += "<th title='Megacredits' align='left'>MC</th><th title='Supplies' align='left'>S</th><th title='Neutronium' align='left'>N</th><th title='Duranium' align='left'>D</th><th title='Tritanium' align='left'>T</th><th title='Molybdenum' align='left'>M</th><th title='Ground Neutronium (unmined)' align='left'>GN</th><th title='Ground Duranium (unmined)' align='left'>GD</th><th title='Ground Tritanium (unmined)' align='left'>GT</th><th title='Ground Molybdenum (unmined)' align='left'>GM</th><th title='Neutronium Density' align='left'>DN</th><th title='Duranium Density' align='left'>DD</th><th title='Tritanium Density' align='left'>DT</th><th title='Molybdenum Density' align='left'>DM</th>";
        if ((view == 0)||(view==3))
            html += "<th title='Starbase' align='left'>SB</th><th align='left' class=\"{sorter: 'text'}\">FC</th><th title='Temperature' align='left'>T</th><th title='Colonists' align='left'>Cols</th><th title='Colonist Tax Rate' align='left'>Tx</th><th title='Colonist Happiness' align='left'>Hp</th><th title='Colonist Happiness Change' align='left'>+/-</th><th title='Natives' align='left'>Natives</th><th title='Native Government' align='left'>Gov</th><th title='Native Population' align='left'>Pop</th><th title='Native Tax Rate' align='left'>Tx</th><th title='Native Happiness' align='left'>Hp</th><th title='Native Happiness Change' align='left'>+/-</th><th title='Ready Checkbox Status' align='left'>R</th>";
		if (view==2)
			html += "<th title='Starbase' align='left'>SB</th><th align='left' class=\"{sorter: 'text'}\">FC</th><th title='Colonists' align='left'>Cols</th><th title='Natives' align='left'>Natives</th><th title='Native Population' align='left'>Pop</th><th title='Notes' align='left'>Notes</th><th title='Ready Checkbox Status' align='left'>R</th>";

        html += "</thead><tbody id='PlanetRows'></tbody></table></div>";

        this.pane = $(html).appendTo(this.content);

        for (var i = 0; i < vgap.myplanets.length; i++) {
            var planet = vgap.myplanets[i];
            //var base = vgap.getStarbase(planet.id) != null ? "X" : "";
			var base;
			var show=0; //for what's interesting view
            var temphtml="";
			temphtml += "<tr class='RowSelect'><td><img class='TinyIcon' src='" + planet.img + "'/></td><td>" + planet.id + "</td><td>" + planet.name + "</td>";
            if (view == 1)
                temphtml += "<td>" + planet.megacredits + "</td><td>" + planet.supplies + "</td><td>" + planet.neutronium + "</td><td>" + planet.duranium + "</td><td>" + planet.tritanium + "</td><td>" + planet.molybdenum + "</td><td>" + planet.groundneutronium + "</td><td>" + planet.groundduranium + "</td><td>" + planet.groundtritanium + "</td><td>" + planet.groundmolybdenum + "</td><td>" + planet.densityneutronium + "</td><td>" + planet.densityduranium + "</td><td>" + planet.densitytritanium + "</td><td>" + planet.densitymolybdenum + "</td></tr>";
            if (view ==2)
			{
				if (vgap.getStarbase(planet.id) != null)
						temphtml += "<td style='color:white' title='Planet has SB'>" + "X" + "</td>";
				else 
						temphtml += "<td>" + "" + "</td>";
				temphtml += "<td>" + planet.friendlycode + "</td><td>" + planet.clans * 100 + "</td>";
				
				if (planet.nativeclans > 0)
					temphtml += "<td>" + planet.nativeracename + "</td><td>" + planet.nativeclans * 100 + "</td>";
				else
					temphtml += "<td></td><td></td>";
				
				var note = vgap.getNote(planet.id, 1);
                    if (note != null) 
                        temphtml += '<td>' + note.body.replace(/\n/g, "<br/>") + '</td>';
                    else 
                        temphtml += '<td></td>';
					 temphtml += "<td>" + (planet.readystatus > 0 ? (planet.readystatus == 1 ? "-" : "+") : "") + "</td></tr>";
			}
		   if ((view == 0)||(view==3)) {
				//-------------------Star Base-------------------------
				if (vgap.getStarbase(planet.id) != null)
						temphtml += "<td style='color:white' title='Planet has SB'>" + "X" + "</td>";
				else 
					{
					var count=5;
					if ((planet.megacredits+planet.supplies)>=900) count--;
					if (planet.duranium>=120) count--;
					if (planet.tritanium>=402) count--;
					if (planet.molybdenum>=340) count--;
					if (count==1)
					{
						temphtml += "<td style='color:green' title='Planet has resources to produce SB'>" + "*" + "</td>";
						show=1;
					}
					else if (count==2)
						temphtml += "<td style='color:yellow' title='Planet is missing only one resource to produce SB'>" + "*" + "</td>";
					else if (count==3)
						temphtml += "<td style='color:red' title='Planet is missing only two resources to produce SB'>" + "*" + "</td>";
					else 
						temphtml += "<td>" + "" + "</td>";
					}
				//-------------------Star Base-------------------------
				//-------------------Dangerous FCs---------------------
				
				if (((planet.friendlycode.charAt(0)=='m') || (planet.friendlycode.charAt(0)=='M')) && ((planet.friendlycode.charAt(1)=='f') || (planet.friendlycode.charAt(1)=='F')))
					{
						temphtml += "<td style='color:red' title='WARNING: MFx Friendly Code set. This can leave minefield vulnerable to enemies'>" + planet.friendlycode + "</td>";
						show=1;
					}
				else if  (((planet.friendlycode.charAt(0)=='b') || (planet.friendlycode.charAt(0)=='B')) && ((planet.friendlycode.charAt(1)=='u') || (planet.friendlycode.charAt(1)=='U')) && ((planet.friendlycode.charAt(2)=='m') || (planet.friendlycode.charAt(2)=='M')))
					{
						temphtml += "<td style='color:yellow' title='WARNING: BUM Friendly Code set. This will beam up money to all ships in orbit'>" + planet.friendlycode + "</td>";
						show=1;
					}
				else 
					temphtml += "<td>" + planet.friendlycode + "</td>";
				//-------------------Dangerous FCs---------------------
			    //-------------------Dangerous Temps-------------------
				if (planet.temp<15)	temphtml += "<td style='color:aqua' title='Planet is Arctic temperature'>" + planet.temp + "</td>";
				else if (planet.temp>84)	temphtml += "<td style='color:red' title='Planet is Desert temperature'>" + planet.temp + "</td>";
				else  temphtml += "<td>" + planet.temp + "</td>";
				//-------------------Dangerous Temps-------------------
				temphtml +="<td>" + planet.clans * 100 + "</td><td>" + planet.colonisttaxrate + "</td>";
				//-------------------Unhappy Colonists---------------------
				if (((planet.colonisthappypoints<70)&&(planet.colhappychange < 0)) || (planet.colonisthappypoints<40)) show=1;
				if (planet.colonisthappypoints<40)
					temphtml += "<td style='color:red' title='Colonists are destroying the planet!'>" + planet.colonisthappypoints + "</td>";
				else if (planet.colonisthappypoints<70)
					temphtml += "<td style='color:yellow' title='Colonists are getting dangerously unhappy, and will no longer grow in population'>" + planet.colonisthappypoints + "</td>";
				else
				//-------------------Unhappy Colonists---------------------	
					temphtml += "<td>" + planet.colonisthappypoints + "</td>";
				temphtml += "<td" + (planet.colhappychange < 0 ? " class='WarnText' " : "") + ">" + planet.colhappychange + "</td>";
                if (planet.nativeclans > 0)
				{
					temphtml += "<td>" + planet.nativeracename + "</td><td>" + planet.nativegovernmentname + "</td><td>" + planet.nativeclans * 100 + "</td><td>" + planet.nativetaxrate + "</td>";
					//-------------------Unhappy Natives---------------------	
					if (((planet.nativehappypoints<70)&&(planet.nativehappychange<0)) || (planet.nativehappypoints<40)) show=1;
					if (planet.nativehappypoints<40)
						temphtml += "<td style='color:red' title='Natives are destroying the planet!'>" + planet.nativehappypoints + "</td>";
					if (planet.nativehappypoints<70)
						temphtml += "<td style='color:yellow' title='Natives are getting dangerously unhappy, and will no longer grow in population'>" + planet.nativehappypoints + "</td>";
					else
					//-------------------Unhappy Natives---------------------	
						temphtml += "<td>" + planet.nativehappypoints + "</td>";
					temphtml += "<td" + (planet.nativehappychange < 0 ? " class='WarnText' " : "") + ">" + planet.nativehappychange + "</td>";

				}
				else
                    temphtml += "<td></td><td></td><td></td><td></td><td></td><td></td>";
                temphtml += "<td>" + (planet.readystatus > 0 ? (planet.readystatus == 1 ? "-" : "+") : "") + "</td></tr>";
            }
			if ((view!=3)||(show==1))
			{
				var select = function(id) { return function() { vgap.map.selectPlanet(id); }; };
				$(temphtml).click(select(planet.id)).appendTo("#PlanetRows");
			}
        }
        
        //this.content.fadeIn();
        $("#PlanetTable").tablesorter();
        this.pane.jScrollPane();

        // vgap.action added for the assistant (Alex):
        vgap.CurrentView = "showPlanets";
        vgap.showPlanetsViewed = 1;
	}
};
	
} //wrapper for injection

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

document.body.appendChild(script);