A production-ready Chrome extension (Manifest V3) that blocks YouTube ads and hides Shorts content with customizable replacement images.
- Automatic Activation: Works immediately on YouTube pages
- Ad Blocking: Removes video ads, banner ads, and sidebar ads
- Shorts Blocking: Hides Shorts shelf, Shorts tab, and Shorts videos in feed
- Custom Replacement Images: Upload your own image to replace blocked ad spaces
- Persistent Settings: User preferences saved with chrome.storage
- Toggle switch for Ad Blocking (ON/OFF)
- Toggle switch for Shorts Blocking (ON/OFF)
- Master toggle to enable/disable all protections
- Image upload with preview
- Real-time status indicator
youtube-ad-blocker/
manifest.json # Extension manifest (Manifest V3)
content.js # Content script for DOM manipulation
popup.html # Popup UI HTML
popup.css # Popup styles
popup.js # Popup logic and storage management
icons/ # Extension icons
icon16.png
icon32.png
icon48.png
icon128.png
icon.svg
images/ # User-uploaded images storage
README.md # This file
-
Download/Clone this repository to your local machine
-
Open Chrome and navigate to
chrome://extensions/ -
Enable Developer Mode by toggling the switch in the top-right corner
-
Click "Load unpacked" button
-
Select the folder containing the extension files (
youtube-ad-blocker) -
The extension should now appear in your extensions list and toolbar
-
Navigate to
chrome://extensions/ -
Enable Developer Mode
-
Click "Pack extension" button
-
Select the extension directory
-
This will generate
.crxand.pemfiles for distribution
-
Navigate to youtube.com
-
The extension automatically activates and:
- Blocks ads (if enabled)
- Hides Shorts content (if enabled)
-
Click the extension icon in the toolbar to:
- Toggle ad blocking
- Toggle Shorts blocking
- Upload a custom replacement image
- View protection status
| Control | Description |
|---|---|
| Block Ads Toggle | Enable/disable ad blocking |
| Block Shorts Toggle | Enable/disable Shorts hiding |
| Enable All Toggle | Master switch for all protections |
| Upload Image | Select custom image (max 1MB) |
| Remove Button | Delete uploaded image |
- Enable "Block Ads" toggle
- Navigate to YouTube homepage
- Verify no banner ads appear at the top
- Play any video
- Verify video ads are skipped automatically
- Enable "Block Shorts" toggle
- Navigate to YouTube homepage
- Verify Shorts shelf is not visible
- Try navigating to
/shortsURL - Verify block message appears
- Click "Upload Image" in popup
- Select a valid image (JPG/PNG, <1MB)
- Verify preview appears
- Navigate to YouTube
- Verify image appears in blocked ad spaces
- Change toggle settings
- Close and reopen browser
- Navigate to YouTube
- Verify settings are preserved
- Navigate to YouTube homepage
- Click on a video
- Click back button
- Verify blocking still works
- No internet connection: Extension waits for page load
- YouTube updates: Extension uses multiple selectors for resilience
- Dynamic content: MutationObserver handles dynamically loaded content
- Multiple tabs: Each tab operates independently
Popup UI chrome.storage Content Script
(popup.html) (sync/local) (content.js)
YouTube DOM
(MutationObs)
- Runs on YouTube pages
- Uses MutationObserver for dynamic content
- Implements ad detection and skipping
- Handles Shorts content hiding
- Communicates with popup via messages
- Clean, modern dark UI
- Toggle switches with visual feedback
- Image upload with preview
- Status indicators
- Toast notifications
- Persists user preferences
- Stores base64-encoded custom images
- Syncs across devices (if using chrome.storage.sync)
- Debounced Processing: Limits DOM manipulation frequency
- Selector Caching: Reduces querySelector calls
- Efficient Observation: Only processes relevant mutations
- Lazy Loading: Waits for body element before initialization
- No external libraries (reduces attack surface)
- Content Security Policy compliant
- Minimal permissions (only youtube.com)
- No data collection or external requests
| Browser | Version | Status |
|---|---|---|
| Chrome | 88+ | Supported |
| Edge | 88+ | Supported |
| Opera | 74+ | Supported |
| Brave | 1.19+ | Supported |
| Firefox | - | Not supported (Manifest V3 only) |
- Check if enabled: Go to
chrome://extensions/and verify toggle is ON - Refresh YouTube: Press F5 to reload the page
- Check permissions: Ensure extension has access to youtube.com
- Console errors: Open DevTools (F12) and check Console for errors
- YouTube may have updated their ad selectors
- Try refreshing the page
- Check if ad blocking toggle is enabled
- Report the issue with specific ad type
- Shorts can appear in various forms (shelf, individual videos)
- Ensure "Block Shorts" toggle is enabled
- Refresh the page after enabling
- Verify image is under 1MB
- Check image format (JPG/PNG only)
- Try re-uploading the image
- Check browser console for errors
No build step required - this is vanilla JavaScript/CSS/HTML.
- ES6+ JavaScript features
- JSDoc comments for functions
- Consistent indentation (2 spaces)
- Semantic HTML5 elements
- BEM-like CSS naming
- Update
manifest.jsonif new permissions needed - Modify
content.jsfor DOM-related features - Update popup files for UI changes
- Test thoroughly on YouTube
This extension is for educational purposes. Use at your own discretion. Blocking ads may impact content creators' revenue.