A Chrome Extension that automates the extraction of tax lot data from Charles Schwab's positions page, built following Test-Driven Development (TDD) principles.
- Automated Extraction: Automatically clicks through all "Next Steps" buttons and extracts lot details
- Progress Tracking: Visual progress bar and status updates during extraction
- Resume Capability: Can resume interrupted extractions automatically
- Export Options: Export data in JSON or CSV format
- Error Handling: Comprehensive error handling with retry logic
- Storage: Persistent storage using Chrome Storage API
🚀 Install from Chrome Web Store
- Clone or download this repository
- Run
npm run buildto create the distribution package - Open Chrome and navigate to
chrome://extensions/ - Enable "Developer mode" in the top right
- Click "Load unpacked" and select the
distdirectory - The extension icon should appear in your Chrome toolbar
- Navigate to
https://client.schwab.com/app/accounts/positions/#/ - Click the extension icon in your toolbar
- Click "Start Extraction" to begin automated lot detail extraction
- The extension will show progress and highlight the current position being processed
- Once complete, use "Export as JSON" or "Export as CSV" to download your data
schwab-tax-lot-extractor/
├── manifest.json # Extension manifest
├── popup.html # Extension popup UI
├── popup.js # Popup logic and messaging
├── content.js # Main content script
├── background.js # Background service worker
├── styles.css # TailwindCSS styling
├── lib/
│ ├── utils.js # Utility functions
│ ├── extractor.js # Core extraction logic
│ ├── storage.js # Chrome storage operations
│ └── exporter.js # JSON/CSV export functions
├── tests/
│ ├── setup.js # Jest test setup
│ └── unit/ # Unit tests for all modules
├── icons/ # Extension icons (16px, 48px, 128px)
└── package.json # Jest configuration
The extension organizes extracted tax lot data hierarchically:
{
"holdingsAccount_[ID]": [
{
"[SYMBOL]": [
{
"open_date": "MM/DD/YYYY",
"quantity": 100,
"price": 150.00,
"cost_per_share": 150.00,
"market_value": 15000.00,
"cost_basis": 15000.00,
"gain_or_loss": 500.00,
"gain_or_loss_percentage": 3.33,
"holding_period": "Long"
}
]
}
]
}npm run build # Create dist/ folder and .zip file for Chrome Web StoreThis creates:
dist/folder with all extension files ready for developmentschwab-tax-lot-extractor-v{version}.zipready for Chrome Web Store upload
npm test # Run all tests
npm run test:watch # Run tests in watch mode
npm run test:coverage # Run tests with coverage reportThe project maintains 80%+ test coverage across all modules:
- ✅ 52 passing tests
- ✅ Utils, Extractor, Storage, and Exporter modules fully tested
- ✅ TDD approach followed throughout development
The extension uses a message-passing architecture:
- Popup → Background → Content Script for commands
- Content Script → Background → Popup for status updates
- Chrome Storage API for data persistence and state management
- Extraction Engine: Processes Schwab's DOM structure to extract lot details
- State Management: Tracks progress and handles interruption/resume
- Export System: Converts data to JSON/CSV with proper formatting
- Error Handling: Retry logic with exponential backoff for reliability
- Chrome version 88+ (Manifest V3 support)
- Works with Schwab's React-based web application
- Handles dynamic page updates and loading states
- No external network requests
- All data processed locally in the browser
- Sensitive data cleared from memory after export
- Content Security Policy compliant
- Processes each position within 5 seconds
- Handles portfolios with 100+ positions
- Memory usage under 50MB
- Supports concurrent tab usage
- "No buttons found": Ensure you're on the correct Schwab positions page
- Extraction fails: Check that you're logged into Schwab and can see your positions
- Modal doesn't open: Some positions may not have lot details available
The extension includes automatic retry logic and can resume from where it left off if interrupted.
This extension was built using:
- Pure JavaScript (no TypeScript or frameworks)
- TDD methodology (tests written before implementation)
- Vanilla DOM APIs for maximum compatibility
- Chrome Extension Manifest V3
Based on the proven logic from the original bookmarklet script that has been manually tested and validated.