import os import time import datetime import psutil blacklisted_apps = [ "Telegram.exe", "Discord.exe", "vlc.exe", "WinStore.App.exe" ] blocked_sites = [ "youtube.com", "www.youtube.com", "t.me", "web.telegram.org", "chat.openai.com", "chatgpt.com", "huggingface.co", "github.com", "chat.qwen.ai", "chat.deepseek.com", "civitai.com", "https://chat.deepseek.com/" ] hosts_path = r"C:\Windows\System32\drivers\etc\hosts" redirect_ip = "127.0.0.1" log_file = "blocked_log.txt" CHECK_INTERVAL = 10 def log_event(event): now = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S") with open(log_file, "a", encoding="utf-8") as f: f.write(f"[{now}] {event}\n") def block_websites(): with open(hosts_path, "r+", encoding="utf-8") as file: content = file.read() for site in blocked_sites: entry = f"{redirect_ip} {site}" if entry not in content: file.write(entry + "\n") log_event(f"Blocked site: {site}") print("✅ All websites blocked.") def close_apps(): for proc in psutil.process_iter(["pid", "name"]): try: if proc.info["name"] in blacklisted_apps: os.system(f"taskkill /F /PID {proc.info['pid']}") print(f"⛔ Closed app: {proc.info['name']}") log_event(f"Closed app: {proc.info['name']}") except (psutil.NoSuchProcess, psutil.AccessDenied): continue print("🚀 Anti-Distraction System Active...") block_websites() while True: close_apps() time.sleep(CHECK_INTERVAL)