T-Waste Script

shows what percent of T pieces were wasted (not used in a t-spin)

  1. // ==UserScript==
  2. // @name T-Waste Script
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.2.1
  5. // @description shows what percent of T pieces were wasted (not used in a t-spin)
  6. // @author Oki, jez
  7. // @match https://*.jstris.jezevec10.com/*
  8. // @grant none
  9. // ==/UserScript==
  10.  
  11. /**************************
  12. T-Waste Script
  13. **************************/
  14.  
  15. var STAT_POS = 1000; //sorting priority for the stat position (1000=always last), default stats have order from 0 and increments of 10
  16.  
  17. (function() {
  18. window.addEventListener('load', function(){
  19.  
  20. var spins = ["TSPIN_SINGLE","TSPIN_MINI_SINGLE","TSPIN_DOUBLE","TSPIN_TRIPLE"]
  21.  
  22. if(typeof trim != "function"){var trim=a=>{a=a.slice(0,-1);a=a.substr(a.indexOf("{")+1);return a}}
  23. if(typeof getParams != "function"){var getParams=a=>{var params=a.slice(a.indexOf("(")+1);params=params.substr(0,params.indexOf(")")).split(",");return params}}
  24.  
  25. Game['bad'] = [0,0]
  26.  
  27. var queueBoxFunc = Game['prototype']['updateQueueBox'].toString()
  28. var lineClearsFunc = Game['prototype']['checkLineClears'].toString()
  29. var placeBlockFunc = Game['prototype']["placeBlock"].toString()
  30. var readyGoFunc = Game['prototype']["startReadyGo"].toString()
  31.  
  32. var params2 = getParams(placeBlockFunc)
  33.  
  34. placeBlockFunc = "if(this['activeBlock'].id==2){Game['bad'][0]++};" + trim(placeBlockFunc)
  35. spins.map(x=>{lineClearsFunc=lineClearsFunc.replace(x+")",x+");Game['bad'][1]++;")})
  36.  
  37. var append = "setTimeout(x=>{Game['bad'][0]=0;Game['bad'][1]=0},100);this['GameStats'].addStat(new StatLine('TWASTE', '🗑️T', "+STAT_POS+"),true);"
  38. var append2 = "if(this['GameStats'].get('TWASTE'))this['GameStats'].get('TWASTE').set((Game['bad'][0]+Game['bad'][1])?(((Game['bad'][0]-Game['bad'][1])/(Game['bad'][0])).toFixed(2)+' '+(Game['bad'][0]-Game['bad'][1])+'/'+(Game['bad'][0])):(0));"
  39. readyGoFunc = append + trim(readyGoFunc)
  40. queueBoxFunc = append2 + trim(queueBoxFunc)
  41.  
  42. Game['prototype']["updateQueueBox"] = new Function(queueBoxFunc);
  43. Game['prototype']["placeBlock"] = new Function(...params2, placeBlockFunc);
  44. Game['prototype']["checkLineClears"] = new Function(trim(lineClearsFunc));
  45. Game['prototype']["startReadyGo"] = new Function(readyGoFunc);
  46.  
  47. })})()