Advanced button stats

Show Advanced button stats

Versione datata 03/04/2015. Vedi la nuova versione l'ultima versione.

Dovrai installare un'estensione come Tampermonkey, Greasemonkey o Violentmonkey per installare questo script.

Dovrai installare un'estensione come Tampermonkey o Violentmonkey per installare questo script.

Dovrai installare un'estensione come Tampermonkey o Violentmonkey per installare questo script.

Dovrai installare un'estensione come Tampermonkey o Userscripts per installare questo script.

Dovrai installare un'estensione come ad esempio Tampermonkey per installare questo script.

Dovrai installare un gestore di script utente per installare questo script.

(Ho già un gestore di script utente, lasciamelo installare!)

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

(Ho già un gestore di stile utente, lasciamelo installare!)

// ==UserScript==
// @name         Advanced button stats
// @namespace    http://bwochinski.com/
// @version      0.1
// @description  Show Advanced button stats
// @author       bwochinski
// @match        *://www.reddit.com/r/thebutton/
// @grant        none
// ==/UserScript==

//CONFIG
var advInterval = 500; //update interval
var advKeepAmt = 30; //history to keep (in seconds)

//Imoprtant variables
var parHist = [];
var histLen = (1000 / advInterval) * advKeepAmt;

$(".thebutton-form").append("<div id='advButtonStats' style='position: relative; float: none; padding-top: 10px; width: 200px;'><div id='advBOPS' style='Font: 18px Verdana normal black;'>BOPS:</div><div id='advPPM' style='Font: 18px Verdana normal black;'>Presses/min:</div><div id='advFlair' style='Font: 18px Verdana normal;'>Current Flair:</div></div>");

function advStatUpdate() {
    if (parHist.length > histLen) {
        parHist.pop();
    }
    var advText = $("span.thebutton-participants").text().replace(",","");
    parHist.unshift(parseInt(advText));

    //console.log(parHist);
    var curBOPS = (parHist[0] - parHist[parHist.length - 1]) / (parHist.length / (1000 / advInterval));
    var curPPM = (parHist[0] - parHist[parHist.length - 1]) * (60 / advKeepAmt) * (advKeepAmt / parHist.length);
    var curTime = parseInt($("#thebutton-s-10s").text() + $("#thebutton-s-1s").text());
    $("#advBOPS").html("<b>BOPS:</b> " + curBOPS.toFixed(5));
    $("#advPPM").html("<b>Presses/min:</b> " + Math.round(curPPM));
    $("#advFlair").html("<b>Current Flair:</b> <span class='flair flair-press-" + String(curTime + 9).substring(0,1) + "'>" + curTime + "s</span>");
}

advStatUpdate();
setInterval(advStatUpdate, advInterval);