Show lineclear types

Counts and displays all types of lineclears

  1. // ==UserScript==
  2. // @name Show lineclear types
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.1
  5. // @author Oki
  6. // @description Counts and displays all types of lineclears
  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. Show lineclear types Script
  17. **************************/
  18.  
  19.  
  20. Game["refreshTable"] = function(object) {
  21. var old = document.getElementById("gdHolder");
  22. old&&(old.parentNode.removeChild(old))
  23. var fgd = '<style>#gdT {border-collapse:collapse;text-align:left}.gd {border:1px solid white;padding:5px}</style><table id="gdT">'
  24.  
  25. if(!object)return;
  26. var gdHold=document.createElement("div");
  27. gdHold.id="gdHolder";
  28. gdHold.style.position="absolute"
  29. gdHold.style.left = (myCanvas.getBoundingClientRect().left - 300) + "px";
  30. gdHold.style.top = (myCanvas.getBoundingClientRect().top + 50) + "px";
  31. document.body.appendChild(gdHold);
  32.  
  33. var ordered = {};
  34. Object.keys(object).sort().forEach(function(key) {
  35. ordered[key] = object[key];
  36. });
  37.  
  38. var keys = Object.keys(ordered)
  39.  
  40. for (var i = 0; i < keys.length; i++) {
  41. var key=keys[i]
  42. var add=[key,ordered[key]]
  43. fgd+=`<tr><td class="gd">${add[0]}</td><td class="gd">${add[1]}</td></tr>`
  44. }
  45.  
  46. gdHolder.innerHTML = fgd+"</table>"
  47. }
  48.  
  49.  
  50. var trim=a=>{a=a.slice(0,-1);a=a.substr(a.indexOf("{")+1);return a}
  51. var getParams=a=>{var params=a.slice(a.indexOf("(")+1);params=params.substr(0,params.indexOf(")")).split(",");return params}
  52.  
  53. window.events = ["TSPIN_SINGLE","TSPIN_MINI_SINGLE","CLEAR1","TSPIN_DOUBLE","CLEAR2","TSPIN_TRIPLE","CLEAR3","CLEAR4","PERFECT_CLEAR"]
  54.  
  55. var rgFunc = Game['prototype']['readyGo'].toString()
  56. rgFunc="gd={};com=-1;Game['refreshTable']();"+trim(rgFunc);
  57. Game['prototype']["readyGo"] = new Function(rgFunc);
  58.  
  59. var clcFunc = Game['prototype']['checkLineClears'].toString()
  60. events.map((x,i)=>{clcFunc=clcFunc.replace(x+")",x+");gd['"+x+"']=~~gd['"+x+"']+1;oldcom=com;com=this['comboCounter'];if(com<0&&oldcom>=0){gd['combo'+oldcom]=~~gd['combo'+oldcom]+1};Game['refreshTable'](gd);");})
  61. Game['prototype']["checkLineClears"] = new Function(trim(clcFunc));
  62.  
  63.  
  64. });
  65. })();