APP/PPD script

shows ppd and app in games and replays

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey, Greasemonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

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

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

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

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्क्रिप्ट व्यवस्थापक एक्स्टेंशन इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्क्रिप्ट व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्टाईल व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

// ==UserScript==
// @name         APP/PPD script
// @namespace    http://tampermonkey.net/
// @version      1.2
// @description  shows ppd and app in games and replays
// @author       orz
// @match        https://*.jstris.jezevec10.com/*
// @grant        none
// ==/UserScript==

/**************************
   APP / PPD Script
**************************/

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

	var rect = holdCanvas.getBoundingClientRect();
	var p = document.createElement("div");
	p.id = "pace"
	p.style = ("color:#999;width:150px;position:absolute;top:"+(rect.top+300)+"px;left:"+(rect.left-50)+"px")
	p.innerHTML = `
	<table style='width:100%;height:100%;table-layout:fixed;'>
	  <tr>
	    <th style='text-align:center' colspan="2">Efficiency Stats:</th>
	  </tr>
	  <tr>
	    <td>APP</td>
	    <td id='appEle'>0</td>
	  </tr>
	  <tr>
	    <td>PPD</td>
	    <td id='dppEle'>0</td>
	  </tr>
	</table>
	`
	document.body.appendChild(p);

	if(typeof trim != "function"){var trim=a=>{a=a.slice(0,-1);a=a.substr(a.indexOf("{")+1);return a}}
    function paces() {
        var appEle = document.getElementById('appEle');
        var dppEle = document.getElementById('dppEle');
        if (appEle && dppEle) {
            var app = this["gamedata"]["attack"] / this["placedBlocks"];
            var dpp = 1 / (this["gamedata"]["garbageCleared"] / this["placedBlocks"]);
            console.log(app);
            console.log(dpp);
            appEle.innerHTML= (app*0 + 1)? app.toFixed(3):'0.000';
            dppEle.innerHTML= (dpp*0 + 1)? dpp.toFixed(3):'0.000';
        }
    }

    if (typeof Game != "undefined") {
	    var queueBoxFunc = Game['prototype']['updateQueueBox'].toString()
        queueBoxFunc = trim(paces.toString()) + trim(queueBoxFunc);
        Game['prototype']["updateQueueBox"] = new Function(queueBoxFunc);
    }
    if (typeof Replayer != "undefined") {
        var replayerQueueBoxFunc = Replayer['prototype']['updateQueueBox'].toString();
        replayerQueueBoxFunc = trim(paces.toString()) + trim(replayerQueueBoxFunc);
        Replayer['prototype']['updateQueueBox'] = new Function(replayerQueueBoxFunc);
    }


    });
})();