Your Kid Sneaking Online Games Again? Try This Anti-Addiction Tool
A Different Kind of Teenager — Chrome Anti-Addiction Extension
Date: 2025-10-25 08:58
Location: Chongqing
---
Click to follow the public account — technical tips delivered promptly!

---
> ❝
> Write a bit of code, and your gaming headaches disappear.
> Got a "little beast" at home obsessed with casual mini-games?
> Last Saturday, I was watching dramas when a relative called:
> “Help! My kid is glued to mini-games, ignores homework, won’t eat — it’s like they’re possessed!”
> Sounds like a typical case of “7k7k / 4399 syndrome.”
> So I spent ten minutes building a Chrome extension: it blocks gaming sites outside allowed hours — no more constant monitoring.
> ❞
---
🎯 Goal: Auto Block Games Outside Allowed Hours

---
Needs Analysis — What Parents Want
After a long chat with my relative, the key requirements were:
- Targeted Blocking: Restrict addictive online mini-game sites only
- Time Management: Allow limited playing hours (e.g., 8–9 PM)
- Friendly Reminder: Explain block reason rather than show an error page
---
Code Implementation — Love in Every Line ❤️
Project Structure
anti-addiction
├── manifest.json # Extension “ID card”
└── background.js # Logic: time checks and blockingFile Roles
- manifest.json — Defines extension details and permissions
- background.js — Determines time limits & intercepts specific sites
---
🚀 GitHub Source Code
- Full code: https://github.com/Teernage/anti-addiction--extension
- Like it? Give a Star ⭐
- Find a bug? Open an issue — I’ll fix it quickly.
---
Step-by-Step Implementation
Step 1 — Create Project Files
- Create folder: `anti-addiction`
- Create file: `manifest.json`
{
"manifest_version": 3,
"name": "Anti-Addiction Game Blocker",
"version": "0.1.0",
"description": "Anti-addiction game interceptor, blocks game loading from sites like 7k7k and 4399.",
"permissions": ["scripting", "tabs", "webNavigation"],
"host_permissions": ["*://*/*"],
"background": {
"service_worker": "background.js"
},
"action": {
"default_title": "Anti-Addiction"
}
}---
background.js — Core Logic
// Blocked domains
const BLOCKED_DOMAINS = ['7k7k.com', '4399.com'];
// Allowed hours: 20:00 - 21:00
const ALLOWED_TIME_RANGE = [20, 21];Key Parameters
- BLOCKED_DOMAINS — List of sites to restrict
- ALLOWED_TIME_RANGE — Permitted gaming hours (24-hour format)
---
Domain Check & Page Injection
function isBlockedUrl(urlString) {
try {
const { hostname } = new URL(urlString);
return BLOCKED_DOMAINS.some(
(domain) => hostname === domain || hostname.endsWith(`.${domain}`)
);
} catch (_) {
return false;
}
}
function injectBlockPage(tabId) {
if (isInAllowedTime()) return;
chrome.scripting.executeScript({
target: { tabId },
func: injectBlockPageContent,
args: [ALLOWED_TIME_RANGE],
}).catch((err) => console.warn('Inject failed:', err));
}
chrome.webNavigation.onCommitted.addListener(({ tabId, url, frameId }) => {
if (frameId !== 0) return;
if (isBlockedUrl(url)) injectBlockPage(tabId);
});
function isInAllowedTime() {
const now = new Date(), hours = now.getHours();
return hours >= ALLOWED_TIME_RANGE[0] && hours < ALLOWED_TIME_RANGE[1];
}
function injectBlockPageContent(timeRange) {
try { window.stop(); } catch (e) { console.warn(e); }
const blockHtml = `
Anti-Addiction Reminder
body { background:#0f172a; color:#e2e8f0; text-align:center; padding:50px; font-family:Arial; }
.container { max-width:520px; margin:auto; background:rgba(30,41,59,0.8); padding:20px; border-radius:12px; }
h1 { font-size:28px; color:#60a5fa; margin-bottom:20px; }
p { font-size:18px; line-height:1.6; }
🎮 Anti-Addiction Reminder
Not in allowed gaming hours.Play between ${timeRange[0]}:00 and ${timeRange[1]}:00 only.
`;
document.open(); document.write(blockHtml); document.close();
}---
Step 2 — Install Extension
- Open `chrome://extensions/` in Chrome
- Enable Developer Mode (top-right)
- Click Load unpacked extension
- Select your project folder
- Installation complete 🎉

---
Step 3 — Test
Open 7k7k.com or 4399.com.
If outside 8–9 PM, you’ll see the friendly blocking page:

---
Personalization
Add More Sites
const BLOCKED_DOMAINS = ['7k7k.com', '4399.com', 'example.com'];Change Allowed Hours
const ALLOWED_TIME_RANGE = [19, 21]; // 7–9 PM---
Technical Highlights
- Lightweight: ~100 lines of code, only 2 files
- Smart: Detects target domains & enforces time windows
- UX-Friendly: Gentle explanations instead of abrupt errors
---
Conclusion
A 10-minute build can tackle serious parenting challenges with minimal technical overhead.

---
Want to scale this?
Integrate AI-powered monitoring, analytics, and publishing via AiToEarn官网 — an open-source global AI content monetization platform supporting multi-platform publishing (Douyin, Kwai, WeChat, Bilibili, Xiaohongshu, Facebook, Instagram, LinkedIn, Threads, YouTube, Pinterest, X) with analytics and AI model rankings.
---
📎 Links: