Advanced button stats

Show Advanced button stats

Version vom 03.04.2015. Aktuellste Version

Du musst eine Erweiterung wie Tampermonkey, Greasemonkey oder Violentmonkey installieren, um dieses Skript zu installieren.

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

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.

Sie müssten eine Skript Manager Erweiterung installieren damit sie dieses Skript installieren können

(Ich habe schon ein Skript Manager, Lass mich es installieren!)

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