Skip to content

Instantly share code, notes, and snippets.

@marcolussetti
Last active February 5, 2024 07:10
Show Gist options
  • Save marcolussetti/80b69d49b3f28f31df4b1f1e9d879695 to your computer and use it in GitHub Desktop.
Save marcolussetti/80b69d49b3f28f31df4b1f1e9d879695 to your computer and use it in GitHub Desktop.
American Express Points Rate Calculator
// Amex Rewards Points Rate Calculator
// by Marco Lussetti
// 1. Navigate to https://global.americanexpress.com/rewards/summary
// 2. Choose the month you need to run it on
// 3. Open your Browser Console
// 4. Paste the contents below
// 5. Wait for the script to run (it will keep clicking show more every 0.75s until
// it loaded the entire statement)
// Not so sure you should trust random scripts on the internet with
// being run on your credit card website though!
(() => {
let createRateColumn = () => {
// Add Rate column to table
let rows = document.querySelectorAll(
"#points-summary-table table tr td div button > div"
);
let header = document.querySelector("#points-summary-table table thead");
let headerSpacer = document.querySelector(
"#points-summary-table table thead th:nth-child(6)"
);
headerSpacer.style.width = "0%";
let pointsHeader = document.querySelector(
"#points-summary-table table thead th:nth-child(8)"
);
pointsHeader.style.width = "18%";
pointsHeader.style.textAlign = "center !important";
rows.forEach((row) => {
let spacer = row.querySelector("div:nth-child(6)");
spacer.width = "0%";
let amount = row
.querySelector("div:nth-child(7)")
.textContent.replace("$", "")
.replace("-", "0");
let points = row
.querySelector("div:nth-child(8)")
.textContent.replace(",", "");
var rate;
if (amount === "0" || points === "0" || amount === "" || points === "") {
rate = 0;
} else {
rate = Math.round(parseFloat(points) / parseFloat(amount));
}
let rateCell = document.createElement("div");
rateCell.textContent = `${rate}x`;
rateCell.style.width = "10%";
if (rate >= 5) {
rateCell.style.color = "green";
} else if (rate >= 2) {
rateCell.style.color = "orange";
} else if (rate > 0) {
rateCell.style.color = "red";
} else {
rateCell.style.color = "black";
}
row.appendChild(rateCell);
});
};
let handleShowMore = () => {
let possibleButtons = document.querySelectorAll("button");
let showMoreButton = Array.from(possibleButtons).filter(
(button) => button.textContent === "Show More"
);
if (showMoreButton.length > 0) {
showMoreButton[0].click();
setTimeout(handleShowMore, 750);
} else {
createRateColumn();
}
};
// Find Show More Button
handleShowMore();
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment