A lightweight Chrome extension that allows you to dynamically remove unwanted elements from web pages using customizable CSS selectors or XPath.
- Custom CSS Selectors and XPath: Remove elements using CSS selectors or XPath expressions
- Interactive XPath Picker: Pick an element from the active page and add its unique XPath
- Inspector-Style Hover Border: The XPath picker highlights the hovered element with a blue border, light overlay, and nearby tooltip before you click
- Domain Exclusion: Exclude specific domains or URLs from ad removal
- Real-time Monitoring: Automatically removes dynamically loaded ads using MutationObserver
- Side Panel Configuration: Easy-to-use side panel for managing settings
- Persistent Settings: Your configurations are saved and synced across devices
(Coming soon)
- Download or clone this repository
- Open Chrome and navigate to
chrome://extensions/ - Enable "Developer mode" in the top right corner
- Click "Load unpacked" and select the extension directory
- The Dynamic Ad Remover extension should now appear in your extensions list
- Click the extension icon in your browser toolbar to open settings
- In the "Selectors or XPath" textarea, add CSS selectors or XPath expressions (one per line) for elements you want to remove
- To pick an XPath visually, click "Pick XPath", hover an element on the page, then click the blue-highlighted target
- Picked XPath values are appended on a new line and saved automatically
- Press
Escwhile picking to cancel without adding a selector - Examples of common selectors:
div#ad .advert ins.adsbygoogle [data-testid*="ad"] .sponsored-content iframe[src*="googleads"] //*[@id='ad-banner'] /html[1]/body[1]/main[1]/div[2]
- In the "Exclude Domains/Hosts" textarea, add domains or URLs you want to exclude from ad removal
- Examples:
dev.azure.com github.com stackoverflow.com/questions/specific-page
- Configure your selectors and exclusions (see above)
- Click "Save" to store your settings
- The extension automatically applies the saved configuration on matching webpages
- The extension will remove elements matching your selectors or XPath expressions and monitor for new ones
- Click the "Save" button to apply your changes
- The extension will automatically start working on applicable websites
The extension uses three main components:
- Content Script (
content.js): Runs on every webpage and removes elements matching your selectors - Side Panel Interface (
sidebar.html+sidebar.js): Provides the main configuration interface and XPath picker controls - Popup Interface (
popup.html+popup.js): Provides a compact legacy configuration interface - Manifest (
manifest.json): Defines extension permissions and structure
- Uses Manifest V3 for modern Chrome extension compatibility
- Employs MutationObserver to catch dynamically loaded content
- Batches mutation cleanup through
requestAnimationFrame - Stores settings using Chrome's sync storage API
- Supports complex CSS selectors, XPath expressions, and domain-based exclusions
/* Google Ads */
ins.adsbygoogle
div[data-google-query-id]
/* Generic ad containers */
.ad-container
.advertisement
.sponsored
[class*="ad-"]
[id*="ad-"]
/* Social media promoted content */
[data-testid="placementTracking"]
[aria-label*="Sponsored"]# Exclude entire domains
example.com
dev.azure.com
# Exclude specific paths
github.com/settings
stackoverflow.com/questions
The extension requires the following permissions:
- storage: To save your selector and exclusion settings
- scripting: To inject content scripts that remove unwanted elements
- activeTab: To access the current tab when you click the extension icon
- sidePanel: To show the main configuration UI in Chrome's side panel
- tabs: To identify the active tab domain and send picker commands to the page
- Settings are stored with Chrome's
chrome.storage.sync; Chrome may sync them through your Google account if Chrome Sync is enabled - The extension does not send data to developer-operated servers, analytics, or third-party APIs
- The extension only processes the CSS selectors, XPath expressions, and domains you configure
- Fork this repository
- Create your feature branch (
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
This project is licensed under the MIT License - see the LICENSE file for details.
- XPath picker now appends the selected XPath on a new line and saves the current site configuration automatically
- Updated the XPath picker hover highlight to use an inspector-style blue border, light overlay, and cursor-following tooltip
- Updated README and Chrome Web Store metadata for the current XPath picker behavior
- Added interactive XPath picker in the side panel
- Added XPath selector support alongside CSS selectors
- Improved live configuration updates on open tabs
- Hardened storage error handling and import validation
- Improved Manifest V3 badge state handling
- Initial release
- Basic CSS selector-based element removal
- Domain exclusion functionality
- Popup configuration interface
- Real-time content monitoring
If you encounter any issues or have suggestions for improvements, please open an issue on GitHub.
This extension is designed for educational purposes and personal use. Please respect website terms of service and consider supporting content creators through legitimate means.