Greasy Fork is available in English.

Hold Stat Script

Shows how often hold was used

2019-07-22 يوللانغان نەشرى. ئەڭ يېڭى نەشرىنى كۆرۈش.

  1. // ==UserScript==
  2. // @name Hold Stat Script
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.2
  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.  
  25. var readyGoFunc = Game['prototype']["startReadyGo"].toString()
  26. var holdBlockFunc = GameCore['prototype']['holdBlock'].toString()
  27.  
  28. readyGoFunc = "holdStat=0;this['GameStats'].addStat(new StatLine('HOLD_FREQ', 'Hold', "+STAT_POS+"),true);" + trim(readyGoFunc)
  29. holdBlockFunc = "if(!this['holdUsedAlready']&&this['holdEnabled']){holdStat++};if(this['GameStats'].get('HOLD_FREQ'))this['GameStats'].get('HOLD_FREQ').set(holdStat);" + trim(holdBlockFunc);
  30.  
  31. Game['prototype']["startReadyGo"] = new Function(readyGoFunc);
  32. GameCore['prototype']['holdBlock'] = new Function(holdBlockFunc);
  33.  
  34.  
  35.  
  36.  
  37. var website = "jstris.jezevec10.com"
  38. var url = window.location.href
  39. var parts = url.split("/")
  40.  
  41. if(typeof Replayer != "undefined"){
  42. Replayer["addStat"] = function(id,into) {
  43. var apmStat = document.createElement("tr");
  44. apmStat.innerHTML = '<td class="ter">Hold</td><td class="sval"><span id="'+id+'">0</span></td>'
  45. into.appendChild(apmStat);
  46. }
  47. }
  48.  
  49. if(parts[3]=="replay" && parts[2].endsWith(website) && parts.length>4){
  50.  
  51. var onLoad = ReplayController['prototype']['loadReplay'].toString()
  52. 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);'
  53. ReplayController['prototype']['loadReplay'] = new Function(onLoad);
  54.  
  55. if(parts[4]=="1v1"){
  56. Replayer["addStat"]("holdElement1",document.getElementsByTagName("tbody")[0])
  57. Replayer["addStat"]("holdElement2",document.getElementsByTagName("tbody")[2])
  58.  
  59. } else {
  60. Replayer["addStat"]("holdElementP",document.getElementsByClassName("moreStats")[0])
  61. }
  62.  
  63. Replayer['prototype']['getHold'] = function(cat) {
  64. if(stamps=GameCore["holdTimestamps"+cat]){
  65. for (var i = 0; i < stamps.length; i++) {
  66. if(stamps[i]>=this['clock']){
  67. return i
  68. }
  69. }
  70. }
  71. return 0
  72. };
  73.  
  74. var oldTextBar = View.prototype.updateTextBar.toString();
  75. oldTextBar = trim(oldTextBar) + ';var cat = this.kppElement.id.slice(-1);eval("holdElement"+cat+"&&(holdElement"+cat+".innerHTML = this.g.getHold(cat))");'
  76. View.prototype.updateTextBar = new Function(oldTextBar);
  77.  
  78. }
  79.  
  80. });
  81. })();