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.1
  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. /**************************
  18. Attack Separator Script
  19. **************************/
  20.  
  21.  
  22. var trim=a=>{a=a.slice(0,-1);a=a.substr(a.indexOf("{")+1);return a}
  23.  
  24. var oldFunc = Game.prototype.checkLineClears.toString()
  25. oldFunc = "var rows0=0;var rows1=0;" + trim(oldFunc)
  26.  
  27. oldFunc = oldFunc.split(")};for(")
  28. var rowVar = oldFunc[0].split("(")[oldFunc[0].split("(").length-1]
  29. oldFunc = oldFunc.join(')};eval("rows"+ +(JSON.stringify(this.matrix['+rowVar+']).indexOf(8)<0)+"++");var oldSent=this.gamedata.linesSent;for(')
  30.  
  31. var split = oldFunc.split("> 0){this[_")
  32.  
  33. 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);'
  34.  
  35. split[3] = split[3].replace("=","*/")
  36. split[3] = split[3].replace(")",");"+inject)
  37. for (var i = 0; i < split.length-1; i++) {
  38. split[i] += (i==2) ? "> 0){/*this[_" : "> 0){this[_"
  39. }
  40.  
  41. oldFunc = split.join``
  42. Game.prototype.checkLineClears = new Function(oldFunc);
  43.  
  44.  
  45. });
  46. })();