NOTICE: By continued use of this site you understand and agree to the binding Terms of Service and Privacy Policy.
// ==UserScript== // @name Pardus Coords Addon // @namespace pardus.at // @author Yog // @version 1.0 // @license GPL-3.0-only // @description Adds coordinates around the Pardus navigation grid. For better visual experience you can use UserStyle "Pardus Style Remake 2.0" at https://userstyles.org/styles/167883 // @include *.pardus.at/main.php* // @match *.pardus.at/main.php* // ==/UserScript== // --User Options--------------------------------------------------- // Use this section to turn on/off features created by the script. // Just change from 'true' to 'false' to turn something off.. var NoPardusStyleRemakeInstalled = true; var NavGridSpacing = 0; // --end User Options----------------------------------------------- //var SectorName = document.getElementById('sector').textContent; var SpaceChart = document.getElementById('tdSpaceChart').getElementsByTagName('tr')[0]; var tilesX = parseInt(SpaceChart.nextSibling.getElementsByTagName('tr')[0].getElementsByTagName('td').length); var tilesY = parseInt(SpaceChart.nextSibling.getElementsByTagName('tr').length); var tilesXhalf = Math.floor(tilesX / 2); var tilesYhalf = Math.floor(tilesY / 2); var verticalLeft = document.createElement('div'); verticalLeft.classList.add('verticalLeft'); SpaceChart.nextSibling.getElementsByTagName('td')[0].prepend(verticalLeft); var verticalRight = document.createElement('div'); verticalRight.classList.add('verticalRight'); SpaceChart.nextSibling.getElementsByTagName('td')[0].nextSibling.nextSibling.prepend(verticalRight); var db = document.getElementById('tdStatusCoords').innerHTML; var coordX = parseInt(db.match(/\d+(?=,\d+\])/)[0]); var coordY = parseInt(db.match(/\d+(?=\])/)[0]); for(var y = 0; y < tilesY; y++) { verticalLeft.innerHTML += "<div class='coord coordsv1'>" + (coordY - tilesYhalf + y) + "</div>"; verticalRight.innerHTML += "<div class='coord coordsv2'>" + (coordY - tilesYhalf + y) + "</div>"; } if(NoPardusStyleRemakeInstalled === false) SpaceChart.getElementsByTagName('td')[1].innerHTML = ''; SpaceChart.nextSibling.nextSibling.getElementsByTagName('td')[1].innerHTML = ''; for(var x = 0; x < tilesX; x++) { SpaceChart.getElementsByTagName('td')[1].innerHTML += "<div class='coord coordsh1'>" + (coordX - Math.floor(tilesX / 2) + x) + "</div>"; SpaceChart.nextSibling.nextSibling.getElementsByTagName('td')[1].innerHTML += "<div class='coord coordsh2'>" + (coordX - Math.floor(tilesX / 2) + x) + "</div>"; } // handle partial refresh scenario function runscript() { if (unsafeWindow.checkToDo !== undefined) { var local_checkToDo = unsafeWindow.checkToDo; unsafeWindow.checkToDo = function() { local_checkToDo(); setTimeout(coordsUpdate,1); }; } coordsUpdate(); } function coordsUpdate() { var db = document.getElementById('tdStatusCoords').innerHTML; var coordX = parseInt(db.match(/\d+(?=,\d+\])/)[0]); var coordY = parseInt(db.match(/\d+(?=\])/)[0]); for(var y = 0; y < tilesY; y++) { verticalLeft.getElementsByTagName('div')[y].innerHTML = (coordY - tilesYhalf + y); verticalRight.getElementsByTagName('div')[y].innerHTML = (coordY - tilesYhalf + y); } for(var x = 0; x < tilesX; x++) { SpaceChart.getElementsByTagName('td')[1].getElementsByTagName('div')[x].innerHTML = (coordX - tilesXhalf + x); SpaceChart.nextSibling.nextSibling.getElementsByTagName('td')[1].getElementsByTagName('div')[x].innerHTML = (coordX - tilesXhalf + x); } } runscript(); // add control class when script executes document.getElementById('tdSpaceChart').classList.add('has-grid'); // grid styling with NoPardusStyleRemakeInstalled if(NoPardusStyleRemakeInstalled) { SpaceChart.nextSibling.getElementsByTagName('td')[1].style.padding = "15px"; if (document.getElementById('nav')) { document.getElementById('nav').parentNode.style.paddingRight = tilesX*NavGridSpacing + "px"; document.getElementById('nav').parentNode.style.paddingBottom = tilesY*NavGridSpacing + "px"; SpaceChart.nextSibling.getElementsByTagName('td')[1].getElementsByTagName('div')[0].style.background = "#00001c"; } (function() {var css = [ "table#navarea, table#navareatransition {", "border-spacing:" + NavGridSpacing + "px;", "}", ".has-grid .coordsh1, .has-grid .coordsh2 {", "padding-right:" + NavGridSpacing + "px;", "}", ".has-grid .coordsv1, .has-grid .coordsv2 {", "padding-bottom:" + NavGridSpacing + "px;", "}", ".coordsh1, .coordsh2 {", "position: relative;", "left: 15px;", "width: 64px;", "height: 0;", "display: inline-block;", "text-align: center;", "margin-top: -8px;", "}", ".coordsh2 {", "bottom: 19px;", "left: -15px;", "}", ".verticalLeft {", "position: relative;", "top: 8px;", "left: 12px;", "}", ".verticalRight {", "position: relative;", "top: 8px;", "left: -12px;", "}", ".coordsv1, .coordsv2 {", "line-height: 64px;", "text-align: center;", "}", ].join("\n") var node = document.createElement("style"); node.type = "text/css"; node.appendChild(document.createTextNode(css)); var heads = document.getElementsByTagName("head"); if (heads.length > 0) { heads[0].appendChild(node); } else { // no head yet, stick it whereever document.documentElement.appendChild(node); } })(); }