Q1还有大半个月结束,不少坛友应该有track自己cff/cf Q1的bonus用了多少的需求,受到Chase Freedom Paypal Tracker - 追踪Q4 5%消费 启发,在 Alienrobot 代码的基础上写了一个Q1 5% bonus的tracker,
function sumBonusTransactions() {
console.log(`Looking for 5% Bonus Category transactions in Q4 2024...`);
const rows = document.querySelectorAll(`[id^="ACTIVITY-dataTableId-row-"]`);
let total = 0;
let foundTransactions = 0;
const bonusCategories = [
// `PAYPAL`, `PET`, `VET`, `MCDONALDS`,
// `CHEWY`, `SPOT & TANGO`, `PETCO`, `PETSMART`,
// `NOMNOMNOW`, `PP*`
`Groceries`,
];
rows.forEach(row => {
try {
const dataValues = row.getAttribute(`data-values`);
if (!dataValues) return;
// Extract date and description first
const firstCommaIndex = dataValues.indexOf(`,`);
const secondCommaIndex = dataValues.indexOf(`,`, firstCommaIndex + 1);
const date = dataValues.substring(0, firstCommaIndex);
cate = "";
const button = row.querySelector('button[id^="select-select"]');
if (button) {
const span = button.querySelector('span');
if (span) {
cate = span.textContent.trim();
}
}
const description = dataValues.substring(firstCommaIndex + 1, secondCommaIndex);
// Find amount pattern with optional negative sign
const amountMatch = dataValues.match(/[-]?\$[\d,]+\.\d{2}/);
const amount = amountMatch ? amountMatch[0] : null;
// Skip if no amount found
if (!amount) return;
// Check for negative values in various formats: -$XX.XX, $-XX.XX, or negative number after parsing
const isNegative = amount.includes(`-`) || amount.startsWith(`($`) || amount.endsWith(`)`);
if (isNegative) return;
const parsedDate = new Date(date);
// Check if it`s Q1 2025 AND in bonus categories
if (parsedDate.getFullYear() === 2025 &&
parsedDate.getMonth() >= 0 &&
parsedDate.getMonth() <= 2 &&
bonusCategories.some(category => cate.includes(category))) {
// Clean amount: remove $, commas, and parentheses
const cleanAmount = amount.replace(/[$,()]/g, ``);
const amountNum = parseFloat(cleanAmount);
if (!isNaN(amountNum) && amountNum > 0) { // Extra check for positive values
if (amountNum < 50000) {
total += amountNum;
foundTransactions++;
const cashback = (amountNum * 0.05).toFixed(2);
const status = row.id.startsWith(`PENDING`) ? `[PENDING]` : `[POSTED]`;
console.log(`${status} Found qualifying transaction: ${date} | ${description} | $${amountNum.toFixed(2)} | Cashback: $${cashback}`);
} else {
console.log(`Warning: Unusually large transaction amount ($${amountNum.toFixed(2)}) found for: ${description}`);
}
}
}
} catch (error) {
console.error(`Error processing row:`, error);
console.error(`Problematic data-values:`, row.getAttribute(`data-values`));
}
});
console.log(`------------------------`);
console.log(`Total spend in bonus categories Q1 2025: $${total.toFixed(2)}`);
console.log(`Estimated UR points earned: ${(total * 5).toFixed(0)}`);
console.log(`Number of qualifying transactions: ${foundTransactions}`);
if (total >= 1500) {
console.log(`You already spent $${total.toFixed(2)} and reached max bonus points!`);
} else {
console.log(`You are $${(1500 - total).toFixed(2)} away from max bonus points`);
}
}
sumBonusTransactions();
最后结果: