Created
September 14, 2025 06:39
-
-
Save hcho3/a2fdbfcca2bfdd9cc0f6d1cdebe9387f to your computer and use it in GitHub Desktop.
Userscript for exporting credit card transactions from Amazon.com
This file contains hidden or 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
| // ==UserScript== | |
| // @name Amazon transactions exporter | |
| // @namespace https://hyunsu-cho.io/ | |
| // @version 2025-09-13 | |
| // @description Compile list of credit card transactions from Amazon.com | |
| // @author Hyunsu Cho | |
| // @match https://www.amazon.com/cpe/yourpayments/transactions | |
| // @icon https://www.google.com/s2/favicons?sz=64&domain=tampermonkey.net | |
| // @grant none | |
| // @require https://code.jquery.com/jquery-3.6.0.min.js | |
| // @require https://raw.githubusercontent.com/eligrey/FileSaver.js/master/dist/FileSaver.min.js | |
| // ==/UserScript== | |
| function parse_transaction(transaction, date) { | |
| let payment_method = transaction.children("div").eq(0).children("div").eq(0).find("span").text(); | |
| let amount = transaction.children("div").eq(0).children("div").eq(1).find("span").text(); | |
| let order = transaction.children("div").eq(1).find("a.a-link-normal"); | |
| return { | |
| date: date, | |
| payment_method: payment_method, | |
| amount: amount, | |
| order_no: order.text(), | |
| order_url: order.attr("href") | |
| }; | |
| } | |
| function parse_page() { | |
| var transactions = new Array(); | |
| var elements = $('div.apx-transaction-date-container').add('div.apx-transactions-line-item-component-container'); | |
| var last_date = ""; | |
| elements.each(function() { | |
| if ($(this).hasClass("apx-transaction-date-container")) { | |
| last_date = $(this).find("span").text(); | |
| } else if ($(this).hasClass("apx-transactions-line-item-component-container")) { | |
| transactions.push(parse_transaction($(this), last_date)); | |
| } | |
| }); | |
| return transactions | |
| } | |
| $(document).ready(function() { | |
| $('body').append('<input type="button" value="Fetch transactions" id="CP">') | |
| $("#CP").css("position", "fixed").css("bottom", 0).css("right", 0); | |
| $('#CP').click(function(){ | |
| let transactions = parse_page(); | |
| let file_content = new Blob([JSON.stringify(transactions)], { type: "application/json;charset=utf-8" }); | |
| saveAs(file_content, `${crypto.randomUUID()}.json`); | |
| }); | |
| }); |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
How to use: