A Chrome extension that intelligently detects and replaces ad spaces with useful, interactive widgets while maintaining the original page layout.
- 🔍 Smart Ad Detection: Automatically identifies ad spaces on web pages
- 🎨 Dynamic Widget Replacement: Replaces ads with beautiful, gradient-styled widgets
- 🛡️ Persistent Protection: Maintains replacements even when ads try to reload
- 🎯 Layout Preservation: Keeps the page structure intact
- 🎪 Shadow DOM Integration: Ensures styles don't conflict with the main page
- 🌈 Random Gradients: Each widget gets a unique, aesthetically pleasing background
- 🎭 Contrast Optimization: Automatically adjusts text and button colors for readability (To be completed)
- Clone the repository:
git clone https://github.com/yourusername/adFriend.git
cd adFriend- Install dependencies:
npm install- Build the extension:
npm run build- Load in Chrome:
- Open Chrome and navigate to
chrome://extensions/ - Enable "Developer mode" in the top right
- Click "Load unpacked"
- Select the
distdirectory from your project
- Open Chrome and navigate to
- Node.js (v14 or higher)
- npm/yarn
- Chrome browser
src/
├── components/ # React components
├── utils/ # Utility functions
├── background/ # Background script
├── content/ # Content scripts
└── manifest.json # Extension manifest
The main component responsible for:
- Detecting ad spaces
- Creating widget mount points
- Managing widget lifecycle
- Handling cleanup
Manages:
- Widget rendering
- Gradient backgrounds
- Contrast calculations
- Component state
# Start development server
npm run dev
# Build for production
npm run build
# Run tests
npm run test
-
Ad Detection
- Content script injects into web pages
- Identifies iframes and common ad patterns
- Determines appropriate replacement locations
-
Widget Mounting
- Creates isolated mount points using Shadow DOM
- Injects React components
- Manages widget lifecycle
-
Protection Mechanism
- Uses MutationObserver to detect changes
- Automatically restores removed widgets
- Handles cleanup on page changes
-
Styling System
- Generates random gradients
- Calculates contrast colors
- Maintains consistent styling
{
"manifest_version": 3,
"name": "adFriend",
"version": "1.0.0",
"action": { "default_popup": "index.html" },
"permissions": ["activeTab", "scripting", "storage"],
"host_permissions": ["<all_urls>"],
"content_scripts": [
{
"matches": ["<all_urls>"],
"js": ["src/content_scripts/main.jsx"]
},
{
"matches": ["<all_urls>"],
"js": ["src/content_scripts/iframe.jsx"],
"all_frames": true,
"match_about_blank": true
}
],
"background": {
"service_worker": "src/background/background.js",
"type": "module"
},
"web_accessible_resources": [
{
"resources": ["assets/*.svg"],
"matches": ["<all_urls>"]
}
]
}Edit the gradients array in ReplacementAd.jsx:
const gradientConfigs = [
{
gradient: 'linear-gradient(45deg, #FF6B6B, #4ECDC4)',
contrast: '#2A2A2A'
},
// Add more gradients...
];- Fork the repository
- Create a feature branch:
git checkout -b feature/my-new-feature- Commit your changes:
git commit -am 'Add some feature'- Push to the branch:
git push origin feature/my-new-feature- Submit a pull request
The extension includes unit tests using React testing library/jest-dom.
# Run all tests
npm run testThis project is licensed under the MIT License - see the LICENSE file for details.
- React team for the excellent framework
- Chrome Extensions team for the comprehensive API
- All contributors and supporters
For issues and feature requests, please use the GitHub issue tracker.