Sustain-a-Buy is a Chrome extension designed for eco-conscious shoppers. It analyzes product pages (specifically Amazon) to provide sustainability insights, including estimated carbon emissions, a sustainability rating, and suggestions for more eco-friendly alternative products.
-
Product Analysis:
Scrapes product details from Amazon, including title, material, and mass. -
Sustainability Scoring:
Uses the Google Generative AI (Gemini) to calculate a sustainability score (0-10) based on product mass and material, along with estimated CO₂ emissions. -
Alternative Suggestions:
Fetches sustainable alternatives for the viewed product with pricing, estimated carbon emissions, and direct product links. -
User-Friendly UI:
Displays real-time analysis with a loading animation during data fetching.
- When visiting an Amazon product page, the extension scrapes the product data and sends it to a background script.
- The scraped data is sent to the frontend where:
- The ProductAnalysis component displays the product name, sustainability rating, and additional insights.
- The AlternativeSuggestions component shows alternative products with relevant details.
- The sustainability score is generated by calling
getSustainabilityScore, which leverages a custom prompt via the Gemini API. - Sustainable alternatives are fetched from Gemini using
getSustainableAlternativesand then parsed to display valid product links and details.
- Navigate to an Amazon product page.
- Click the Sustain-a-Buy extension icon in Chrome.
- The extension will automatically scrape the product details and display: Product analysis with sustainability score and estimated CO₂ emissions. A list of sustainable alternatives with price, emissions, and a link to view each product.
- A loading animation is displayed while data is being fetched.
-
Clone the repository:
git clone https://github.com/yourusername/sustaina-buy.git
-
Open Visual Studio Code and load the project folder.
-
Install dependencies (if any) using: npm install
-
Follow the Chrome Extension packaging instructions to load the unpacked extension into Chrome.
-
Make sure to run the command "node ./server.js" to run the express server for scraping.