Skip to content

Refactor Website Blocker: OOP design, improved reliability, and better user interaction#564

Open
AhmadAL-Quraan wants to merge 9 commits intowasmerio:mainfrom
AhmadAL-Quraan:improve-web_blocker-structure
Open

Refactor Website Blocker: OOP design, improved reliability, and better user interaction#564
AhmadAL-Quraan wants to merge 9 commits intowasmerio:mainfrom
AhmadAL-Quraan:improve-web_blocker-structure

Conversation

@AhmadAL-Quraan
Copy link
Copy Markdown

@AhmadAL-Quraan AhmadAL-Quraan commented Apr 9, 2026

PR Title

Refactor Website Blocker: OOP design, improved reliability, and better user interaction

Summary

Closes #562

This PR improves the website blocker implementation by refactoring the code into a modular, object-oriented design and enhancing reliability, usability, and maintainability.

Description

This change builds on the existing implementation by improving the internal structure and addressing several limitations in the current script.

The previous implementation relied on a procedural approach with limited error handling and responsiveness. This PR restructures the code into a class-based design, improves user interaction, and ensures safer handling of system modifications.

The changes are as follows:

  • Refactored the script into a WebsiteBlocker class to improve structure and maintainability
  • Added cross-platform hosts file handling inside the class
  • Implemented interactive user input for selecting predefined or custom websites
  • Improved error handling for permission-related issues
  • Fixed a design issue where the hosts file was not restored if the script was interrupted
  • Added a cleanup mechanism using signal handling (Ctrl+C)
  • Improved responsiveness by replacing long sleep intervals with shorter checks
  • Enhanced code readability with type hints and better organization
  • Ensured code quality and consistency by passing flake8 and mypy checks
  • Updated README with usage instructions and project details

Checks

in the repository

  • Made no changes that degrade the functioning of the repository
  • Gave each commit a meaningful title

in the PR

  • Followed the format of the pull_request_template
  • Made the Pull Request focused and well-scoped
  • Tested the changes locally

Thank You,

Ahmad AL-Quraan

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Web Blocker only works for mac and linux distributions

2 participants