Greasy Fork is available in English.

Hold Stat Script

Shows how often hold was used

  1. // ==UserScript==
  2. // @name Hold Stat Script
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.2.3
  5. // @description Shows how often hold was used
  6. // @author Oki
  7. // @match https://*.jstris.jezevec10.com/*
  8. // @grant none
  9. // ==/UserScript==
  10.  
  11. /**************************
  12. Hold Stat Script
  13. **************************/
  14.  
  15.  
  16. (function() {
  17. window.addEventListener('load', function(){
  18.  
  19. var STAT_POS = 970;
  20.  
  21. if(typeof trim != "function"){var trim=a=>{a=a.slice(0,-1);a=a.substr(a.indexOf("{")+1);return a}}
  22. var getParams=a=>{var params=a.slice(a.indexOf("(")+1);params=params.substr(0,params.indexOf(")")).split(",");return params}
  23.  
  24. if(typeof Game != "undefined"){
  25.  
  26. var readyGoFunc = Game['prototype']["startReadyGo"].toString()
  27. var holdBlockFunc = GameCore['prototype']['holdBlock'].toString()
  28.  
  29. readyGoFunc = "holdStat=0;this['GameStats'].addStat(new StatLine('HOLD_FREQ', 'Hold', "+STAT_POS+"),true);" + trim(readyGoFunc)
  30. holdBlockFunc = "if(!this['holdUsedAlready']&&(this['holdEnabled']==undefined||this['holdEnabled'])){holdStat++};if(this['GameStats'].get('HOLD_FREQ'))this['GameStats'].get('HOLD_FREQ').set(holdStat);" + trim(holdBlockFunc);
  31.  
  32. Game['prototype']["startReadyGo"] = new Function(readyGoFunc);
  33. GameCore['prototype']['holdBlock'] = new Function(holdBlockFunc);
  34.  
  35. }
  36.  
  37.  
  38.  
  39.  
  40. var website = "jstris.jezevec10.com"
  41. var url = window.location.href
  42. var parts = url.split("/")
  43.  
  44. if(typeof Replayer != "undefined"){
  45. Replayer["addStat"] = function(id,into) {
  46. var apmStat = document.createElement("tr");
  47. apmStat.innerHTML = '<td class="ter">Hold</td><td class="sval"><span id="'+id+'">0</span></td>'
  48. into.appendChild(apmStat);
  49. }
  50. }
  51.  
  52. if(parts[3]=="replay" && parts[2].endsWith(website) && parts.length>4){
  53.  
  54. var onLoad = ReplayController['prototype']['loadReplay'].toString()
  55. onLoad = trim(onLoad) + 'for(i=0;i<this["g"].length;i++)GameCore["holdTimestamps"+(this.g.length==1?"P":(i+1))]=this["g"][i]["actions"].filter(x=>x.a==10).map(x=>x.t);'
  56. ReplayController['prototype']['loadReplay'] = new Function(onLoad);
  57.  
  58. if(parts[4]=="1v1"){
  59. Replayer["addStat"]("holdElement1",document.getElementsByTagName("tbody")[0])
  60. Replayer["addStat"]("holdElement2",document.getElementsByTagName("tbody")[2])
  61.  
  62. } else {
  63. Replayer["addStat"]("holdElementP",document.getElementsByClassName("moreStats")[0])
  64. }
  65.  
  66. Replayer['prototype']['getHold'] = function(cat) {
  67. if(stamps=GameCore["holdTimestamps"+cat]){
  68. for (var i = 0; i < stamps.length; i++) {
  69. if(stamps[i]>=this['clock']){
  70. return i
  71. }
  72. }
  73. return stamps.length
  74. }
  75. return 0
  76. };
  77.  
  78. var oldTextBar = View.prototype.updateTextBar.toString();
  79. oldTextBar = trim(oldTextBar) + ';var cat = this.kppElement.id.slice(-1);eval("holdElement"+cat+"&&(holdElement"+cat+".innerHTML = this.g.getHold(cat))");'
  80. View.prototype.updateTextBar = new Function(oldTextBar);
  81.  
  82. }
  83.  
  84. });
  85. })();