Attack Separator Script

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

目前為 2019-07-02 提交的版本,檢視 最新版本

  1. // ==UserScript==
  2. // @name Attack Separator Script
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.2
  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 = trim(oldTextBar)
  32. oldFunc2 = oldFunc2.split("+=")
  33. var sum = oldFunc2[oldFunc2.length-1].split(";")[0]
  34. 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]
  35. oldFunc2 = oldFunc2.join`+=`
  36. View.prototype.onReady = function(){this.setupMode(),this.updateQueueBox(),this.redrawHoldBox(),this.clearMainCanvas(),this.sentElement.innerHTML=0}
  37. View.prototype.updateTextBar = new Function(oldTextBar);
  38. Replayer.prototype.checkLineClears = new Function(oldFunc2);
  39.  
  40. } else {
  41.  
  42. var oldFunc = Game.prototype.checkLineClears.toString()
  43. oldFunc = "var rows0=0;var rows1=0;" + trim(oldFunc)
  44. oldFunc = oldFunc.split(")};for(")
  45. var rowVar = oldFunc[0].split("(")[oldFunc[0].split("(").length-1]
  46. oldFunc = oldFunc.join(')};eval("rows"+ +(JSON.stringify(this.matrix['+rowVar+']).indexOf(8)<0)+"++");var oldSent=this.gamedata.linesSent;for(')
  47. var split = oldFunc.split("> 0){this[_")
  48. 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);'
  49. split[3] = split[3].replace("=","*/")
  50. split[3] = split[3].replace(")",");"+inject)
  51. for (var i = 0; i < split.length-1; i++) {
  52. split[i] += (i==2) ? "> 0){/*this[_" : "> 0){this[_"
  53. }
  54. oldFunc = split.join``
  55. Game.prototype.checkLineClears = new Function(oldFunc);
  56. }
  57.  
  58. });
  59. })();