Replay Details Script

shows additional information in replays

当前为 2019-12-16 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Replay Details Script
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.21
  5. // @description shows additional information in replays
  6. // @author Oki
  7. // @match https://*.jstris.jezevec10.com/*
  8. // @grant none
  9. // ==/UserScript==
  10.  
  11. /**************************
  12. Replay Details Script
  13. **************************/
  14.  
  15. (function() {
  16. window.addEventListener('load', function(){
  17.  
  18. var repDhold=document.createElement("div");
  19. repDhold.id="repDHolder";
  20. repDhold.style.position="absolute"
  21. repDhold.style.left = (myCanvas.getBoundingClientRect().left - 500) + "px";
  22. repDhold.style.top = (myCanvas.getBoundingClientRect().top + 100) + "px";
  23. document.body.appendChild(repDhold);
  24.  
  25. var fRepD = '<style>#repDT {border-collapse:collapse;text-align:left}.repD {border:1px solid white;padding:5px}</style><table id="repDT">'
  26.  
  27. var website = "jstris.jezevec10.com"
  28. var url = window.location.href
  29. var parts = url.split("/")
  30.  
  31. if(parts[3]=="replay" && parts[2].endsWith(website)){
  32.  
  33.  
  34.  
  35. fetch("https://"+parts[2]+"/replay/data?id="+ (parts.length==6?(parts[5]+"&live=1"):(parts[4])))
  36. .then(function(response) {
  37. return response.json();
  38. })
  39. .then(function(jsonResponse) {
  40. try {
  41. var keys = Object.keys(jsonResponse.c)
  42. }
  43. catch (e) {
  44. console.log("very old replay, cant execute replay details script")
  45. keys = []
  46. }
  47.  
  48. for (var i = 0; i < keys.length; i++) {
  49. var key=keys[i]
  50. var add=[key,jsonResponse.c[key]]
  51.  
  52. if(key=="softDropId"){
  53. add[1]="Slow9Medium9Fast9Ultra9Instant".split(9)[add[1]]
  54. }
  55. if(key=="gameEnd" || key=="gameStart"){
  56. add[1]=(""+new Date(add[1])).split(" ").splice(0,5)
  57. }
  58. if(key=="v"){add[0]="version"}
  59. if(key=="bs"){add[0]="blockskin id"}
  60. if(key=="se"){add[0]="sound effects id"}
  61. if(key=="map"){add[1]="<a href='https://jstris.jezevec10.com/map/"+add[1]+"'>"+add[1]+"</a>"}
  62.  
  63. fRepD+=`<tr><td class="repD">${add[0]}</td><td class="repD">${add[1]}</td></tr>`
  64. }
  65.  
  66. repDHolder.innerHTML = fRepD+"</table>"
  67. });
  68.  
  69. }
  70.  
  71. });
  72. })();