Coordinator

Small fleet utility to increase effective

目前為 2015-11-21 提交的版本,檢視 最新版本

// ==UserScript==
// @name        Coordinator
// @namespace   bitbucket.org/Odahviing
// @description Small fleet utility to increase effective
// @include     http://www.war-facts.com/fleet.php?fleet=*
// @include     http://www.war-facts.com/fleet/*
// @version     1.1
// @grant       none
// ==/UserScript==

/* Has a collision with next explorer script */

// Version 1.0 - Basic version - will make it much bigger
// Version 1.1 - Added random cords generator

window.setTimeout(main,100); // For loading issues


function coordCopy()
{
  // Get cords and copy
  var lines = document.getElementsByClassName('light tbborder padding5');
  var ahref = lines[5].getElementsByTagName('a');
  var change = document.getElementById('textcoords').value;
  var coords = ahref[0].innerHTML.substring(0, ahref[0].innerHTML.indexOf('g')-2);  
  if (change == "")
  {
    document.getElementById('xyz').value=coords;  
  }
  else
  {
    var eachCoord = coords.replace(",","").replace(",","").split(' ');
    
    var xCoord = parseInt(eachCoord[0]);
    var yCoord = parseInt(eachCoord[1]);
    var zCoord = parseInt(eachCoord[2]);
    
    var amountChange = parseInt(change);
    var xChange = Math.ceil(amountChange);
    var yChange = Math.floor(amountChange);
    var zChange = yChange;
    
    xCoord += Math.round((2 * Math.random() - 1) * xChange);
    
    yCoord += Math.round((2 * Math.random() - 1) * yChange);
    zCoord += Math.round((2 * Math.random() - 1) * zChange);
    
    document.getElementById('xyz').value= xCoord + ", " + yCoord + ", " + zCoord;
    
  }
}

function main()
{
  // Make New Button
  var newButton = document.createElement('input');
  newButton.setAttribute("class", "submit darkbutton");
  newButton.setAttribute("type", "button");
  newButton.setAttribute("id", "buttoncopy");
  newButton.setAttribute("value", "Current");
  newButton.addEventListener("click", coordCopy, false);
  
  var newLine = document.createElement('input');
  newLine.setAttribute("class", "darkinput text");
  newLine.setAttribute("style", "width: 80px;");
  newLine.setAttribute("type", "text");
  newLine.setAttribute("id", "textcoords");
  newLine.setAttribute("value", "");
  
  // Attach Button
  var coordLine = document.getElementById('mCoordinates');
  coordLine.appendChild(newButton); 
  coordLine.appendChild(newLine);
 
  
}