如何通过Chrome扩展移除含April Fools的网页HTML或清空页面
Hey there! Let's break down exactly how to solve both of your April Fools-related issues—no confusing third-party tools needed if you don't want them. Here's what you can do:
If you just need to clean up a single page right now, or want a quick one-click solution for future use, here are two straightforward options:
Option 1: Use Chrome's DevTools Console (Temporary Fix)
- Open Chrome's DevTools by pressing
F12(orCtrl+Shift+Ion Windows/Linux,Cmd+Opt+Ion Mac) - Switch to the Console tab
- Paste this code and hit Enter:
// Grab every element on the page const allElements = document.getElementsByTagName('*'); // Filter elements that contain "April Fools" (case-insensitive) const elementsToRemove = Array.from(allElements).filter(el => el.textContent.toLowerCase().includes('april fools') ); // Delete each matching element from the page elementsToRemove.forEach(el => el.remove());
This will instantly delete any element (paragraphs, divs, images, etc.) that has "April Fools" in its visible text. Note: This fix only lasts until you refresh the page.
Option 2: Create a Bookmarklet (One-Click Reusable Fix)
Save this as a bookmark to quickly run the cleanup on any page:
- Right-click your Chrome bookmarks bar and select Add page
- For the name, use something like "Remove April Fools Content"
- For the URL, paste this wrapped script:
javascript:(function(){const allElements=document.getElementsByTagName('*');const elementsToRemove=Array.from(allElements).filter(el=>el.textContent.toLowerCase().includes('april fools'));elementsToRemove.forEach(el=>el.remove());})();
- Save it. Now whenever you spot unwanted April Fools content, just click the bookmark to wipe those elements instantly.
Since you struggled with Selective Eraser, let's make a dead-simple custom extension that does exactly what you want—no complicated settings required. Here's how:
Step 1: Create the Extension Files
- Make a new folder on your computer (name it something like
AprilFoolsBlocker) - Inside this folder, create two files:
manifest.jsonandcontent.js
Step 2: Edit manifest.json
Copy and paste this into the file—it tells Chrome what your extension does:
{ "manifest_version": 3, "name": "April Fools Blocker", "version": "1.0", "description": "Clears pages containing April Fools content automatically", "content_scripts": [ { "matches": ["<all_urls>"], "js": ["content.js"], "run_at": "document_end" } ] }
Step 3: Edit content.js
This is the script that checks for unwanted content and clears the page:
// Check if the page's text contains "April Fools" (case-insensitive) if (document.body.textContent.toLowerCase().includes('april fools')) { // Empty the entire page document.body.innerHTML = ''; // Optional: Add a custom message (remove this line if you want a totally blank page) document.body.innerHTML = '<h1 style="text-align: center; margin-top: 2rem;">This page has been blocked for containing April Fools content.</h1>'; }
If you want to check the full HTML source (including hidden elements or code comments) instead of just visible text, replace the if condition with:
if (document.documentElement.innerHTML.toLowerCase().includes('april fools')) {
Step 4: Load the Extension into Chrome
- Open Chrome and navigate to
chrome://extensions/ - Toggle on Developer mode (it's a switch in the top-right corner)
- Click Load unpacked and select the
AprilFoolsBlockerfolder you created - That's it! The extension will now run automatically on every page. If it detects "April Fools" content, it'll clear the page right after it loads.
内容的提问来源于stack exchange,提问作者Tim Clemans

