IntelligenceAutoSetup

Small script to auto-chose settings for AR planets

当前为 2018-08-13 提交的版本,查看 最新版本

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