Skip to content

Instantly share code, notes, and snippets.

@smat
Last active December 20, 2015 05:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save smat/6077429 to your computer and use it in GitHub Desktop.
Save smat/6077429 to your computer and use it in GitHub Desktop.
NordInvasion AH price per item
// ==UserScript==
// @name NordInvasion AH price per item
// @namespace http://github.com/smat
// @version 0.1
// @description Shows the price per item on the NordInvasion AH
// @match http://*.nordinvasion.com/*
// @match https://*.nordinvasion.com/*
// @grant none
// @copyright 2012+, Stian Mathissen
// ==/UserScript==
$(document).ready(function() {
$('.ah-item-row').each(function(index, el) {
jel = $(el);
quantityRegexMatch = jel.text().match(/^\s*(\d+) x/);
amountRegexMatch = jel.find('span:eq(2)').text().match(/^\s*(\d+)/);
quantity = quantityRegexMatch[1];
amount = amountRegexMatch[1];
pricePer = amount / quantity;
jel.append($('<span>').css('display', 'block').css('float', 'right').css('width', '100px').text(pricePer.toFixed(1) + " per"));
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment