TopCoder Marathn Match Score Complement UserScript

show "1000000 - Score" instead of "Score"

  1. // ==UserScript==
  2. // @name TopCoder Marathn Match Score Complement UserScript
  3. // @namespace https://github.com/kmyk
  4. // @version 1.0
  5. // @description show "1000000 - Score" instead of "Score"
  6. // @author Kimiyuki Onaka
  7. // @match *://community.topcoder.com/longcontest/?*module=ViewStandings*
  8. // ==/UserScript==
  9. function main() {
  10. const table = document.getElementsByClassName("statTable")[0];
  11. const rows = table.getElementsByTagName('tr');
  12. const th = rows[1].getElementsByTagName('td');
  13. let x = 0;
  14. while (th[x].textContent.trim() != "Score")
  15. x += 1;
  16. th[x].textContent = "1000000 - " + th[x].textContent;
  17. for (let y = 2; y < rows.length; ++y) {
  18. const td = rows[y].getElementsByTagName('td')[x];
  19. td.textContent = (1000000 - parseFloat(td.textContent)).toFixed(2);
  20. }
  21. }
  22. main();