Average Price Calculator for MoogleMail

Shows the average price of items attached to a letter at the bottom of the body section.

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

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            Average Price Calculator for MoogleMail
// @description     Shows the average price of items attached to a letter at the bottom of the body section.
// @include         http://hentaiverse.org/?s=Bazaar&ss=mm&filter=*
// @version 0.0.1.20150316110318
// @namespace https://greasyfork.org/users/2233
// ==/UserScript==

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(/&?\bmid=/.test(href)) {
    var body_section = $('#leftpane').children[1]
    var s = body_section.textContent.replace(/>/g, '')
    var m = s.match(/(?:Attached item removed: )(?:([0-9]+)x )?([^\(]+)\(.+, CoD was ([0-9]+)C/i)
    //var m = s.match(/(?:(?:Originally attached item was: )|(?:Attached item removed: ))(?:([0-9]+)x )?([^\(]+)\(.+, CoD was ([0-9]+)C/i)
    console.log(m)
    if(m) {
        var quantity = parseInt(m[1])
        if(isNaN(quantity)) { quantity = 1 }
        var item = m[2].replace(/^ +| +$/g, '')
        var cod = parseInt(m[3])
        var avg_price = cod/quantity
        body_section.innerHTML = body_section.innerHTML + '<HR>Item: ' + item + '<BR>Quantity: ' + quantity + '<BR>CoD: ' + cod + 'c<BR>Average Price: ' + avg_price + 'c'
    }
}