Last active
December 24, 2025 06:38
-
-
Save coolreader18/495d699cafa5b02181951b3244f47b9c to your computer and use it in GitHub Desktop.
Userscript to convert a walgreens digital receipt to a tab-separated-values document
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 walgreens receipt -> tsv | |
| // @namespace https://github.com/coolreader18 | |
| // @author coolreader18 | |
| // @match https://www.walgreens.com/orderhistory/order/details-ui* | |
| // @grant GM_setClipboard | |
| // @version 1.0 | |
| // @author - | |
| // @require https://cdn.jsdelivr.net/npm/@violentmonkey/shortcut@1 | |
| // @description Convert a walgreens digital receipt to a tab-separated-values document | |
| // ==/UserScript== | |
| function getTSV() { | |
| const setter = "window.__APP_INITIAL_STATE__ ="; | |
| const script = Array.from( | |
| document.querySelectorAll("script:not([src])"), | |
| ).find((s) => s.textContent.trim().startsWith(setter)); | |
| const state = JSON.parse( | |
| script.textContent.trim().slice(setter.length).slice(0, -1), | |
| ); | |
| const { order } = state.purchaseDetails; | |
| const date = order.purchaseDateObj.slice(0, "0000-00-00".length); | |
| const taxRate = ( | |
| order.priceInfo.tax / order.priceInfo.itemSubTotal | |
| ).toPrecision(2); | |
| const tsv = order.items | |
| .map((item) => { | |
| const name = item.productInfo.baseInfo.displayName.trim(); | |
| const qty = item.fulfillmentInfo.quantityPicked; | |
| const price = item.priceInfo.rawTotalSalePrice; | |
| return [date, "Walgreens", "", name, "", "", price, qty, `${taxRate * 100}%`].join("\t"); | |
| }) | |
| .join("\n"); | |
| return tsv; | |
| } | |
| VM.shortcut.register("c-c", () => { | |
| try { | |
| const tsv = getTSV(); | |
| GM_setClipboard(tsv); | |
| console.log(tsv); | |
| } catch (err) { | |
| console.error(err); | |
| } | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment