DEV Community

Cover image for Chrome Extension: Capture & Generate Components with AI
Allan Carlos
Allan Carlos

Posted on β€’ Edited on

3 2 2 2 2

Chrome Extension: Capture & Generate Components with AI

πŸ“Έ Component Capture - Chrome Extension

Image description

Easily capture individual web elements with a simple hover and click! πŸš€

✨ Features

  • Highlight Elements: Hover over any web component to see a red border.
  • One-Click Screenshot: Click to capture only the selected element.
  • Auto Copy to Clipboard: The screenshot is instantly copied for easy sharing.
  • AI Component Generation: Generate React components from your screenshots using OpenAI.
  • Multiple Component Types: Choose between React, React + Tailwind, or React + Styled Components.
  • Lightweight & Fast: Works seamlessly on any website.
  • Ideal for Developers, Designers & Testers!

πŸ“₯ Installation

  1. Download the Source Code:
   git clone git@github.com:this-is-allan/component-screenshot.git
   cd component-screenshot
Enter fullscreen mode Exit fullscreen mode
  1. Load the Extension in Chrome:

    • Open Chrome and go to chrome://extensions/.
    • Enable Developer Mode (top right).
    • Click Load unpacked and select the project folder.
  2. Start Capturing Screenshots! πŸŽ‰

πŸš€ How to Use

Capturing Screenshots

  1. Click on the Element Screenshot extension icon in the toolbar.
  2. Activate Scan Mode from the popup.
  3. Hover over any element – it will be highlighted with a red border.
  4. Click on the element to take a screenshot.
  5. The image is automatically copied to the clipboard!

Generating React Components

  1. Capture a screenshot of a UI element.
  2. In the extension popup, click "Select" on the screenshot you want to use.
  3. Enter your OpenAI API key (required only once).
  4. Choose the component type (React, React + Tailwind, React + Styled Components).
  5. Click "Generate Component".
  6. Copy the generated code to use in your project!

πŸ› οΈ Technologies Used

  • JavaScript (Vanilla JS)
  • Chrome Extensions API
  • Clipboard API
  • Canvas for Image Processing
  • OpenAI API for AI-powered component generation (using GPT-4o model)

πŸ—οΈ Development Guide

Clone the Repository

git clone https://github.com/this-is-allan/component-screenshot.git
cd component-screenshot
Enter fullscreen mode Exit fullscreen mode

Modify the Extension

  • Edit content.js to adjust element selection behavior.
  • Modify popup.html and popup.js to update the UI.
  • Adjust permissions in manifest.json as needed.

Reload the Extension

After making changes, reload the extension from chrome://extensions/.

πŸ”‘ API Key Security

Your OpenAI API key is stored locally in your browser's storage and is only used to make requests to the OpenAI API. It is never sent to any other server.

πŸ› Issues & Contributions

Feel free to open an issue or submit a Pull Request if you want to improve the extension.

πŸ“œ License

This project is licensed under the MIT License. See the LICENSE file for details.

πŸš€ Enjoy faster, more precise element screenshots and AI-powered component generation!

Hot sauce if you're wrong - web dev trivia for staff engineers

Hot sauce if you're wrong Β· web dev trivia for staff engineers (Chris vs Jeremy, Leet Heat S1.E4)

  • Shipping Fast: Test your knowledge of deployment strategies and techniques
  • Authentication: Prove you know your OAuth from your JWT
  • CSS: Demonstrate your styling expertise under pressure
  • Acronyms: Decode the alphabet soup of web development
  • Accessibility: Show your commitment to building for everyone

Contestants must answer rapid-fire questions across the full stack of modern web development. Get it right, earn points. Get it wrong? The spice level goes up!

Watch Video 🌢️πŸ”₯

Top comments (0)

5 Playwright CLI Flags That Will Transform Your Testing Workflow

  • 0:56 --last-failed
  • 2:34 --only-changed
  • 4:27 --repeat-each
  • 5:15 --forbid-only
  • 5:51 --ui --headed --workers 1

Learn how these powerful command-line options can save you time, strengthen your test suite, and streamline your Playwright testing experience. Click on any timestamp above to jump directly to that section in the tutorial!

πŸ‘‹ Kindness is contagious

Engage with a wealth of insights in this thoughtful article, valued within the supportive DEV Community. Coders of every background are welcome to join in and add to our collective wisdom.

A sincere "thank you" often brightens someone’s day. Share your gratitude in the comments below!

On DEV, the act of sharing knowledge eases our journey and fortifies our community ties. Found value in this? A quick thank you to the author can make a significant impact.

Okay