Skip to content

Latest commit

ย 

History

2 Commits

Folders and files

NameName
Last commit message
Last commit date
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿšซ Website Blocker (Python)

A powerful and simple Python script designed to improve productivity by blocking distracting websites (like Facebook, YouTube, etc.) during specific working hours. The script modifies the system's hosts file to redirect unwanted traffic.

โœจ Features

  • Time-Based Blocking: Automatically blocks websites during "Work Hours" and unblocks them during "Free Time."
  • Customizable List: Easily add or remove websites from the block list.
  • Platform Independent: Works on Windows, macOS, and Linux.
  • Local Execution: No external software or browser extensions required.

๐Ÿ› ๏ธ Tech Stack

  • Language: Python 3.x
  • Module Used: time, datetime (Standard Python libraries).
  • System Logic: File I/O operations on the system's hosts file.

๐Ÿš€ How It Works

The script runs in the background and checks the current time:

  1. During Work Hours: It adds the distracting websites' URLs to the hosts file, mapping them to 127.0.0.1 (localhost).
  2. During Free Time: It removes those lines from the hosts file, allowing normal access.

๐Ÿ“– Getting Started

Prerequisites

You need Administrative/Root privileges to run this script because it modifies system files.

Usage

  1. Clone the repository:
    git clone [https://github.com/wajiharubab648-coder/website-blocker.git](https://github.com/wajiharubab648-coder/website-blocker.git)
    

2. **Run the script as Administrator:**
```bash
python website_blocker.py

๐Ÿ›ค๏ธ Future Roadmap

  • Create a System Tray icon for easy on/off toggle.
  • Add a simple GUI using Tkinter for managing the block list.
  • Support for temporary "Focus Sessions" (Pomodoro style).

๐Ÿ’ก Lessons Learned

  • Understanding how the Operating System handles DNS and the hosts file.
  • Working with Python's file handling (r+ mode) to read and write simultaneously.
  • Handling system-level permissions and background execution.

Developed by Wajiha | BSIT Student | Learning Python & Problem Solving

About

A Python automation script that runs as a background process to block specified websites during scheduled focus hours by dynamically modifying the system hosts file

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages