Skip to content

Instantly share code, notes, and snippets.

@RayBB
Created June 7, 2017 21:40
Show Gist options
  • Save RayBB/d25ee78fb37c8f1b496d0eea6d8ecca9 to your computer and use it in GitHub Desktop.
Save RayBB/d25ee78fb37c8f1b496d0eea6d8ecca9 to your computer and use it in GitHub Desktop.
Calculates total profit from Amazon FBA
/*
Instructions:
Go to Amazon Seller Central > Invintory > Manage FBA Invintory
Under Filters, set status = active
Set results to page to necessicary size
*/
///FBA Value Calculator!
let prices = [...document.querySelectorAll('.a-input-text.main-entry.mt-icon-input.mt-input-text')].map(function(currentValue){return currentValue.value*1;})
let quantities = [...document.querySelectorAll('div[data-column="quantity"]')].map(function(currentValue){return currentValue.innerText*1;})
let fees = [...document.querySelectorAll('div[data-column="fee_preview"]')].map(function(currentValue){return currentValue.innerText.match(/\d*\.\d*/)[0]*1;})
let totalPrice = prices.reduce(function(accumulator, currentValue, currentIndex){return accumulator + currentValue*quantities[currentIndex];})
let totalFees = fees.reduce(function(accumulator, currentValue, currentIndex){return accumulator + currentValue*quantities[currentIndex];})
console.log('Selling ' + quantities.length + ' items!');
console.log('Total Price: ' + totalPrice)
console.log('Total Fees: ' + totalFees)
console.log('Total Profit: ' + (totalPrice - totalFees))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment