IntelligenceAutoSetup

Small script to auto-chose settings for AR planets

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

  1. // ==UserScript==
  2. // @name IntelligenceAutoSetup
  3. // @namespace Cohanman.Resources
  4. // @include http://*.war-facts.com/intelligence.php
  5. // @include http://*.war-facts.com/empire_known_universe.php
  6. // @description Small script to auto-chose settings for AR planets
  7. // @version 1.1
  8. // @grant none
  9. // ==/UserScript==
  10.  
  11. // Version 1.0 - Initial Version, set 35b, 50% AR planets
  12. // Version 1.1 - Remove already colonized planets
  13.  
  14. function removeColonies()
  15. {
  16. var mainTable = document.getElementsByTagName('table');
  17. var allColonies = mainTable[0].rows;
  18. var removeRows = []
  19. for (index = 1; index <allColonies.length ; index = index + 2)
  20. {
  21. var innerTableRow = allColonies[index].getElementsByTagName('table')[0].rows[0];
  22. var cell = innerTableRow.cells[1];
  23. if (cell.innerHTML != '&nbsp;')
  24. {
  25. removeRows.push(index-1);
  26. removeRows.push(index);
  27. }
  28. }
  29. for (index = removeRows.length -1; index >=0; index --)
  30. mainTable[0].deleteRow(removeRows[index]);
  31. }
  32.  
  33. function makeButton()
  34. {
  35. var row = document.getElementsByClassName('light padding5 tbborder');
  36. row[0].innerHTML = row[0].innerHTML + "<input type='button' class='darkbutton' id='btn' value='Remove Colonies'>";
  37. var button = document.getElementById('btn');
  38. button.addEventListener("click", removeColonies, false);
  39. }
  40.  
  41. function setupPlanet()
  42. {
  43.  
  44.  
  45. $('[name=habit]').val(50);
  46. $('[name=landmass]').val(35000000000);
  47. $('[name=orderType]').val("land");
  48. $('[name=orderDirection]').val("desc");
  49. $('[name=ressel]').val(1);
  50. var allBoxes = $("input[type=checkbox]");
  51. $.each(allBoxes, function( index, value )
  52. {
  53. var checkBox = value;
  54. if (checkBox.name == "colonized") return true; // On empire page, we had extra checkBox
  55. checkBox.checked = true;
  56. });
  57. }
  58.  
  59. makeButton();
  60. setupPlanet();
  61.