HOF Warbase Helper

Highlights potential war targets in green on HOF page

  1. // ==UserScript==
  2. // @name HOF Warbase Helper
  3. // @namespace namespace
  4. // @version 0.2
  5. // @description Highlights potential war targets in green on HOF page
  6. // @author tos
  7. // @match *.torn.com/halloffame.php*
  8. // @grant none
  9. // ==/UserScript==
  10.  
  11. APIkey = 'APIKEY'; //API KEY HERE
  12. myFac = 'facID'; //YOUR FACTION ID HERE
  13. minFacSize = 50; //Set minimum faction size here
  14. badTargets = [myFac]; //can use commas to add more factions not to target here eg. [myfac, '23', '1028']
  15.  
  16. $.ajax({
  17. type: "GET",
  18. url: 'https://api.torn.com/faction/'+ myFac +'?selections=basic&key='+ APIkey,
  19. success: function (response) {
  20. var wars = Object.keys(response.wars);
  21. var naps = Object.keys(response.naps);
  22. var peace = Object.keys(response.peace);
  23. for(i=0; i < wars.length; i++){
  24. badTargets.push(wars[i]);
  25. }
  26. for(i=0; i < naps.length; i++){
  27. badTargets.push(naps[i]);
  28. }
  29. for(i=0; i < peace.length; i++){
  30. badTargets.push(peace[i]);
  31. }
  32. }
  33. });
  34.  
  35. const observer = new MutationObserver((mutations) => {
  36. for (const mutation of mutations) {
  37. for (const node of mutation.addedNodes) {
  38. try{
  39. if(node.className === 'hall-of-fame-wrap respect m-bottom10'){
  40. var factionList = node.querySelector('.players-list').children;
  41. for(i=0; i < factionList.length; i++){
  42. var facSize = parseInt(factionList[i].querySelector('.acc-wrap .player-info').children[0].innerText);
  43. var facID = factionList[i].querySelector('.acc-header .player-info .player').children[1].href.split('ID=')[1];
  44. if(facSize >= minFacSize && !badTargets.includes(facID)){
  45. factionList[i].style.backgroundColor = '#d7e1cc';
  46. }
  47. }
  48. }
  49. }
  50. catch(err){
  51. console.log(err);
  52. }
  53. }
  54. }
  55. });
  56. const wrapper = document.querySelector('#mainContainer .hall-of-fame-list-wrap');
  57. observer.observe(wrapper, { subtree: true, childList: true });
  58.