Chase Freedom Flex 2025 Q1 Groceries Tracker - 追踪Q1买菜消费

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();

最后结果:

4 个赞

由于不懂ms(怕撸船被杀)我只有买菜的消费,其他类别的并没有做,欢迎二次开发

或者在页面里面手动把其他qualified的transaction的类别改成groceries也能统计进去

目前只统计了posted transaction

666,看来谭里码农不少

可以详细说说“然后切换到Console标签” 这一步吗

ML Researcher第一次写js :rofl:

Chrome为例,浏览器按F12,在弹出窗口的上面一栏点console,


在下面的 > 后面粘贴代码

不是可以直接看吗

哦 大概是要看pending points :slightly_smiling_face:

Same motivation

有没有一种可能茶色已经做了这个功能 :yaoming:

2 个赞

那很尴尬了 :yaoming:

不过其他类别应该可以在这个基础上跟原帖一样通过description来匹配,但是我一个测试点都没有 :yaoming:

getMonth 是zero based 楼主没测试啊显然。

已更新zs