Last active
August 5, 2016 12:48
-
-
Save daronspence/de97f15d22c1ebd94d563118714c1370 to your computer and use it in GitHub Desktop.
Calculate Meh.com Total
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Run this is the JS console of your Browser. | |
// jQuery must be loaded | |
// https://meh.com/orders | |
var total = 0; | |
$('span.summary').each(function() { | |
// Get the QTY and Purchase Price | |
var nums = $(this).text().match(/\d+\.\d+|\d+\b|\d+(?=\w)/g); | |
// Multiply QTY by Purchase Price | |
total += parseInt(nums[0],10)*parseInt(nums[nums.length - 1],10); | |
}); | |
alert("Your Meh habit has cost you $" + total + " so far"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment