Skip to content

IanKulin/clean-image

Repository files navigation

Clean Image Opener

A Firefox browser extension that allows users to open images in new tabs with query parameters stripped from the URL. The extension adds a context menu item when right-clicking on images.

Settings

To configure the extension's settings, go to the Firefox Add-ons page (about:addons), find "Clean Image Opener" in the list, and click the "Options" button.

You can configure the following settings:

  • Switch to the new tab immediately: When checked, the new tab will become the active tab as soon as it's opened.

Files

  • manifest.json: Firefox extension manifest (version 2) defining permissions and background scripts
  • background.js: Main extension logic handling context menu creation and clicks
  • utils.js: stripQueryParameters() that handles URL cleaning
  • test/**: Test suite using Node.js built-in test runner

Development Commands

# Run all tests
npm test

# Run tests in watch mode during development
npm run test:watch

# Run tests with coverage reporting
npm run test:coverage

Build & Package Commands

# Build extension for distribution (creates ZIP file)
npm run build

# Build and create XPI file with version number
npm run package

# Watch for changes and rebuild automatically
npm run build:watch

Packaging Process

The extension uses Mozilla's official web-ext tool for packaging:

  1. npm run build - Creates web-ext-artifacts/clean_image_opener-[version].zip

    • Automatically excludes development files (tests, README, package.json)
    • Validates manifest.json and extension structure
    • Uses proper ZIP compression compatible with Firefox
  2. npm run package - Complete packaging workflow:

    • Runs the build process
    • Renames output to .xpi format with version number
    • Final file: clean-image-opener-1.2.0.xpi

The generated .xpi file is ready for:

  • Upload to Mozilla Add-ons (AMO)
  • Manual installation in Firefox for testing
  • Distribution as unsigned extension for development

Key Implementation Details

The stripQueryParameters() function in utils.js handles complex URL parsing scenarios including:

  • Standard HTTP/HTTPS URLs with proper port handling
  • Special URL protocols (data:, blob:, file:)
  • URLs with authentication credentials
  • Malformed URLs with fallback string splitting
  • IPv6 addresses and internationalized domains

The extension uses Firefox's browser API for context menus and tab management, with error handling for tab creation failures.

About

Firefox add-on to open images in a new tab with query parameters removed.

Resources

License

Stars

Watchers

Forks