Ghost Trappers - Ghost Counter

To be used with the Ghost Trappers Facebook game. This script will count the total number of ghosts a player has caught and places the information in their profile page.

От 07.08.2014. Виж последната версия.

За да инсталирате този скрипт, трябва да имате инсталирано разширение като Tampermonkey, Greasemonkey или Violentmonkey.

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

За да инсталирате този скрипт, трябва да имате инсталирано разширение като Tampermonkey или Violentmonkey.

За да инсталирате този скрипт, трябва да имате инсталирано разширение като Tampermonkey или Userscripts.

За да инсталирате скрипта, трябва да инсталирате разширение като Tampermonkey.

За да инсталирате този скрипт, трябва да имате инсталиран скриптов мениджър.

(Вече имам скриптов мениджър, искам да го инсталирам!)

За да инсталирате този стил, трябва да инсталирате разширение като Stylus.

За да инсталирате този стил, трябва да инсталирате разширение като Stylus.

За да инсталирате този стил, трябва да инсталирате разширение като Stylus.

За да инсталирате този стил, трябва да имате инсталиран мениджър на потребителски стилове.

За да инсталирате този стил, трябва да имате инсталиран мениджър на потребителски стилове.

За да инсталирате този стил, трябва да имате инсталиран мениджър на потребителски стилове.

(Вече имам инсталиран мениджър на стиловете, искам да го инсталирам!)

// ==UserScript==
// @name         Ghost Trappers - Ghost Counter
// @author       Rani Kheir
// @namespace    https://greasyfork.org/users/4271-rani-kheir
// @version      1.0
// @description  To be used with the Ghost Trappers Facebook game. This script will count the total number of ghosts a player has caught and places the information in their profile page.
// @include      *ghost-trappers.com/fb/profiletab/index_intern.php?fbid=*
// @icon         http://i44.photobucket.com/albums/f36/Rani-Kheir/ghosticon_zpsc395e1ce.png
// @copyright    2014+, Rani Kheir
// ==/UserScript==

var countGhosts = document.getElementsByClassName('ghostCount').length;
var countGhostsTotal = 0;
var i;

for ( i = 0; i < countGhosts; i++ ) {
    var singleGhostCount = document.getElementsByClassName('ghostCount')[i].innerHTML.replace( /[^\d.]/g, '' );
    singleGhostCountInt = parseInt(singleGhostCount, 10);
    countGhostsTotal += singleGhostCountInt;
}

function addCommas(nStr) {
    nStr += '';
    var x = nStr.split('.');
    var x1 = x[0];
    var x2 = x.length > 1 ? '.' + x[1] : '';
    var rgx = /(\d+)(\d{3})/;
    while (rgx.test(x1)) {
        x1 = x1.replace(rgx, '$1' + ',' + '$2');
    }
    return x1 + x2;
}

var contentToEdit = document.getElementsByClassName('profileBoxData')[0].innerHTML.split("<b>Location:</b>");
var contentEdited = contentToEdit.join("<b>Total ghosts caught: </b>" + addCommas(countGhostsTotal) + "<br><b>Location:</b>");
document.getElementsByClassName('profileBoxData')[0].innerHTML = contentEdited;

//document.getElementsByClassName('profileBoxData')[0].innerHTML = document.getElementsByClassName('profileBoxData')[0].innerHTML + "<b>Total ghosts caught: </b>" + addCommas(countGhostsTotal);
//alert(countGhostsTotal);