T-Waste Script

shows what percent of T pieces were wasted (not used in a t-spin)

目前为 2019-06-13 提交的版本。查看 最新版本

// ==UserScript==
// @name         T-Waste Script
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  shows what percent of T pieces were wasted (not used in a t-spin)
// @author       Oki
// @match        https://*.jstris.jezevec10.com/*
// @grant        none
// ==/UserScript==

/**************************
     T-Waste Script         
**************************/

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

var  wasteStat= document.createElement("tr");
wasteStat.innerHTML = '<td class="ter">🗑️T</td><td class="sval"><span id="waste">0</span></td>'
aux2.parentNode.parentNode.insertBefore(wasteStat, aux2.parentNode);
var spins = ["TSPIN_SINGLE","TSPIN_MINI_SINGLE","TSPIN_DOUBLE","TSPIN_TRIPLE"]

if(typeof trim != "function"){var trim=a=>{a=a.slice(0,-1);a=a.substr(a.indexOf("{")+1);return a}}
if(typeof getParams != "function"){var getParams=a=>{var params=a.slice(a.indexOf("(")+1);params=params.substr(0,params.indexOf(")")).split(",");return params}}

Game['bad'] = [0,0]

var queueBoxFunc = Game['prototype']['updateQueueBox'].toString()
var lineClearsFunc = Game['prototype']['checkLineClears'].toString()
var placeBlockFunc = Game['prototype']["placeBlock"].toString()
var readyGoFunc = Game['prototype']["startReadyGo"].toString()

var params2 = getParams(placeBlockFunc)

placeBlockFunc = "if(this['activeBlock'].id==2){Game['bad'][0]++};" + trim(placeBlockFunc)
spins.map(x=>{lineClearsFunc=lineClearsFunc.replace(x+")",x+");Game['bad'][1]++;")})

var append = "setTimeout(x=>{Game['bad'][0]=0;Game['bad'][1]=0},100);"
var append2 = "waste.innerHTML=(Game['bad'][0]+Game['bad'][1])?((1-Game['bad'][1]/Game['bad'][0]).toFixed(2)+' ('+(Game['bad'][0]-Game['bad'][1])+'/'+(Game['bad'][0])+')'):(0);"

readyGoFunc = append + trim(readyGoFunc)
queueBoxFunc = append2 + trim(queueBoxFunc)

Game['prototype']["updateQueueBox"] = new Function(queueBoxFunc);
Game['prototype']["placeBlock"] = new Function(...params2, placeBlockFunc);
Game['prototype']["checkLineClears"] = new Function(trim(lineClearsFunc));
Game['prototype']["startReadyGo"] = new Function(readyGoFunc);

})})()