Greasy Fork is available in English.

Efficiency Stat Script

Shows efficiency (attack per piece + downstack per piece)

Verze ze dne 05. 04. 2020. Zobrazit nejnovější verzi.

  1. // ==UserScript==
  2. // @name Efficiency Stat Script
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.3.2
  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. STAT_POS = 970;
  20. STAT_NAME = "Eff"
  21.  
  22. STAT_POS2 = 1000;
  23. STAT_NAME2 = "VS"
  24.  
  25. enable_playing = true
  26. enable_replay = true
  27. enable_vsscore = true
  28.  
  29. var trim=a=>{a=a.slice(0,-1);a=a.substr(a.indexOf("{")+1);return a}
  30. var getParams=a=>{var params=a.slice(a.indexOf("(")+1);params=params.substr(0,params.indexOf(")")).split(",");return params}
  31.  
  32. x = true
  33.  
  34. function afterPlaceBlock() {
  35. if(this.clock == 0 && x){
  36. GameCore['downstack'] += (currentGarbage - (JSON.stringify(this.matrix).split(8).length-1)/9)
  37. cat = this["v"]["kppElement"].id.slice(-1)
  38. pieces = this['placedBlocks']
  39. APP = this["gamedata"]["attack"] / pieces
  40. DPP = GameCore['downstack'] / pieces
  41. EFF = (APP + DPP)
  42. time = this['actions'][this['ptr']]["t"]
  43. GameCore[STAT_NAME + "Timestamps"+cat] = GameCore[STAT_NAME + "Timestamps"+cat] || []
  44. GameCore[STAT_NAME + "Timestamps"+cat].push([(EFF).toFixed(2), time])
  45.  
  46. } else {
  47. x = false;
  48. GameCore['downstack'] = 0;
  49. ["1","2","P"].map(y=>{
  50. stat = GameCore[STAT_NAME + "Timestamps" + y]
  51. if(stat){
  52. if(stat[stat.length-1][1] < stat[stat.length-2][1]){
  53. stat[stat.length-1][1] = stat[stat.length-2][1]
  54. }
  55. }
  56. })
  57. }
  58.  
  59. }
  60.  
  61. function afterCheckLineClears() {
  62. GameCore['downstack'] += (currentGarbage - (JSON.stringify(this.matrix).split(8).length-1)/9)
  63. pieces = this["GameStats"]["stats"]["BLOCKS"].value
  64. APP = this["gamedata"]["attack"] / pieces
  65. DPP = GameCore['downstack'] / pieces
  66. if(enable_vsscore){
  67. PPS = this['getPPS']()
  68. if(this['GameStats'].get('VS'))this['GameStats'].get('VS').set(((APP + DPP)*PPS).toFixed(2));
  69. }
  70. if(this['GameStats'].get('EFF'))this['GameStats'].get('EFF').set((APP + DPP).toFixed(2));
  71. }
  72.  
  73. function beforeCheckLineClears() {
  74. window.currentGarbage = (JSON.stringify(this.matrix).split(8).length-1)/9;
  75. }
  76.  
  77. if(enable_playing | enable_replay){
  78. var checkLineClearsFunc = GameCore['prototype']['checkLineClears'].toString()
  79. var params = getParams(checkLineClearsFunc)
  80. checkLineClearsFunc = trim(beforeCheckLineClears.toString()) + trim(checkLineClearsFunc)
  81. GameCore['prototype']['checkLineClears'] = new Function(...params, checkLineClearsFunc);
  82. }
  83.  
  84.  
  85.  
  86. if(enable_playing){
  87. if(typeof Game != "undefined"){
  88.  
  89. checkLineClearsFunc = GameCore['prototype']['checkLineClears'].toString()
  90. checkLineClearsFunc = trim(checkLineClearsFunc) + trim(afterCheckLineClears.toString())
  91. GameCore['prototype']['checkLineClears'] = new Function(...params, checkLineClearsFunc);
  92.  
  93. var readyGoFunc = Game['prototype']["startReadyGo"].toString()
  94. readyGoFunc = `
  95. GameCore['downstack']=0;
  96. this['GameStats'].addStat(new StatLine('EFF', '`+STAT_NAME+`', `+STAT_POS+`),true);
  97. this['GameStats'].addStat(new StatLine('VS', '`+STAT_NAME2+`', `+STAT_POS2+`),true);` + trim(readyGoFunc)
  98. Game['prototype']["startReadyGo"] = new Function(readyGoFunc);
  99.  
  100. }
  101. }
  102.  
  103.  
  104. if(enable_replay){
  105.  
  106. var website = "jstris.jezevec10.com"
  107. var url = window.location.href
  108. var parts = url.split("/")
  109.  
  110. if(typeof Replayer != "undefined"){
  111. Replayer["addStat"] = function(id,into,name) {
  112. var newStat = document.createElement("tr");
  113. newStat.innerHTML = '<td class="ter">'+name+'</td><td class="sval"><span id="'+id+'">0</span></td>'
  114. into.appendChild(newStat);
  115. }
  116. }
  117.  
  118. if(parts[3]=="replay" && parts[2].endsWith(website) && parts.length>4){
  119.  
  120. GameCore['downstack'] = 0
  121. var placeBlockFunc = GameCore['prototype']['placeBlock'].toString()
  122. var params2 = getParams(placeBlockFunc)
  123. placeBlockFunc = trim(placeBlockFunc) + trim(afterPlaceBlock.toString())
  124. GameCore['prototype']['placeBlock'] = new Function(...params2, placeBlockFunc);
  125.  
  126. if(parts[4]=="1v1"){
  127. Replayer["addStat"](STAT_NAME+"Element1",document.getElementsByTagName("tbody")[0],STAT_NAME)
  128. Replayer["addStat"](STAT_NAME+"Element2",document.getElementsByTagName("tbody")[2],STAT_NAME)
  129.  
  130. if(enable_vsscore){
  131. Replayer["addStat"](STAT_NAME2+"Element1",document.getElementsByTagName("tbody")[0],STAT_NAME2)
  132. Replayer["addStat"](STAT_NAME2+"Element2",document.getElementsByTagName("tbody")[2],STAT_NAME2)
  133. }
  134. } else {
  135. Replayer["addStat"](STAT_NAME+"ElementP",document.getElementsByClassName("moreStats")[0])
  136. if(enable_vsscore){
  137. Replayer["addStat"](STAT_NAME2+"ElementP",document.getElementsByClassName("moreStats")[0])
  138. }
  139. }
  140.  
  141. Replayer['prototype']['getStat'] = function(cat) {
  142. if(stamps=GameCore[STAT_NAME+"Timestamps"+cat]){
  143. for (var i = 1; i < stamps.length; i++) {
  144. if(stamps[i][1]>this['clock']){
  145. return stamps[i-1][0]
  146. }
  147. }
  148. return stamps[stamps.length-1][0]
  149. }
  150. return 0
  151. };
  152.  
  153. var oldTextBar = View.prototype.updateTextBar.toString();
  154. oldTextBar = trim(oldTextBar) + `;
  155. var cat = this.kppElement.id.slice(-1);
  156. eval("`+STAT_NAME+`Element"+cat+"&&(`+STAT_NAME+`Element"+cat+".innerHTML = this.g.getStat(cat))");
  157. if(enable_vsscore){
  158. eval("`+STAT_NAME2+`Element"+cat+"&&(`+STAT_NAME2+`Element"+cat+".innerHTML = ($('#PPS'+cat)[0].innerHTML*this.g.getStat(cat)).toFixed(2))");
  159. }`
  160. View.prototype.updateTextBar = new Function(oldTextBar);
  161.  
  162. }
  163. }
  164.  
  165. });
  166. })();
  167.