Greasy Fork is available in English.

Show APM in Replays

Show APM and Attack stats in Jstris replays

  1. // ==UserScript==
  2. // @name Show APM in Replays
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.4.1
  5. // @author Oki
  6. // @description Show APM and Attack stats in Jstris replays
  7. // @match https://*.jstris.jezevec10.com/*
  8. // @grant none
  9. // ==/UserScript==
  10.  
  11. (function() {
  12. 'use strict';
  13.  
  14. window.addEventListener('load', function(){
  15. /**************************
  16. APM & Attack in Replays Script
  17. **************************/
  18.  
  19. var website = "jstris.jezevec10.com"
  20. var url = window.location.href
  21. var parts = url.split("/")
  22. var trim=a=>{a=a.slice(0,-1);a=a.substr(a.indexOf("{")+1);return a}
  23.  
  24. Replayer["addStat"] = function(id,into) {
  25. var apmStat = document.createElement("tr");
  26. apmStat.innerHTML = '<td class="ter">APM</td><td class="sval"><span id="'+id+'">0</span></td>'
  27. into.appendChild(apmStat);
  28. }
  29.  
  30.  
  31. function addAPMelement(){
  32. console.log(this)
  33.  
  34. //if ((this.g.GameStats.shown & 4) != 0) {
  35. //}
  36.  
  37. if(parts[4]=="1v1"){
  38. var side = this.canvas.id.slice(-1)
  39. Replayer["addStat"]("apmElement"+side,document.getElementById("statTable"+side))
  40.  
  41. } else {
  42. document.getElementsByClassName("ter")[2].innerHTML = "Attack"
  43. Replayer["addStat"]("apmElements",document.getElementById("statTable"))
  44. }
  45. }
  46.  
  47.  
  48. if(parts[3]=="replay" && parts[2].endsWith(website) && parts.length>4){
  49.  
  50. var onCreate = View.prototype.onCreate.toString();
  51. onCreate = trim(onCreate) + trim(addAPMelement.toString())
  52. View['prototype']["onCreate"] = new Function(onCreate);
  53.  
  54.  
  55. Replayer['prototype']['getAPM'] = function() {
  56. return ((this['gamedata']['linesSent'] / (this['clock'] / 6000))*10).toFixed(2)
  57. };
  58.  
  59.  
  60. var oldTextBar = View.prototype.updateTextBar.toString();
  61. oldTextBar = trim(oldTextBar) + ';var cat = this.canvas.id.slice(-1);eval("apmElement"+cat+"&&(apmElement"+cat+".innerHTML = this.g.getAPM())");'
  62.  
  63.  
  64. View.prototype.updateTextBar = new Function(oldTextBar);
  65. View.prototype.onCreate = new Function(onCreate)
  66. }
  67.  
  68.  
  69.  
  70. });
  71. })();