A Chrome browser extension that helps users make more thoughtful purchasing decisions on Amazon by providing behavioral nudges, delayed gratification tools, and purchase alternatives.
- π― Project Idea & Goal
- π Project Status
- π οΈ Technology Stack
- π Local Development Setup
- π Project Structure
- ποΈ Architecture Overview
- π Privacy & Security
- π CI/CD & Workflows
- π¦ Versioning & Release Management
- π€ Contributing
- ποΈ Data Models
- π Documentation
- π οΈ Troubleshooting
ThinkTwice intervenes at the moment of purchase to help users pause and reconsider whether they truly need an item. The extension appears on Amazon product pages and presents users with:
- Behavioral nudges - Thoughtful prompts to reconsider the purchase
- "Sleep on it" reminders - Set timed reminders to reconsider purchases after 24 hours (or custom durations)
- Alternative considerations - Explore DIY, refurbished, or rental options
- Investment opportunities - Learn about investing the money you save
The extension is designed around behavioral economics principles:
- Delayed gratification: Research shows 3 out of 4 people change their mind within 24 hours
- Conscious consumption: Make intentional decisions rather than impulse purchases
- Financial wellness: Redirect saved money toward long-term goals
- Product page intervention - Overlay appears on Amazon product pages with decision options
- Behavioral nudges - Random nudges displayed to encourage thoughtful consideration
- Three decision paths:
- "I don't really need it" β Investment options view
- "Sleep on it" β Reminder system with browser notifications
- "I need it" β Confirmation and proceed to purchase
- Reminder scheduling with customizable durations:
- 1 minute (debug/testing)
- 1 hour, 6 hours, 24 hours
- 3 days, 1 week
- Product data extraction - Automatically captures product name, price, image, and URL
- Chrome Alarms API integration - Reliable scheduled notifications
- Browser notifications - Alerts when it's time to reconsider
- Extension badge count - Shows number of pending due reminders
- Popup interface - View all pending reminders with actions:
- "Still interested" β Opens product page
- "Not interested" β Dismisses reminder
- Chrome Storage API integration - All data stored locally
- Storage abstraction layer with TypeScript interfaces
- Message passing architecture for content scripts
- Normalized data structure - Products stored separately from reminders
- Investment options flow - UI exists but handlers are basic (console logs only)
- Close/dismiss behavior - Handler exists but needs refinement
- Alternative purchase options - DIY, Refurbished, Rent/Borrow flows
- Settings page - Customize notification preferences and reminder durations
- Statistics dashboard - Track money saved, purchases avoided
- Enhanced nudges system - Context-aware, personalized nudges
- Multi-marketplace support - Expand beyond Amazon (eBay, Walmart, etc.)
- Social features - Share decisions, group savings challenges
See test flow documentation in tests/flows/ for detailed user flow testing scenarios.
- Framework: Plasmo - Modern Chrome Extension framework
- UI Library: React 19 with TypeScript
- Storage: Chrome Storage API (local persistence)
- Notifications: Chrome Alarms & Notifications APIs
- Build Tool: Parcel (via Plasmo)
- Linting: ESLint with TypeScript and React plugins
- Formatting: Prettier with import sorting
- Node.js: Version 22.18.0 (exact version specified in
package.json)node --version # Should output v22.18.0 - npm: Comes with Node.js
- Google Chrome: Latest version
-
Clone the repository
cd /home/verte/Desktop/Thinktwice/plugin-3 -
Install dependencies
npm install
-
Start development server
npm run dev
This will:
- Start Plasmo development server
- Watch for file changes
- Build extension to
build/chrome-mv3-dev/ - Hot reload changes automatically
- Open Chrome and navigate to
chrome://extensions/ - Enable Developer mode (toggle in top-right corner)
- Click "Load unpacked"
- Select the
build/chrome-mv3-dev/directory - The ThinkTwice extension should now appear in your extensions list
- Make changes to source files (
.tsx,.ts,.css) - Plasmo will automatically rebuild
- Reload the extension in Chrome:
- Click the refresh icon on the extension card in
chrome://extensions/ - Or use the keyboard shortcut:
Ctrl+R(Windows/Linux) orCmd+R(Mac) while focused on the extension
- Click the refresh icon on the extension card in
-
Visit an Amazon product page
https://www.amazon.com/dp/B0XXXXXXX -
Test the intervention flow
- ThinkTwice overlay should appear
- Click "Sleep on it" button
- Select a reminder duration (try "1 minute" for quick testing)
- Click "Set Reminder"
-
Test reminder notifications
- Wait for the reminder duration to elapse
- Browser notification should appear
- Extension badge should show "1"
- Click extension icon to see reminder in popup
-
Test reminder actions
- "Still interested" β Opens product page
- "Not interested" β Removes reminder
# Development
npm run dev # Start development server with hot reload
# Production
npm run build # Build production-ready extension
npm run package # Package extension for distribution
# Testing
npm run test:e2e # Run end-to-end tests with Playwright
# Code Quality
npm run lint # Run ESLint
npm run lint:fix # Fix ESLint errors automatically
npm run format # Format code with Prettier
npm run format:check # Check code formattingplugin-3/
βββ .github/ # GitHub configuration
β βββ workflows/ # CI/CD workflows
β β βββ lint-and-format.yml # Code quality checks
β β βββ update-version.yml # Release validation
β β βββ submit.yml # Chrome Web Store submission
β βββ CODEOWNERS # Code ownership configuration
βββ assets/ # Static assets (icons, images)
β βββ icons/ # Extension icons and UI icons (7 files)
βββ components/ # Reusable React components
β βββ Nudge.tsx # Behavioral nudge display
β βββ ui/ # UI component library (10 components)
β βββ Button.tsx
β βββ Card.tsx
β βββ Header.tsx
β βββ Loading.tsx
β βββ Skeleton.tsx
β βββ ... (5 more)
βββ contents/ # Content scripts (injected into web pages)
β βββ amazon.tsx # Main Amazon product page content script
βββ docs/ # Documentation (6 files)
β βββ ARCHITECTURE.md # System architecture overview
β βββ VERSIONING-CHEATSHEET.md # Version management quick reference
β βββ VERSIONING-WORKFLOW.md # Release workflow guide
β βββ chrome-runtime-messages.md # Message passing documentation
β βββ sleep-on-it-implementation.md # Feature implementation details
β βββ desktop-app-integration-plan.md # Desktop app integration plan
βββ hooks/ # Custom React hooks (4 files)
β βββ useStorage.ts # Chrome storage reactive hook
β βββ usePendingReminder.ts # Reminder state management
β βββ useProductPageState.ts # Product page state management
β βββ useGoogleFonts.ts # Google Fonts loading hook
βββ managers/ # Business logic managers (2 files)
β βββ index.ts # Manager exports
β βββ ProductActionManager.ts # Product action orchestration
βββ scripts/ # Build and utility scripts
β βββ validate-tag.sh # Git tag validation script
βββ services/ # Core services (6 files)
β βββ AlarmService.ts # Chrome alarms management
β βββ BadgeService.ts # Extension badge updates
β βββ ChromeMessaging.ts # Message passing utilities
β βββ NotificationService.ts # Browser notifications
β βββ StorageProxyService.ts # Storage proxy for content scripts
β βββ TabService.ts # Tab management operations
βββ storage/ # Storage abstraction layer (4 files)
β βββ IStorage.ts # Storage interface definition
β βββ BrowserStorage.ts # Chrome storage implementation
β βββ types.ts # Data models (Product, Reminder, Settings)
β βββ index.ts # Storage singleton export
βββ types/ # TypeScript type definitions
β βββ messages.ts # Message type definitions
βββ utils/ # Utility functions
β βββ productExtractor.ts # Extract product data from Amazon DOM
β βββ time.ts # Time formatting utilities
βββ views/ # View components (screen-level, 8 files)
β βββ ProductView.tsx # Main decision screen
β βββ IDontNeedIt.tsx # Investment options screen
β βββ SleepOnIt.tsx # Reminder duration selection
β βββ INeedIt.tsx # Confirmation screen
β βββ Celebration.tsx # Success/celebration screen
β βββ CelebrateThoughtfulPurchase.tsx
β βββ EarlyReturnFromSleep.tsx # Early return flow
β βββ BackToAnOldFlame.tsx # Revisit product flow
βββ tests/ # Test files
β βββ e2e/ # End-to-end tests with Playwright (16 files)
β β βββ *.spec.ts # Test specifications
β β βββ fixtures.ts # Test fixtures
β β βββ setup.ts # Test setup
β β βββ page-objects/ # Page object models
β β βββ utils/ # Test utilities
β βββ flows/ # User flow documentation (4 files)
βββ background.ts # Background service worker (295 lines)
βββ popup.tsx # Extension popup (332 lines)
βββ style.css # Global styles
βββ design-system.ts # Design tokens and theme
βββ playwright.config.ts # Playwright test configuration
βββ package.json # Dependencies and scripts
βββ tsconfig.json # TypeScript configuration
βββ .versionrc.json # Changelog generation config
βββ .prettierrc.mjs # Prettier formatting config
βββ eslint.config.mts # ESLint configuration
Amazon Product Page
β
ProductView (Content Script)
β
User clicks "Sleep on it"
β
SleepOnIt View (Duration Selection)
β
productExtractor.ts (Extract product data)
β
BrowserStorage (Save product + reminder)
β
Message to Background Service Worker
β
Chrome Alarms API (Schedule notification)
β
[Time elapses...]
β
Alarm fires β Browser Notification
β
User opens popup β View reminders
β
User takes action β Update reminder status
- Context-aware: Automatically detects execution context (content script vs popup)
- Message passing: Content scripts communicate with background worker for storage operations
- Normalized data: Products stored separately from reminders to avoid duplication
- Type-safe: Full TypeScript interfaces for all data structures
See docs/ARCHITECTURE.md for detailed architecture documentation.
- Local storage only - No data sent to external servers
- No tracking - No analytics or telemetry
- User control - Users can dismiss reminders and clear data
- Minimal data collection - Only stores what's necessary for functionality
The project has three automated workflows:
Runs on every push and pull request to master:
- β Checks code with ESLint
- β Validates formatting with Prettier
- β Uses Node.js 22.18.0
# Run locally before committing
npm run lint # Check for linting errors
npm run lint:fix # Auto-fix linting errors
npm run format:check # Check formatting
npm run format # Auto-format codeRuns when a new version tag is pushed (e.g., v0.0.5):
- β Verifies tag is on
masterbranch - β Validates tag format (semantic versioning:
vX.Y.Z) - β Confirms
package.jsonversion matches tag version
Manual workflow for publishing to Chrome Web Store:
- Builds production extension
- Packages as
.zipfile - Submits to Chrome Web Store using secrets
This project follows Semantic Versioning (SemVer):
- MAJOR version (X.0.0): Breaking changes
- MINOR version (0.X.0): New features (backwards compatible)
- PATCH version (0.0.X): Bug fixes
Current version: 0.1.0
The project uses standard-version for automated versioning and changelog generation.
# Patch release (0.0.4 β 0.0.5) - Bug fixes only
npm run release:patch
# Minor release (0.0.4 β 0.1.0) - New features
npm run release:minor
# Major release (0.0.4 β 1.0.0) - Breaking changes
npm run release:major
# Auto-detect version bump based on commits
npm run release-
Make your changes and commit using Conventional Commits
-
Run release script:
npm run release:patch # or minor/majorThis will:
- Bump version in
package.json - Update
CHANGELOG.mdbased on commits - Create a git commit with message
chore(release): vX.Y.Z - Create a git tag
vX.Y.Z
- Bump version in
-
Push to GitHub:
git push --follow-tags origin master
-
GitHub Actions will validate the release automatically
See docs/VERSIONING-WORKFLOW.md for detailed release procedures.
This project follows Conventional Commits specification:
<type>(<scope>): <subject>
[optional body]
[optional footer]
Types:
feat: New features β appears in changelogfix: Bug fixes β appears in changelogdocs: Documentation changes β appears in changelogrefactor: Code refactoring β appears in changelogperf: Performance improvements β appears in changelogchore: Maintenance tasks β appears in changelogstyle: Formatting, no code change β hiddentest: Test changes β hiddenci: CI/CD changes β appears in changelogbuild: Build system changes β appears in changelog
Examples:
# Feature commit
git commit -m "feat(sleep-on-it): add custom reminder duration input"
# Bug fix commit
git commit -m "fix(notifications): correct badge count calculation"
# Breaking change commit
git commit -m "feat(storage)!: change reminder data model
BREAKING CHANGE: Reminder schema now requires productId field"Changelog configuration is in .versionrc.json.
-
Create a feature branch:
git checkout -b feat/your-feature-name
-
Make changes following the code style
-
Test your changes:
npm run dev # Start dev server # Load extension in Chrome and test manually
-
Lint and format:
npm run lint:fix npm run format
-
Commit using Conventional Commits:
git commit -m "feat(scope): description" -
Push and create Pull Request
- TypeScript: All code must be typed (no
anyunless absolutely necessary) - ESLint: Must pass
npm run lintwith no errors - Prettier: Code must be formatted (run
npm run format) - React Best Practices: Use hooks, functional components, proper prop types
Before submitting a PR, test:
- β Extension loads without errors
- β Product page overlay appears on Amazon
- β All three decision flows work (I don't need it, Sleep on it, I need it)
- β Reminders save and alarms fire correctly
- β Notifications appear at scheduled times
- β Extension popup displays reminders properly
- β No console errors in any context (content script, background, popup)
This project uses Playwright for end-to-end testing:
# Run all E2E tests
npm run test:e2e
# Run specific test file
npx playwright test tests/e2e/sleeponit.spec.ts
# Run tests in headed mode (see browser)
npx playwright test --headed
# Run tests in debug mode
npx playwright test --debugTest Coverage:
- Close flow (closing overlay)
- "I don't need it" flow
- "I need it" flow
- "Sleep on it" flow with reminders
- Extension initialization
- Storage operations
- Product extraction
See automated E2E tests in tests/e2e/ and flow documentation in tests/flows/ for comprehensive testing procedures.
enum ProductState {
SLEEPING_ON_IT = "sleepingOnIt"
I_NEED_THIS = "iNeedThis"
DONT_NEED_IT = "dontNeedIt"
}
{
id: string // Amazon product ID (e.g., "B0XXXXXXX")
name: string // Product title
price: string | null // Price string (e.g., "$99.99")
image: string | null // Product image URL
url: string // Full Amazon product URL
timestamp: number // When saved (Date.now())
marketplace: string // Marketplace identifier (e.g., "amazon.com")
state?: ProductState | null // Product decision state
}{
id: string // UUID for reminder
productId: string // References Product.id
reminderTime: number // When to remind (Date.now() + duration)
duration: number // Duration in milliseconds
status: "pending" | "completed" | "dismissed"
}{
reminderDurations: number[] // Available duration options in ms
defaultDuration: number // Default selected duration in ms
}{
reminders: Reminder[] // Array of all reminders
products: { [productId: string]: Product } // Product map by ID
settings: Settings // User settings
}{
tabId: number | null // Current tab ID
justCreatedReminderId?: string | null // Recently created reminder ID
}- ARCHITECTURE.md - System architecture, data flow, and storage layer design
- VERSIONING-WORKFLOW.md - Release workflow and version management guide
- VERSIONING-CHEATSHEET.md - Quick reference for versioning commands
- chrome-runtime-messages.md - Message passing architecture documentation
- sleep-on-it-implementation.md - Detailed "Sleep on it" feature implementation
- desktop-app-integration-plan.md - Desktop app integration with Agent Forge backend
- Installation: See Local Development Setup
- Testing: See Testing the Extension and
tests/e2e/for automated tests - Architecture: See Architecture Overview and ARCHITECTURE.md
- Release: See Versioning & Release Management
- Contributing: See Contributing
Extension doesn't load:
- Ensure Node.js version is exactly 22.18.0
- Delete
node_modulesandbuilddirectories, reinstall:npm install - Check for errors in
chrome://extensions/console
Overlay doesn't appear on Amazon:
- Verify you're on a product page (URL contains
/dp/or/gp/product/) - Check content script console in DevTools (F12)
- Ensure extension permissions are granted
Reminders don't trigger:
- Check background service worker console for alarm events
- Verify browser notifications are enabled
- Ensure Chrome is running (service worker may sleep but will wake for alarms)
Build fails:
- Ensure you're using exact Node.js version:
nvm use 22.18.0 - Clear Plasmo cache:
rm -rf .plasmo - Reinstall dependencies:
npm ci
Built with Plasmo - The browser extension framework
Copyright Β© 2025 Thinktwiceco
Last Updated: January 28, 2026