Trophy Value Calculator

Calculate the total value of trophies based on jenga201's buying prices

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

You will need to install an extension such as Tampermonkey to install this 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            Trophy Value Calculator
// @description     Calculate the total value of trophies based on jenga201's buying prices
// @include         http://hentaiverse.org/?s=Character&ss=in
// @include         http://hentaiverse.org/?s=Bazaar&ss=is
// @include         http://hentaiverse.org/?s=Bazaar&ss=is&*
// @version 0.0.1.20160110102520
// @namespace https://greasyfork.org/users/2233
// ==/UserScript==

/*** Settings ***/
var d = {
    'ManBearPig Tail': 600,
    'Holy Hand Grenade of Antioch': 600,
    'Mithra\'s Flower': 600,
    'Dalek Voicebox': 600,
    'Lock of Blue Hair': 850,
    'Bunny-Girl Costume': 1250,
    'Hinamatsuri Doll': 1250,
    'Broken Glasses': 1250,
    'Black T-Shirt': 3400,
    'Sapling': 3400,
    'Unicorn Horn': 6000,
    'Noodly Appendage': 26000,
    'Bronze Coupon': 600,
    'Silver Coupon': 1100,
    'Golden Coupon': 30000,
    'Platinum Coupon': 100000,
}
/*** End of Settings ***/

var wnd = window
var doc = wnd.document
var loc = location
var href = loc.href

var $  = function(e, css) { if(!css) { css=e; e=doc }; return e.querySelector(css) }
var $$ = function(e, css) { if(!css) { css=e; e=doc }; return e.querySelectorAll(css) }

if(!$('#togpane_log') && !$('#riddlemaster')) {
    var display_total_value = function(sum) {
        var out = 'Total value of trophies: ' + sum.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",") + ' credits'
        console.log(out)

        var div = doc.createElement('DIV')
        div.appendChild(doc.createElement('BR'))
        div.appendChild(doc.createTextNode(out))

        var left = $('.clb')
        div.style.cssText = $(left, '.cit .fd4 > div').style.cssText + 'margin-right: 8px;'
        left.appendChild(div)
    }

    // Character -> Inventory
    var inv_item = $('#inv_item')
    if(inv_item) {
        var items = $$(inv_item, '.id')
        for(var i=items.length-1, sum=0; i>=0; i--) {
            var k = items[i].textContent
            var v = parseInt(d[k])
            var supply = parseInt($(items[i].parentNode.parentNode, '.ii').textContent)
            if( (!isNaN(v)) && (!isNaN(supply)) ) {
                sum += (v*supply)
            }
        }
        display_total_value(sum)
    }

    // Bazaar -> Item Shop -> All/Special
    var item_pane = $('#item_pane')
    if(item_pane) {
        var items = $$(item_pane, '.idp')
        var supplies = $$(item_pane, '.ii')
        for(var i=items.length-1, sum=0; i>=0; i--) {
            var k = items[i].textContent
            var v = parseInt(d[k])
            var supply = parseInt(supplies[i].textContent)
            if( (!isNaN(v)) && (!isNaN(supply)) ) {
                sum += (v*supply)
            }
        }
        display_total_value(sum)
    }
}