Script pour afficher la défense et les points flotte réels avec war riders - need help

    • Script / Add on

    This site uses cookies. By continuing to browse this site, you are agreeing to our Cookie Policy.

    • Script pour afficher la défense et les points flotte réels avec war riders - need help

      Bonjour,

      J'ai depuis des années un script (qui n'est pas de moi) qui permet d'afficher un tableau sous war riders, seulement il y a une erreur avec ce script et ça fait planter chrome :D



      La console d'erreur :

      Source Code

      1. chrome-extension://kfaofnlkooiapdmkbppmpgmjmhkolaeb/js/init.js:37 Synchronous XMLHttpRequest on the main thread is deprecated because of its detrimental effects to the end user's experience. For more help, check https://xhr.spec.whatwg.org/.
      2. (program):4 ERROR: Execution of script 'Show Fleet & Def 4 WarRiders' failed! Cannot read property 'getElementsByTagName' of null(anonymous function) @ (program):4
      3. (program):4 TypeError: Cannot read property 'getElementsByTagName' of null
      4. at readTable (eval at <anonymous> (unknown source), <anonymous>:54:57)


      PHP Source Code

      1. // ==UserScript==
      2. // @name Show Fleet & Def 4 WarRiders
      3. // @namespace http://use.i.E.your.homepage/
      4. // @version 0.1
      5. // @description enter something useful
      6. // @match http://*/*
      7. // @copyright 2012+, You
      8. // ==/UserScript==
      9. // ==UserScript==
      10. // @name War Riders Extended
      11. // @namespace forcetree
      12. // @include http://*war-riders.de/*/*/details/player/*
      13. // @include http://*war-riders.de/*/*/search/player/*
      14. // @include http://*war-riders.de/*/*/details/ally/*
      15. // @include http://*war-riders.de/*/*/search/ally/*
      16. // @include http://*ogame.gamestats.org/*/*/details/player/*
      17. // @include http://*ogame.gamestats.org/*/*/search/player/*
      18. // @include http://*ogame.gamestats.org/*/*/details/ally/*
      19. // @include http://*ogame.gamestats.org/*/*/search/ally/*
      20. // @exclude http://*war-riders.de/*/*/timecalc
      21. // @exclude http://*ogame.gamestats.org/*/*/timecalc
      22. // @exclude http://*.ogame.gameforge.com/*
      23. // @exclude http://board.fr.ogame.gameforge.com/*
      24. // ==/UserScript==
      25. readTable();
      26. function draw_chart(chartData)
      27. {
      28. var size = "400x100";
      29. var labels = "Economique sans la défense|Recherche|Flotte|Défense";
      30. var url = "http://chart.apis.google.com/chart?"
      31. + "cht=p3&"
      32. + "chl=" + labels + "&"
      33. + "chf=bg,s,efefef00&"
      34. + "chs="+ size +"&"
      35. + "chld=&"
      36. + "chco=556B2F&"
      37. + "chtt=&"
      38. + "&chd=t:" + chartData;
      39. var img = document.createElement("img");
      40. img.src = url;
      41. return img;
      42. }
      43. function readTable()
      44. {
      45. var fullTable = document.getElementById("startcontent2").getElementsByTagName("table")[0];
      46. try{
      47. var totalPoints = fullTable.getElementsByTagName("tr")[3].lastChild.textContent;
      48. var ecoPoints = fullTable.getElementsByTagName("tr")[6].lastChild.textContent;
      49. var researchPoints = fullTable.getElementsByTagName("tr")[9].lastChild.textContent;
      50. var militaryPoints = fullTable.getElementsByTagName("tr")[12].lastChild.textContent;
      51. } catch(err)
      52. {
      53. GM_log('No Table found.');
      54. return;
      55. }
      56. calculate(fullTable, totalPoints, ecoPoints, researchPoints, militaryPoints);
      57. }
      58. function calculate(fullTable, totalPoints, ecoPoints, researchPoints, militaryPoints)
      59. {
      60. totalPoints = removeDots(totalPoints);ecoPoints = removeDots(ecoPoints);researchPoints = removeDots(researchPoints);militaryPoints = removeDots(militaryPoints);
      61. defencePoints = parseInt(ecoPoints) + parseInt(researchPoints) + parseInt(militaryPoints) - parseInt(totalPoints);
      62. armadaPoints = parseInt(militaryPoints) - parseInt(defencePoints);
      63. if ((defencePoints < 0) || (armadaPoints < 0))
      64. {
      65. GM_log("Invalid value.")
      66. fullTable.parentNode.insertBefore(document.createTextNode("Invalid value."), fullTable);
      67. return
      68. }
      69. chartData = (ecoPoints-defencePoints) / totalPoints + "," + researchPoints / totalPoints + "," + armadaPoints / totalPoints + "," + defencePoints / totalPoints;
      70. indestPoints = parseInt(ecoPoints) + parseInt(researchPoints) - defencePoints;
      71. var newDiv = document.createElement("div");
      72. newDiv.appendChild(draw_chart(chartData));
      73. newDiv.appendChild(br());
      74. newDiv.appendChild(br());
      75. newDiv.appendChild(drawTable((insertDots(defencePoints) + " ("+ (defencePoints / totalPoints * 100).toFixed(1) +"%)"), (insertDots(armadaPoints) + " ("+ (armadaPoints / totalPoints * 100).toFixed(1) +"%)"), (insertDots(indestPoints)+ " ("+ (indestPoints / totalPoints * 100).toFixed(1) +"%)")));
      76. newDiv.appendChild(br());
      77. fullTable.parentNode.insertBefore(newDiv, fullTable);
      78. }
      79. function drawTable(def, armada, indest)
      80. {
      81. var newTable = document.createElement("table");
      82. newTable.className = "border";
      83. newTable.title = "Armada incl. 50% civil Ships, 50% Jumpgate, 50% Phalanx indestructible Points alike plus other lunarbased buildings";
      84. var trOne = document.createElement("tr");
      85. newTable.appendChild(trOne);
      86. trOne.appendChild( getTd("cl","Défense") );
      87. trOne.appendChild( getTd("cl","Flotte") );
      88. trOne.appendChild( getTd("cl","Indestructibles") );
      89. var trTwo = document.createElement("tr");
      90. newTable.appendChild(trTwo);
      91. trTwo.appendChild( getTd("s",def) );
      92. trTwo.appendChild( getTd("s",armada) );
      93. trTwo.appendChild( getTd("s",indest) );
      94. return newTable;
      95. }
      96. function getTd(className, text)
      97. {
      98. var newTd = document.createElement("td");
      99. newTd.appendChild(document.createTextNode(text));
      100. newTd.className = className;
      101. return newTd;
      102. }
      103. function removeDots(s)
      104. {
      105. return s.replace(/\./g, "");
      106. }
      107. function br()
      108. {
      109. return document.createElement("br");
      110. }
      111. function insertDots(n)
      112. {
      113. n= "" + n;
      114. if (n.length > 3)
      115. {
      116. var mod = n.length % 3;
      117. var output = (mod > 0 ? (n.substring(0,mod)) : "");
      118. for (i=0 ; i < Math.floor(n.length / 3); i++)
      119. {
      120. if ((mod == 0) && (i == 0))
      121. output += n.substring(mod+ 3 * i, mod + 3 * i + 3);
      122. else
      123. output+= "." + n.substring(mod + 3 * i, mod + 3 * i + 3);
      124. }
      125. return (output);
      126. }
      127. else return n;
      128. }
      Display All



      qqun saurait me dire ce qui cloche ? Et corriger, moi je n'y comprend hélas rien :(

      PS : le script bug sur les pages ogame ... pourtant il devrait pas s'y activer le bougre. Bref je patauge.


      The post was edited 1 time, last by Gonth ().