Skip to content

Commit

Permalink
Added app files [v1.6]
Browse files Browse the repository at this point in the history
  • Loading branch information
Rabixx committed Oct 19, 2021
1 parent 09b87f0 commit 3373f0e
Show file tree
Hide file tree
Showing 7 changed files with 47 additions and 39 deletions.
Binary file modified SimpleWebsiteBlocker.exe
Binary file not shown.
3 changes: 2 additions & 1 deletion assets/CHANGELOG.log
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@
[10.09.2021 - version 1.2] Small changes in source code now it looks cleaner and some bugs were fixed also checking the operating system before running the app was added!
[19.09.2021 - version 1.3] Huuuge update today! we improved the source code to be faster also we added customizing color of the app in settings section check it out!
[26.09.2021 - version 1.4] Added inject option to block websites faster!
[05.10.2021 - version 1.5] Added auto update now app download all files from github and extract them to app folder also config extension was changed to ini
[05.10.2021 - version 1.5] Added auto update now app download all files from github and extract them to app folder also config extension was changed to ini
[19.10.2021 - version 1.6] Now source code is much cleaner and faster
Empty file added assets/lists/.gitkeep
Empty file.
1 change: 0 additions & 1 deletion assets/lists/example.txt

This file was deleted.

2 changes: 1 addition & 1 deletion assets/version.ini
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
[settings]
version = 1.5
version = 1.6
79 changes: 44 additions & 35 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import requests
import logging
import os.path
import ctypes
import time
import sys
import os
Expand All @@ -22,19 +23,6 @@

COLOR = cfg["settings"]["color"]

user_choice = -1
user_choice_block_website = ""
user_choice_unlock_website = ""
user_confirm_choice = ""
user_choice_settings = -1
user_choice_settings_confirm_color = -1
user_choice_settings_confirm_clear = -1
user_choice_settings_choice_list = ""

current_version = "1.5"

version_url = "https://raw.githubusercontent.com/Rabixx/updater/main/version.txt"

win_path = "C:\\Windows\\System32\\drivers\\etc\\hosts"

def on_start():
Expand All @@ -49,25 +37,41 @@ def on_start():

notification.send()

with open(win_path,"w") as m:
m.truncate(0)
with open(win_path,"w") as first_clear:
first_clear.truncate(0)

os.remove("start.tmp")

CONFIG_COLOR = getattr(Fore, COLOR)
print(CONFIG_COLOR)
os.system('cls')
except PermissionError:
logging.warning("Access denied please run SimpleWebsiteBlocker with admin permissions!")
os.system('pause')
sys.exit()
except:
pass

def checkadmin():
try:
isAdmin = (os.getuid() == 0)
except AttributeError:
isAdmin = ctypes.windll.shell32.IsUserAnAdmin() != 0
return isAdmin

def load_config():
CONFIG_COLOR = getattr(Fore, COLOR)
print(CONFIG_COLOR)
os.system('cls')

def main(user_choice,user_choice_block_website,user_choice_unlock_website,win_path,version_url,current_version,user_confirm_choice,user_choice_settings,user_choice_settings_confirm_clear,user_choice_settings_confirm_color,config_path,COLOR,user_choice_settings_choice_list):
def main(win_path):
user_choice = -1
user_choice_block_website = ""
user_choice_unlock_website = ""
user_confirm_choice = ""
user_choice_settings = -1
user_choice_settings_confirm_color = -1
user_choice_settings_confirm_clear = -1
user_choice_settings_choice_list = ""
current_version = "1.6"
version_url = "https://raw.githubusercontent.com/Rabixx/updater/main/version.txt"

while user_choice != 7:
if user_choice == 1:
try:
Expand All @@ -78,8 +82,8 @@ def main(user_choice,user_choice_block_website,user_choice_unlock_website,win_pa
print()
user_choice_block_website = str(input(">>: "))

with open(win_path,"a") as c:
c.writelines("0.0.0.0" + " " + user_choice_block_website + "\n")
with open(win_path,"a") as ch_1:
ch_1.writelines("0.0.0.0" + " " + user_choice_block_website + "\n")

print("website was successfully blocked!")
time.sleep(1)
Expand All @@ -100,11 +104,11 @@ def main(user_choice,user_choice_block_website,user_choice_unlock_website,win_pa
print("to cancel hold CTRL + C in the same moment")
print()
user_choice_unlock_website = str(input(">>: "))
with open(win_path, 'r') as file:
with open(win_path,"r") as file:
lines = file.readlines()

content = f'0.0.0.0 {user_choice_unlock_website}'
with open(win_path, 'w') as file:
with open(win_path, "w") as file:
for line in lines:
if line.strip("\n") != content:
file.write(line)
Expand All @@ -125,8 +129,8 @@ def main(user_choice,user_choice_block_website,user_choice_unlock_website,win_pa
os.system('cls')
print("all the websites that are currently blocked:")
print()
with open(win_path,"r") as a:
lines = a.readlines()
with open(win_path,"r") as ch_3:
lines = ch_3.readlines()

for line in lines:
print(line)
Expand Down Expand Up @@ -382,15 +386,20 @@ def main(user_choice,user_choice_block_website,user_choice_unlock_website,win_pa

if __name__ == "__main__":
if sys.platform.startswith("win"):
try:
on_start()
load_config()
main(user_choice,user_choice_block_website,user_choice_unlock_website,win_path,version_url,current_version,user_confirm_choice,user_choice_settings,user_choice_settings_confirm_clear,user_choice_settings_confirm_color,config_path,COLOR,user_choice_settings_choice_list)
except Exception as ex_6:
os.system('cls')
print(f"[ERROR] {ex_6}")
time.sleep(2)
os.system('cls')
if checkadmin():
try:
on_start()
load_config()
main(win_path)
except Exception as ex_6:
os.system('cls')
print(f"[ERROR] {ex_6}")
time.sleep(2)
os.system('cls')
else:
logging.warning("Please run SimpleWebsiteBlocker with admin permissions!")
os.system('pause')
sys.exit()
else:
logging.warning("SimpleWebsiteBlocker works only on Windows operating system!")
os.system('pause')
Expand Down
1 change: 0 additions & 1 deletion start.tmp

This file was deleted.

0 comments on commit 3373f0e

Please sign in to comment.