Greasy Fork is available in English.

Efficiency Stat Script

Shows efficiency (attack per piece + downstack per piece)

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