Coordinator

Small fleet utility to increase effective

当前为 2015-11-21 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Coordinator
  3. // @namespace bitbucket.org/Odahviing
  4. // @description Small fleet utility to increase effective
  5. // @include http://www.war-facts.com/fleet.php?fleet=*
  6. // @include http://www.war-facts.com/fleet/*
  7. // @version 1.2
  8. // @grant none
  9. // ==/UserScript==
  10.  
  11.  
  12. // Version 1.0 - Basic version - will make it much bigger
  13. // Version 1.1 - Added random cords generator
  14. // Version 1.2 - Limiting Z axi + Fix issue with "next explorer script"
  15.  
  16. window.setTimeout(main,500); // For loading issues
  17.  
  18.  
  19. function coordCopy()
  20. {
  21. // Get cords and copy
  22. var lines = document.getElementsByClassName('light tbborder padding5');
  23. var ahref = lines[5].getElementsByTagName('a');
  24. var change = document.getElementById('textcoords').value;
  25. var coords = ahref[0].innerHTML.substring(0, ahref[0].innerHTML.indexOf('g')-1);
  26. if (change == "")
  27. {
  28. document.getElementById('xyz').value=coords;
  29. }
  30. else
  31. {
  32. var eachCoord = coords.replace(",","").replace(",","").split(' ');
  33. var xCoord = parseInt(eachCoord[0]);
  34. var yCoord = parseInt(eachCoord[1]);
  35. var zCoord = parseInt(eachCoord[2]);
  36. var amountChange = parseInt(change);
  37. if (amountChange > 15000)
  38. {
  39. var zChange = 5000;
  40. amountChange -= zChange;
  41. var xChange = Math.ceil(amountChange / 2);
  42. var yChange = Math.floor(amountChange / 2);
  43. }
  44. else
  45. {
  46. var zChange = Math.floor(amountChange /3);
  47. var xChange = Math.ceil(amountChange / 3);
  48. var yChange = Math.floor(amountChange / 3);
  49. }
  50.  
  51. xCoord += Math.round((2 * Math.random() - 1) * xChange);
  52. yCoord += Math.round((2 * Math.random() - 1) * yChange);
  53. zCoord += Math.round((2 * Math.random() - 1) * zChange);
  54. document.getElementById('xyz').value= xCoord + ", " + yCoord + ", " + zCoord;
  55. }
  56. }
  57.  
  58. function main()
  59. {
  60. // Make New Button
  61. var newButton = document.createElement('input');
  62. newButton.setAttribute("class", "submit darkbutton");
  63. newButton.setAttribute("type", "button");
  64. newButton.setAttribute("id", "buttoncopy");
  65. newButton.setAttribute("value", "Current");
  66. newButton.addEventListener("click", coordCopy, false);
  67. var newLine = document.createElement('input');
  68. newLine.setAttribute("class", "darkinput text");
  69. newLine.setAttribute("style", "width: 80px;");
  70. newLine.setAttribute("type", "text");
  71. newLine.setAttribute("id", "textcoords");
  72. newLine.setAttribute("value", "");
  73. // Attach Button
  74. var coordLine = document.getElementById('mCoordinates');
  75. coordLine.appendChild(newButton);
  76. coordLine.appendChild(newLine);
  77. }
  78.  
  79.