Attack Separator Script

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

Stan na 02-07-2019. Zobacz najnowsza wersja.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Greasemonkey lub Violentmonkey.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana będzie instalacja rozszerzenia Tampermonkey lub Userscripts.

You will need to install an extension such as Tampermonkey to install this script.

Aby zainstalować ten skrypt, musisz zainstalować rozszerzenie menedżera skryptów użytkownika.

(Mam już menedżera skryptów użytkownika, pozwól mi to zainstalować!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Musisz zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

(Mam już menedżera stylów użytkownika, pozwól mi to zainstalować!)

// ==UserScript==
// @name         Attack Separator Script
// @namespace    http://tampermonkey.net/
// @version      0.3
// @description  separates attack into attack from self-created lines and attack from garbage lines
// @author       Oki
// @match        https://*.jstris.jezevec10.com/*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    window.addEventListener('load', function(){

/**************************
   Attack Separator Script
**************************/

var trim=a=>{a=a.slice(0,-1);a=a.substr(a.indexOf("{")+1);return a}

if(typeof Game == "undefined"){

    var oldFunc2 = Replayer.prototype.checkLineClears.toString()
    oldFunc2 = "rows0=0;rows1=0;" + trim(oldFunc2)
    
    oldFunc2 = oldFunc2.split("=== 10){for(var ")
    var rowVar = oldFunc2[1].split("=")[1].split(";")[0]
    oldFunc2 = oldFunc2.join('=== 10){eval("rows"+ +(JSON.stringify(this.matrix['+rowVar+']).indexOf(8)<0)+"++");for(var ')
    
    var oldTextBar = View.prototype.updateTextBar.toString()
    oldTextBar = oldTextBar.replace("this.sentElement.innerHTML=this.g.gamedata.lines,","")
    oldTextBar = oldTextBar.replace("this.sentElement.innerHTML=this.g.gamedata.linesSent","")
    
    oldTextBar = trim(oldTextBar)
    
    oldFunc2 = oldFunc2.split("+=")
    var sum = oldFunc2[oldFunc2.length-1].split(";")[0]
    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]
    oldFunc2 = oldFunc2.join`+=`
    
    View.prototype.onReady = function(){this.setupMode(),this.updateQueueBox(),this.redrawHoldBox(),this.clearMainCanvas(),this.sentElement.innerHTML=0}
    View.prototype.updateTextBar = new Function(oldTextBar);
    Replayer.prototype.checkLineClears = new Function(oldFunc2);

} else {

    var oldFunc = Game.prototype.checkLineClears.toString()
    oldFunc = "var rows0=0;var rows1=0;" + trim(oldFunc)
    
    oldFunc = oldFunc.split(")};for(")
    var rowVar = oldFunc[0].split("(")[oldFunc[0].split("(").length-1]
    oldFunc = oldFunc.join(')};eval("rows"+ +(JSON.stringify(this.matrix['+rowVar+']).indexOf(8)<0)+"++");var oldSent=this.gamedata.linesSent;for(')
    var split = oldFunc.split("> 0){this[_")
    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);'
    
    split[3] = split[3].replace("=","*/")
    split[3] = split[3].replace(")",");"+inject)
    for (var i = 0; i < split.length-1; i++) {
        split[i] += (i==2) ? "> 0){/*this[_" : "> 0){this[_"
    }
    
    oldFunc = split.join``
    Game.prototype.checkLineClears = new Function(oldFunc);
}

    });
})();