KPP2 Script

shows an alternate kpp excluding hold and counting 180 spins as 1 key

  1. // ==UserScript==
  2. // @name KPP2 Script
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.31
  5. // @description shows an alternate kpp excluding hold and counting 180 spins as 1 key
  6. // @author Oki
  7. // @match https://*.jstris.jezevec10.com/*
  8. // @grant none
  9. // ==/UserScript==
  10.  
  11. /**************************
  12. KPP2 Script
  13. **************************/
  14.  
  15. (function() {
  16. window.addEventListener('load', function(){
  17.  
  18.  
  19. count_hold_as_keypress = true
  20. STAT_POS = 990
  21.  
  22. var trim=a=>{a=a.slice(0,-1);a=a.substr(a.indexOf("{")+1);return a}
  23. var getParams=a=>{var params=a.slice(a.indexOf("(")+1);params=params.substr(0,params.indexOf(")")).split(",");return params}
  24.  
  25. Game["keypressesMinus"] = 0;
  26.  
  27. var rotFunc = Game['prototype']['rotateCurrentBlock'].toString()
  28. var holdFunc = GameCore['prototype']['holdBlock'].toString()
  29. var readyGoFunc = Game['prototype']["startReadyGo"].toString()
  30. var kppFunc = GameCore['prototype']['getKPP'].toString()
  31.  
  32. var rotParams = getParams(rotFunc)
  33.  
  34. rotFunc = rotFunc.replace("2:","(Game['keypressesMinus']++,2):")
  35. if(!count_hold_as_keypress){
  36. holdFunc = holdFunc.replace("++","++;Game['keypressesMinus']++;")
  37. }
  38. readyGoFunc = "this['GameStats'].addStat(new StatLine('KPPT', 'KPP2', "+STAT_POS+"),true);Game['keypressesMinus']=0;" + trim(readyGoFunc)
  39.  
  40.  
  41. function kppAdd() {
  42. var kpp2 = 0;
  43. if (this['placedBlocks']) {
  44. kpp2 = (this['totalKeyPresses'] - Game["keypressesMinus"] + this['placedBlocks']) / this['placedBlocks']
  45.  
  46. };
  47. if(this['GameStats'].get('KPPT'))this['GameStats'].get('KPPT').set(kpp2.toFixed(2));
  48. };
  49.  
  50.  
  51. GameCore['prototype']['getKPP'] = new Function(trim(kppAdd.toString()) + trim(kppFunc))
  52. GameCore['prototype']['holdBlock'] = new Function(trim(holdFunc));
  53. Game['prototype']['rotateCurrentBlock'] = new Function(...rotParams, trim(rotFunc));
  54. Game['prototype']["startReadyGo"] = new Function(readyGoFunc);
  55.  
  56.  
  57. })})()