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.

目前為 2014-08-07 提交的版本,檢視 最新版本

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

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

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 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);