# Maple the Dog - Chrome Extension

An educational Chrome extension that demonstrates how browser extensions can modify web page content by replacing Trump images and text references with Maple the dog.

## What This Extension Does

- Replaces mentions of "Trump" with "Maple"
- Replaces mentions of "Donald Trump" with "Maple Bacon"
- Attempts to replace Trump images with maple.png (when detected via alt text, title, or filename)

## Installation Instructions

### Step 1: Add Your Dog's Picture
1. Place your `maple.png` image file in the extension folder (same folder as manifest.json)
2. For best results, use a square image (e.g., 512x512 pixels)

### Step 2: Load the Extension in Chrome
1. Open Google Chrome
2. Navigate to `chrome://extensions/`
3. Enable "Developer mode" (toggle in the top-right corner)
4. Click "Load unpacked"
5. Select the folder containing this extension
6. The extension will now be active!

## Files Included

- **manifest.json** - Extension configuration and permissions
- **content.js** - Script that performs the replacements on web pages
- **README.md** - This file
- **maple.png** - Your dog's picture (you need to add this!)

## How It Works (Educational Breakdown)

### Manifest V3
The extension uses Manifest V3, the latest Chrome extension format. Key components:

- **content_scripts**: Runs on all web pages to modify content
- **web_accessible_resources**: Makes maple.png available to web pages
- **host_permissions**: Allows the extension to run on all websites

### Content Script (content.js)
The content script demonstrates several key concepts:

1. **DOM Manipulation**: Traverses the document tree to find and replace text
2. **Image Replacement**: Identifies images by attributes (src, alt, title)
3. **MutationObserver**: Monitors for dynamically added content
4. **chrome.runtime.getURL()**: Accesses extension resources

### Text Replacement
Uses regular expressions to find and replace text while preserving word boundaries:
- `/\bTrump\b/g` - Matches "Trump" as a whole word
- Case-sensitive variations for TRUMP and Donald Trump

### Image Detection
Checks image attributes for Trump-related keywords:
- `src` attribute (URL)
- `alt` attribute (alternative text)
- `title` attribute

## Testing the Extension

Visit news websites or search for "Donald Trump" to see the replacements in action. You should see:
- Text changes from "Trump" to "Maple"
- Text changes from "Donald Trump" to "Maple Bacon"
- Images with Trump-related keywords replaced with maple.png

## Privacy & Permissions

This extension:
- ✅ Runs entirely locally on your computer
- ✅ Does NOT collect any data
- ✅ Does NOT send any information to external servers
- ⚠️ Requires access to all websites to perform replacements

## Troubleshooting

**Images aren't being replaced:**
- Images are only replaced if they have "trump" in their src, alt, or title attributes
- Many images on the web don't have descriptive attributes
- Some sites use lazy loading or dynamic image loading

**Text isn't being replaced:**
- Some websites use shadow DOM or iframes which may not be processed
- JavaScript frameworks may re-render content faster than the extension can modify it

**Extension isn't loading:**
- Make sure all files are in the same folder
- Ensure maple.png is present in the folder
- Check for errors in chrome://extensions/

## Educational Use

This extension is a great example for learning:
- Chrome extension development
- DOM manipulation with JavaScript
- MutationObserver API
- Regular expressions for text processing
- Chrome extension permissions model

## Customization

You can modify this extension to replace other content:
- Change the `textReplacements` array in content.js
- Modify the `mightBeTrumpImage()` function to detect different images
- Add more sophisticated image detection using machine learning APIs

## License

This is an educational example. Feel free to modify and use for learning purposes!
