Skip to content

roybarak80/currency-flow

Repository files navigation

CurrencyFlow - Chrome Extension

A fast and reliable Chrome extension that allows you to convert between different currencies using real-time exchange rates with advanced features like tax calculation and custom formulas.

Features

  • Real-time currency conversion with multiple API fallbacks
  • Support for 170+ currencies from reliable sources
  • Fallback API system - If one API is down, automatically tries others
  • Clean, modern UI with smooth interactions
  • Swap currencies with one click
  • Enter key support for quick conversion
  • Error handling and loading states
  • Tax calculation - Add percentage-based taxes to converted amounts
  • Custom formula support - Apply custom mathematical formulas to results
  • Side-by-side comparison - View base conversion, tax amounts, and custom calculations

Installation

  1. Download or clone this repository
  2. Open Chrome and go to chrome://extensions/
  3. Enable "Developer mode" in the top right corner
  4. Click "Load unpacked" and select the folder containing your extension files
  5. The extension should now appear in your Chrome toolbar

Usage

  1. Click on the extension icon in your Chrome toolbar
  2. Enter the amount you want to convert
  3. Select the source currency from the "From" dropdown
  4. Select the target currency from the "To" dropdown
  5. Click "Convert" or press Enter to see the result
  6. Use the swap button (⇄) to quickly switch between currencies

Additional Calculations

Tax Calculation:

  • Check "Add Taxes (%)" to enable tax calculation
  • Enter the tax rate as a percentage (e.g., 8.5 for 8.5%)
  • The extension will show the tax amount and total with tax

Custom Formula:

  • Check "Custom Formula" to enable custom calculations
  • Enter a value or simple formula to add to the converted amount
  • Examples:
    • 1200 (add $1200)
    • -50 (subtract $50)
    • 100 (add $100)
    • 500+200 (add $700)
  • Shows both the formula result and the total (converted amount + formula result)

Files

  • manifest.json - Extension configuration
  • popup.html - Extension popup interface
  • popup.js - JavaScript functionality
  • styles.css - Styling for the popup
  • tests.js - Comprehensive test suite
  • test-runner.html - Test runner interface

API

This extension uses multiple currency APIs with automatic fallback:

Primary APIs

  1. Frankfurter API - Free, no authentication required
  2. ExchangeRate-API - Free tier available
  3. CurrencyAPI - Free tier available

Fallback System

  • If the primary API (Frankfurter) is unavailable, the extension automatically tries the next API
  • This ensures the extension continues working even if one service is down
  • All APIs are free and don't require API keys for basic usage

Troubleshooting

  • If you see "Error loading currencies", check your internet connection
  • If conversion fails, try refreshing the extension or checking the API status
  • Make sure you have selected different currencies for conversion

Development

To modify the extension:

  1. Edit the files as needed
  2. Go to chrome://extensions/
  3. Click the refresh icon on your extension to reload it
  4. Test your changes

Testing

The extension includes a comprehensive test suite:

Running Tests

  1. Open test-runner.html in your browser
  2. Click "Run Unit Tests" to test core functionality
  3. Click "Run Scenarios" to see example use cases
  4. Click "Run All Tests" for complete testing

Test Coverage

  • ✅ Basic currency conversion
  • ✅ Tax calculation with percentage
  • ✅ Custom formula addition
  • ✅ localStorage persistence
  • ✅ Input validation
  • ✅ Error handling
  • ✅ UI state management
  • ✅ Calculation display

Test Scenarios

  1. Basic Conversion: Convert 100 USD to EUR
  2. Tax Calculation: Add 8.5% tax to converted amount
  3. Custom Formula: Add 1200 to converted amount
  4. Combined Calculations: Tax + formula together
  5. Error Handling: Invalid inputs and API errors
  6. Persistence: Settings saved and restored

License

This project is open source and available under the MIT License.

About

A fast and reliable Chrome extension that allows you to convert between different currencies using real-time exchange rates with advanced features like tax calculation and custom formulas.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors