The Facebook Marketplace CSV Generator Chrome Extension streamlines the process of creating listings for Facebook Marketplace. It leverages OpenAI's vision model to analyze images and automatically generate detailed product descriptions, titles, and other relevant information. This extension bridges the gap between visual content and structured data, saving time for sellers and improving listing quality.
- Image Analysis: Utilizes OpenAI's GPT-4 Vision API to extract product details from images.
- CSV Generation: Automatically creates CSV files compatible with Facebook Marketplace bulk uploads.
- Drag-and-Drop Interface: User-friendly image upload system for easy interaction.
- Customizable Settings: Allows users to manage their OpenAI API key for secure access.
- Test Mode: Facilitates development and debugging without making actual API calls.
The processImages
function in background.js
demonstrates efficient handling of multiple images using Promise.all:
async function processImages(images) {
console.log('Processing images:', images);
const apiKey = await getApiKey();
if (!apiKey) {
throw new Error('OpenAI API key not set. Please set it in the extension settings.');
}
const imageDescriptions = await Promise.all(images.map(processImage));
console.log('Image descriptions:', imageDescriptions);
const csvData = generateCSV(imageDescriptions);
// ... rest of the function
}
This approach allows for concurrent processing of multiple images, significantly reducing overall execution time.
The extension implements a secure method for storing and retrieving the OpenAI API key using Chrome's storage API:
async function getApiKey() {
return new Promise((resolve) => {
chrome.storage.sync.get('openaiApiKey', (data) => {
resolve(data.openaiApiKey);
});
});
}
This method ensures that sensitive information is stored securely and not exposed in the codebase.
The generateCSV
function in background.js
efficiently creates a CSV structure from the processed image descriptions:
function generateCSV(descriptions) {
const csvRows = [['title', 'description', 'price', 'condition', 'category']];
descriptions.forEach(description => {
const rows = parseDescription(description);
csvRows.push(rows);
});
return csvRows.map(row => row.join(',')).join('\n');
}
This function demonstrates a clean approach to data structuring and CSV formatting.
- JavaScript (ES6+)
- Chrome Extension APIs
- OpenAI GPT-4 Vision API
- HTML5 and CSS3 for user interface
- File API for handling image uploads
- Clone the repository:
git clone https://github.com/yourusername/facebook-marketplace-csv-generator.git
- Navigate to
chrome://extensions/
in Google Chrome. - Enable "Developer mode" in the top right corner.
- Click "Load unpacked" and select the directory containing the extension files.
- Configure your OpenAI API key in the extension settings.
- Click the extension icon in your Chrome toolbar.
- Drag and drop image files into the designated area.
- Click "Generate CSV" to process the images and create a CSV file.
- The generated CSV file will automatically download, ready for upload to Facebook Marketplace.
We welcome contributions to improve the Facebook Marketplace CSV Generator!
- Fork the repository.
- Create a new branch for your feature:
git checkout -b feature/AmazingFeature
- Commit your changes:
git commit -m 'Add some AmazingFeature'
- Push to the branch:
git push origin feature/AmazingFeature
- Open a pull request.
Please ensure your code adheres to the existing style and includes appropriate comments.
This project is licensed under the MIT License.
Your Name - [email protected]
Project Link: https://github.com/yourusername/facebook-marketplace-csv-generator