Skip to content

darkwebdev/amazon-returns

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

13 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Amazon Returns Cost Information - Browser Extension

A browser extension that displays return cost information on Amazon product pages for US (amazon.com) and Germany (amazon.de).

Browser Support

Works in:

  • Chrome, Edge, and other Chromium-based browsers
  • Firefox (version 109+)

Requires Manifest V3 support (Chrome 109+, Firefox 109+).

Features

  • Displays return costs for both defective/damaged items and regular returns
  • Supports Amazon.com (US) and Amazon.de (Germany)
  • Multi-language support (English & German)
  • Detects third-party sellers and fetches their return policies
  • Caches seller policies to reduce repeated fetches
  • Clean, non-intrusive UI that matches Amazon's design

Installation

Development Installation

  1. Install dependencies:
yarn install
  1. Build the extension:
yarn build
  1. Load the extension:

Chrome/Edge:

  • Navigate to chrome://extensions (Chrome) or edge://extensions (Edge)
  • Enable "Developer mode" (toggle in top right)
  • Click "Load unpacked"
  • Select the dist/ folder from this project

Firefox:

  • Navigate to about:debugging#/runtime/this-firefox
  • Click "Load Temporary Add-on"
  • Select the dist/manifest.json file
  • Note: Temporary add-ons in Firefox are removed when the browser closes

Development Mode (Watch)

To automatically rebuild on file changes:

yarn dev

After making changes, reload the extension in chrome://extensions and refresh the Amazon product page.

Testing

Unit Tests (Jest)

yarn test              # Run all tests
yarn test:watch        # Watch mode
yarn test:coverage     # With coverage report

50 tests covering:

  • Policy scraping (Amazon.com and Amazon.de)
  • Seller detection
  • Internationalization (i18n)
  • Edge cases (restocking fees, non-returnable items, paid shipping)

Extension Testing (Puppeteer)

Basic Test

yarn test:extension

Automated integration test:

  • Launches Chrome with the extension loaded
  • Navigates to a real Amazon.de product page
  • Waits for the widget to appear
  • Validates widget content
  • Takes a screenshot (/tmp/extension-test-screenshot.jpg)
  • Keeps browser open for 10 seconds for inspection

Expected output:

πŸŽ‰ Extension test PASSED!
βœ“ Defective section: βœ…
βœ“ Regular section: βœ…
βœ“ Cost information: βœ…

Dynamic URL Testing

# Test with default URLs
yarn test:dynamic

# Test any Amazon product page
yarn node test-dynamic.js "https://www.amazon.de/dp/PRODUCT_ID"

# Examples
yarn node test-dynamic.js "https://www.amazon.com/dp/B0D1XD1ZV3"
yarn node test-dynamic.js "https://www.amazon.de/dp/B0BNQ66ZN1"

Features:

  • βœ… Test any Amazon product URL dynamically
  • βœ… Multiple test cases in one run
  • βœ… Validates widget content automatically
  • βœ… Screenshots saved for each test
  • βœ… Detailed console logs and extension logs
  • βœ… Pass/fail summary report

See TEST_USAGE.md for detailed testing guide.

Manual Testing

  1. Visit Amazon product pages:

  2. Look for the "Return Cost Information" widget near the buy box

  3. Test cases to verify:

    • Products with "FREE Returns" badge (should show free for both)
    • Products without "FREE Returns" badge (should show €6.50-€13.00 for regular returns)
    • Products sold by third-party sellers
    • Different product categories
    • Both amazon.com and amazon.de domains

Project Structure

src/
β”œβ”€β”€ content/
β”‚   β”œβ”€β”€ content.ts           # Main orchestrator
β”‚   β”œβ”€β”€ policyScraper.ts     # Product page policy extraction
β”‚   β”œβ”€β”€ sellerScraper.ts     # Third-party seller detection & scraping
β”‚   β”œβ”€β”€ ui.ts                # Widget creation and injection
β”‚   └── styles.css           # Widget styles
β”œβ”€β”€ shared/
β”‚   β”œβ”€β”€ types.ts             # TypeScript interfaces
β”‚   β”œβ”€β”€ regionDetector.ts    # Amazon domain detection
β”‚   β”œβ”€β”€ policyData.ts        # Static policy guidelines
β”‚   └── i18n.ts              # Language patterns & UI text
└── manifest.json            # Chrome extension manifest

How It Works

  1. Detects Amazon region (amazon.com or amazon.de) and language
  2. Checks if the seller is Amazon or a third-party seller
  3. For third-party sellers: Fetches and parses their return policy from their seller details page
  4. For Amazon-sold items: Scrapes return policy from product page
  5. Paid Shipping Detection (Amazon.de):
    • Defective items: Always free per EU consumer law
    • Regular returns: Free only if "FREE Returns" badge is present
    • Without badge: Shows €6.50-€13.00 shipping cost (customer pays)
  6. Falls back to default regional policies if scraping fails
  7. Displays the information in a clean, color-coded widget
  8. Caches third-party seller policies for 7 days to improve performance

Return Policy Logic (Amazon.de)

Defective/Damaged Items

  • βœ… Always free return shipping (EU consumer law requirement)
  • βœ… 14-day return window

Regular Returns

  • βœ… With "FREE Returns" badge: Free shipping, 14 days
  • ⚠️ Without "FREE Returns" badge: €6.50-€13.00 shipping cost, 14 days
  • ℹ️ The extension detects the absence of the badge and displays the cost

Widget Example (Paid Shipping)

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ RΓΌcksendekosten-Informationen    β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ Defekte/BeschΓ€digte Artikel:     β”‚
β”‚ Kostenlose RΓΌcksendung innerhalb β”‚ ← Green
β”‚ von 14 Tagen                     β”‚
β”‚                                  β”‚
β”‚ RegulΓ€re RΓΌcksendungen:          β”‚
β”‚ Nicht kostenlose RΓΌcksendung     β”‚ ← Red/Orange
β”‚ (€6.50-€13.00 Kosten)            β”‚
β”‚ innerhalb von 14 Tagen           β”‚
β”‚                                  β”‚
β”‚ ⚬ Basierend auf Amazons          β”‚
β”‚   RΓΌckgaberichtlinie             β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Technologies

  • TypeScript
  • Webpack 5
  • Browser Extension Manifest V3
  • WebExtension Polyfill (cross-browser compatibility)
  • Vanilla JavaScript (no frameworks)

Supported Regions

  • United States (amazon.com) - English
  • Germany (amazon.de) - German

Cross-Browser Compatibility

The extension uses webextension-polyfill to ensure consistent behavior across Chrome, Edge, and Firefox:

  • Single codebase: Same code works in all browsers
  • Unified API: Uses standard browser.* namespace (polyfill translates to chrome.* in Chromium browsers)
  • No browser-specific code: All functionality works identically across browsers
  • Single build: The dist/ folder works for all browsers without modification

Technical details:

  • Chrome uses callback-based chrome.* API
  • Firefox uses promise-based browser.* API
  • WebExtension polyfill provides unified promise-based browser.* API for both
  • Manifest V3 is fully supported in Chrome 109+ and Firefox 109+

Development Documentation

See .claude/CHROME_EXTENSION_TESTING.md for comprehensive testing guide.

License

MIT

About

Chrome extension that displays return cost information on Amazon product pages (defective vs regular returns)

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors