Attack Separator Script

separates attack into attack from self-created lines and attack from garbage lines

  1. // ==UserScript==
  2. // @name Attack Separator Script
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.3
  5. // @description separates attack into attack from self-created lines and attack from garbage lines
  6. // @author Oki
  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. /**************************
  17. Attack Separator Script
  18. **************************/
  19.  
  20. var trim=a=>{a=a.slice(0,-1);a=a.substr(a.indexOf("{")+1);return a}
  21.  
  22. if(typeof Game == "undefined"){
  23.  
  24. var oldFunc2 = Replayer.prototype.checkLineClears.toString()
  25. oldFunc2 = "rows0=0;rows1=0;" + trim(oldFunc2)
  26. oldFunc2 = oldFunc2.split("=== 10){for(var ")
  27. var rowVar = oldFunc2[1].split("=")[1].split(";")[0]
  28. oldFunc2 = oldFunc2.join('=== 10){eval("rows"+ +(JSON.stringify(this.matrix['+rowVar+']).indexOf(8)<0)+"++");for(var ')
  29. var oldTextBar = View.prototype.updateTextBar.toString()
  30. oldTextBar = oldTextBar.replace("this.sentElement.innerHTML=this.g.gamedata.lines,","")
  31. oldTextBar = oldTextBar.replace("this.sentElement.innerHTML=this.g.gamedata.linesSent","")
  32. oldTextBar = trim(oldTextBar)
  33. oldFunc2 = oldFunc2.split("+=")
  34. var sum = oldFunc2[oldFunc2.length-1].split(";")[0]
  35. oldFunc2[oldFunc2.length-1] = sum+';distr=[rows1/(rows0+rows1),(rows0/(rows0+rows1))].map(x=>x*('+sum+'));var sentHTML=this.v.sentElement.innerHTML.split("/");if(sentHTML!=0){distr[0]+= +sentHTML[0];distr[1]+= +sentHTML[1]};this.v.sentElement.innerHTML=distr[0].toFixed(2)+" / "+distr[1].toFixed(2);' + oldFunc2[oldFunc2.length-1]
  36. oldFunc2 = oldFunc2.join`+=`
  37. View.prototype.onReady = function(){this.setupMode(),this.updateQueueBox(),this.redrawHoldBox(),this.clearMainCanvas(),this.sentElement.innerHTML=0}
  38. View.prototype.updateTextBar = new Function(oldTextBar);
  39. Replayer.prototype.checkLineClears = new Function(oldFunc2);
  40.  
  41. } else {
  42.  
  43. var oldFunc = Game.prototype.checkLineClears.toString()
  44. oldFunc = "var rows0=0;var rows1=0;" + trim(oldFunc)
  45. oldFunc = oldFunc.split(")};for(")
  46. var rowVar = oldFunc[0].split("(")[oldFunc[0].split("(").length-1]
  47. oldFunc = oldFunc.join(')};eval("rows"+ +(JSON.stringify(this.matrix['+rowVar+']).indexOf(8)<0)+"++");var oldSent=this.gamedata.linesSent;for(')
  48. var split = oldFunc.split("> 0){this[_")
  49. var inject = 'var distr=[rows1/(rows0+rows1),(rows0/(rows0+rows1))].map(x=>x*(this.gamedata.linesSent-oldSent));var sentHTML=this.sentElement.innerHTML.split("/");if(sentHTML!=0){distr[0]+= +sentHTML[0];distr[1]+= +sentHTML[1]};this.sentElement.innerHTML=distr[0].toFixed(2)+" / "+distr[1].toFixed(2);'
  50. split[3] = split[3].replace("=","*/")
  51. split[3] = split[3].replace(")",");"+inject)
  52. for (var i = 0; i < split.length-1; i++) {
  53. split[i] += (i==2) ? "> 0){/*this[_" : "> 0){this[_"
  54. }
  55. oldFunc = split.join``
  56. Game.prototype.checkLineClears = new Function(oldFunc);
  57. }
  58.  
  59. });
  60. })();