ynab-amazon-helper/inspect-page.ts
2025-11-04 12:27:02 -05:00

56 lines
1.9 KiB
TypeScript

/**
* Helper script to inspect the Amazon transactions page HTML
* Run this to see what selectors we should use
*/
const html = await Bun.file('debug-transactions-page.html').text();
// Find all unique class names that might be relevant
const classRegex = /class="([^"]+)"/g;
const classes = new Set<string>();
let match;
while ((match = classRegex.exec(html)) !== null) {
const classList = match[1].split(' ');
classList.forEach(cls => {
if (cls.toLowerCase().includes('transaction') ||
cls.toLowerCase().includes('payment') ||
cls.toLowerCase().includes('order') ||
cls.toLowerCase().includes('item') ||
cls.toLowerCase().includes('amount') ||
cls.toLowerCase().includes('date')) {
classes.add(cls);
}
});
}
console.log('\n=== Relevant Class Names Found ===');
console.log(Array.from(classes).sort().join('\n'));
// Find data-testid attributes
const testIdRegex = /data-testid="([^"]+)"/g;
const testIds = new Set<string>();
while ((match = testIdRegex.exec(html)) !== null) {
testIds.add(match[1]);
}
console.log('\n=== Data-testid Attributes Found ===');
console.log(Array.from(testIds).sort().join('\n'));
// Look for common patterns
console.log('\n=== Page Analysis ===');
console.log(`Total HTML length: ${html.length} characters`);
console.log(`Contains "transaction": ${html.toLowerCase().includes('transaction')}`);
console.log(`Contains "payment": ${html.toLowerCase().includes('payment')}`);
console.log(`Contains "order": ${html.toLowerCase().includes('order')}`);
// Try to find price/amount patterns
const priceRegex = /\$\d+\.\d{2}/g;
const prices = html.match(priceRegex) || [];
console.log(`\nFound ${prices.length} price patterns (e.g., $XX.XX)`);
if (prices.length > 0) {
console.log(`First 10 prices: ${prices.slice(0, 10).join(', ')}`);
}
console.log('\nCheck debug-transactions-page.html to see the full HTML structure');