T-Waste Script

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

Tính đến 11-06-2019. Xem phiên bản mới nhất.

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

Bạn sẽ cần cài đặt một tiện ích mở rộng như Tampermonkey hoặc Violentmonkey để cài đặt kịch bản này.

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

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

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

You will need to install a user script manager extension to install this script.

(Tôi đã có Trình quản lý tập lệnh người dùng, hãy cài đặt nó!)

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.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

// ==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         
**************************/

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);