Efficiency Stat Script

Shows efficiency (attack per piece + downstack per piece)

2020-04-04 기준 버전입니다. 최신 버전을 확인하세요.

  1. // ==UserScript==
  2. // @name Efficiency Stat Script
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.1
  5. // @description Shows efficiency (attack per piece + downstack per piece)
  6. // @author Oki
  7. // @match https://*.jstris.jezevec10.com/*
  8. // @grant none
  9. // ==/UserScript==
  10.  
  11. /**************************
  12. Efficiency Stat Script
  13. **************************/
  14.  
  15.  
  16. (function() {
  17. window.addEventListener('load', function(){
  18.  
  19. var STAT_POS = 970;
  20. var STAT_NAME = "Eff"
  21. var enable_playing = true
  22. var enable_replay = true
  23.  
  24.  
  25. var trim=a=>{a=a.slice(0,-1);a=a.substr(a.indexOf("{")+1);return a}
  26. var getParams=a=>{var params=a.slice(a.indexOf("(")+1);params=params.substr(0,params.indexOf(")")).split(",");return params}
  27.  
  28. var x = true
  29.  
  30. function afterPlaceBlock() {
  31. if(this.clock == 0 && x){
  32. cat = this["v"]["kppElement"].id.slice(-1)
  33. pieces = this['placedBlocks']
  34. APP = this["gamedata"]["attack"] / pieces
  35. DPP = this["gamedata"]["lines"] / pieces
  36. GameCore[STAT_NAME + "Timestamps"+cat] = GameCore[STAT_NAME + "Timestamps"+cat] || []
  37. GameCore[STAT_NAME + "Timestamps"+cat].push([(APP + DPP).toFixed(2), this['actions'][this['ptr']]["t"]])
  38. } else {
  39. x = false
  40. }
  41. }
  42.  
  43. function afterCheckLineClears() {
  44. pieces = this["GameStats"]["stats"]["BLOCKS"].value
  45. APP = this["gamedata"]["attack"] / pieces
  46. DPP = this["gamedata"]["lines"] / pieces
  47. if(this['GameStats'].get('EFF'))this['GameStats'].get('EFF').set((APP + DPP).toFixed(2));
  48. }
  49.  
  50.  
  51.  
  52. if(enable_playing){
  53. if(typeof Game != "undefined"){
  54.  
  55. var checkLineClearsFunc = GameCore['prototype']['checkLineClears'].toString()
  56. var params = getParams(checkLineClearsFunc)
  57. checkLineClearsFunc = trim(checkLineClearsFunc) + trim(afterCheckLineClears.toString())
  58. GameCore['prototype']['checkLineClears'] = new Function(...params, checkLineClearsFunc);
  59.  
  60. var readyGoFunc = Game['prototype']["startReadyGo"].toString()
  61. readyGoFunc = "EFFStat=0;this['GameStats'].addStat(new StatLine('EFF', '"+STAT_NAME+"', "+STAT_POS+"),true);" + trim(readyGoFunc)
  62. Game['prototype']["startReadyGo"] = new Function(readyGoFunc);
  63.  
  64. }
  65. }
  66.  
  67.  
  68. if(enable_replay){
  69.  
  70. var website = "jstris.jezevec10.com"
  71. var url = window.location.href
  72. var parts = url.split("/")
  73.  
  74. if(typeof Replayer != "undefined"){
  75. Replayer["addStat"] = function(id,into) {
  76. var newStat = document.createElement("tr");
  77. newStat.innerHTML = '<td class="ter">'+STAT_NAME+'</td><td class="sval"><span id="'+id+'">0</span></td>'
  78. into.appendChild(newStat);
  79. }
  80. }
  81.  
  82. if(parts[3]=="replay" && parts[2].endsWith(website) && parts.length>4){
  83.  
  84.  
  85. var placeBlockFunc = GameCore['prototype']['placeBlock'].toString()
  86. var params2 = getParams(placeBlockFunc)
  87. placeBlockFunc = trim(placeBlockFunc) + trim(afterPlaceBlock.toString())
  88. GameCore['prototype']['placeBlock'] = new Function(...params2, placeBlockFunc);
  89.  
  90. if(parts[4]=="1v1"){
  91. Replayer["addStat"](STAT_NAME+"Element1",document.getElementsByTagName("tbody")[0])
  92. Replayer["addStat"](STAT_NAME+"Element2",document.getElementsByTagName("tbody")[2])
  93.  
  94. } else {
  95. Replayer["addStat"](STAT_NAME+"ElementP",document.getElementsByClassName("moreStats")[0])
  96. }
  97.  
  98. Replayer['prototype']['getStat'] = function(cat) {
  99. if(stamps=GameCore[STAT_NAME+"Timestamps"+cat]){
  100. for (var i = 1; i < stamps.length; i++) {
  101. if(stamps[i][1]>this['clock']){
  102. return stamps[i-1][0]
  103. }
  104. }
  105. return stamps[stamps.length-1][0]
  106. }
  107. return 0
  108. };
  109.  
  110. var oldTextBar = View.prototype.updateTextBar.toString();
  111. oldTextBar = trim(oldTextBar) + ';var cat = this.kppElement.id.slice(-1);eval("'+STAT_NAME+'Element"+cat+"&&('+STAT_NAME+'Element"+cat+".innerHTML = this.g.getStat(cat))");'
  112. View.prototype.updateTextBar = new Function(oldTextBar);
  113.  
  114. }
  115. }
  116.  
  117. });
  118. })();