You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Web Blocker only works for mac and linux distributions #562
Hi! I’d like to work on adding Windows compatibility and improving the current website blocker implementation, which seems limited in its current form.
From what I see, the main issue is the hardcoded hosts file path (/etc/hosts), which only works on Unix-based systems. On Windows, the equivalent path is: C:\Windows\System32\drivers\etc\hosts, and modifying it requires Administrator privileges.
A possible approach would be:
Detect the OS using os.name or platform.system()
Dynamically set the hosts file path based on the OS
Handle permission errors gracefully (e.g., informing the user to run with admin privileges)
Optionally, add DNS cache flushing support on Windows (ipconfig /flushdns)
Improve the structure and readability of the code by refactoring it into a more modular, object-oriented design
I can implement a cross-platform abstraction for managing the hosts file and submit a PR if this approach sounds good.
Please let me know if I can proceed with this 🙂 @DhanushNehru
Hi @AhmadAL-Quraan, thank you for the suggestions! Just a quick update: this repository is currently being transferred to a new owner, so I no longer have management permissions.
If you are looking for any repo to contribute then feel free to check this
Hi @JoseAlbanoGaspar, thanks for the work on this — the cross-platform support is a great improvement.
I’ll build on top of your changes and focus on improving the structure (e.g., making the implementation more modular) and handling edge cases like permission errors and file updates.
I worked on improving the website blocker by refactoring it into a more modular, object-oriented design.
I introduced a WebsiteBlocker class that organizes the main logic into clear methods such as:
is_working_hours()
block_websites()
unblock_websites()
run()
I also improved cross-platform support by handling the hosts file path dynamically through a dedicated method.
To make the script more reliable, I added error handling for permission issues, so it doesn’t fail silently when not run with the required privileges.
On the usability side, I added an interactive interface that allows users to select predefined websites or provide custom domains, instead of modifying the source code directly.
I also improved responsiveness by replacing long fixed delays with shorter checks, and added a cleanup mechanism using signal handling to ensure the hosts file is restored if the script is interrupted.
Overall, these changes aim to improve structure, reliability, and usability, while making the project easier to extend in the future.
Activity
github-actions commentedon Apr 5, 2026
Thank you for raising this issue! Our team will review it soon.
For more queries or discussions or approval of requests, please join the Discord server for further discussion: Discord Link
AhmadAL-Quraan commentedon Apr 9, 2026
Hi! I’d like to work on adding Windows compatibility and improving the current website blocker implementation, which seems limited in its current form.
From what I see, the main issue is the hardcoded hosts file path (
/etc/hosts), which only works on Unix-based systems. On Windows, the equivalent path is:C:\Windows\System32\drivers\etc\hosts, and modifying it requires Administrator privileges.A possible approach would be:
os.nameorplatform.system()ipconfig /flushdns)I can implement a cross-platform abstraction for managing the hosts file and submit a PR if this approach sounds good.
Please let me know if I can proceed with this 🙂 @DhanushNehru
JoseAlbanoGaspar commentedon Apr 9, 2026
Hi! I made a PR a few days ago with a similar structure: #563
If you want, do some improvements on top of that PR.
Best regards
DhanushNehru commentedon Apr 9, 2026
Hi @AhmadAL-Quraan, thank you for the suggestions! Just a quick update: this repository is currently being transferred to a new owner, so I no longer have management permissions.
If you are looking for any repo to contribute then feel free to check this
AhmadAL-Quraan commentedon Apr 9, 2026
@DhanushNehru Thank u for the opportunity, I will definitely give it a try.
AhmadAL-Quraan commentedon Apr 9, 2026
Hi @JoseAlbanoGaspar, thanks for the work on this — the cross-platform support is a great improvement.
I’ll build on top of your changes and focus on improving the structure (e.g., making the implementation more modular) and handling edge cases like permission errors and file updates.
Appreciate the contribution!
AhmadAL-Quraan commentedon Apr 9, 2026
I worked on improving the website blocker by refactoring it into a more modular, object-oriented design.
I introduced a
WebsiteBlockerclass that organizes the main logic into clear methods such as:is_working_hours()block_websites()unblock_websites()run()I also improved cross-platform support by handling the hosts file path dynamically through a dedicated method.
To make the script more reliable, I added error handling for permission issues, so it doesn’t fail silently when not run with the required privileges.
On the usability side, I added an interactive interface that allows users to select predefined websites or provide custom domains, instead of modifying the source code directly.
I also improved responsiveness by replacing long fixed delays with shorter checks, and added a cleanup mechanism using signal handling to ensure the hosts file is restored if the script is interrupted.
Overall, these changes aim to improve structure, reliability, and usability, while making the project easier to extend in the future.
I’d appreciate any feedback 🙂