Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
mikropsoft authored Jul 3, 2024
1 parent 8162ebc commit bf8047c
Show file tree
Hide file tree
Showing 6 changed files with 2,200 additions and 210 deletions.
1 change: 0 additions & 1 deletion common/functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,6 @@ mount_mirrors() {

# Credits
ui_print "
_______________ _______ _____ __ ____ _______ __
/ __/_ __/ __/ | / / __/ |/ / _ )/ / / __ \/ ___/ //_/
_\ \ / / / _/ | |/ / _// / _ / /__/ /_/ / /__/ ,<
Expand Down
Binary file modified install.zip
Binary file not shown.
4 changes: 2 additions & 2 deletions module.prop
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
id=StevenBlock
name=StevenBlock | Anti-Malware & Ad Blocker
version=v1.2.0
versionCode=21
version=v1.2.1
versionCode=22
author=𝗪𝗜𝗡𝗭𝗢𝗥𝗧
description=StevenBlock protects your device from malware and unwanted ads. This Magisk module keeps your browsers and apps safe from malicious content, so you can enjoy a clean and smooth internet experience.
updateJson=https://raw.githubusercontent.com/mikropsoft/StevenBlock/main/update.json
148 changes: 48 additions & 100 deletions system/bin/script
Original file line number Diff line number Diff line change
@@ -1,114 +1,62 @@
#!/system/bin/sh

# Function to add a host entry
add_host() {
if [ -z "$1" ]; then
echo "Usage: $0 add <hostname>"
exit 1
fi

host="$1"
hosts_file="/etc/hosts"
HOSTS_FILE="/etc/hosts"

if grep -qxF "0.0.0.0 $host" "$hosts_file"; then
echo "Entry for $host already exists in $hosts_file"
else
if echo "0.0.0.0 $host" >> "$hosts_file"; then
echo "Entry for $host added to $hosts_file"
else
echo "Error: Failed to add entry to $hosts_file"
exit 1
fi
fi
# Error handling function
error() {
echo "Error: $1" >&2
exit 1
}

# Function to remove a host entry
remove_host() {
if [ -z "$1" ]; then
echo "Usage: $0 remove <hostname>"
exit 1
fi

word="$1"
hosts_file="/etc/hosts"
temp_file="$(mktemp)"

if grep -qF "$word" "$hosts_file"; then
if grep -vF "$word" "$hosts_file" > "$temp_file"; then
if mv "$temp_file" "$hosts_file"; then
echo "Entry for $word removed from $hosts_file"
else
echo "Error: Failed to update $hosts_file"
rm "$temp_file"
exit 1
fi
else
echo "Error: Failed to create temporary file"
rm "$temp_file"
exit 1
fi
else
echo "No entry found for $word"
fi
# Function to add or remove a host entry
modify_host() {
[ $# -ne 2 ] && error "Usage: $0 $1 <hostname>"
local action=$1 hostname=$2

case $action in
add)
grep -qxF "0.0.0.0 $hostname" "$HOSTS_FILE" &&
echo "Entry for $hostname already exists" ||
{ echo "0.0.0.0 $hostname" >> "$HOSTS_FILE" && echo "Entry for $hostname added"; }
;;
remove)
sed -i "/0\.0\.0\.0 $hostname/d" "$HOSTS_FILE" &&
echo "Entry for $hostname removed" ||
echo "No entry found for $hostname"
;;
esac
}

# Function to update the hosts file
update_hosts() {
PS3='Choose your preferred option: '
options=("Ultimate Hosts" "Daily Hosts" "Quit")
local urls=(
"https://raw.githubusercontent.com/StevenBlack/hosts/master/alternates/fakenews-gambling-porn-social/hosts"
"https://raw.githubusercontent.com/StevenBlack/hosts/master/hosts"
)
local descriptions=(
"Ultimate Hosts (Unified + fakenews + gambling + porn + social)"
"Daily Hosts (Unified = adware + malware)"
)

echo "Select hosts file to download:"
for i in "${!descriptions[@]}"; do
echo "$((i+1))) ${descriptions[$i]}"
done

update_hosts_file() {
local url="$1"
if curl -sf "$url" -o /etc/hosts; then
echo "Successfully updated"
else
echo "Failed to update. Please check your internet connection or try again later."
fi
}
read -p "Enter your choice (1-${#urls[@]}): " choice
[ "$choice" -ge 1 ] && [ "$choice" -le ${#urls[@]} ] || error "Invalid option"

select opt in "${options[@]}"; do
case $opt in
"Ultimate Hosts")
echo "Unified hosts + fakenews + gambling + porn + social"
update_hosts_file "https://raw.githubusercontent.com/StevenBlack/hosts/master/alternates/fakenews-gambling-porn-social/hosts"
break
;;
"Daily Hosts")
echo "Unified hosts = (adware + malware)"
update_hosts_file "https://raw.githubusercontent.com/StevenBlack/hosts/master/hosts"
break
;;
"Quit")
echo "User requested exit"
break
;;
*)
echo "Invalid option $REPLY"
;;
esac
done
if curl -sfL "${urls[$((choice-1))]}" -o "$HOSTS_FILE.tmp"; then
mv "$HOSTS_FILE.tmp" "$HOSTS_FILE" && echo "Hosts file updated successfully" || error "Failed to update hosts file"
else
rm -f "$HOSTS_FILE.tmp"
error "Failed to download hosts file. Check your internet connection."
fi
}

# Main script
if [ $# -lt 1 ]; then
echo "Usage: $0 {add|remove|update} [hostname]"
exit 1
fi

case $1 in
add)
shift
add_host "$@"
;;
remove)
shift
remove_host "$@"
;;
update)
update_hosts
;;
*)
echo "Usage: $0 {add|remove|update} [hostname]"
exit 1
;;
esac
case ${1:-help} in
add|remove) modify_host "$@" ;;
update) update_hosts ;;
*) echo "Usage: $0 {add|remove|update} [hostname]" ;;
esac
Loading

0 comments on commit bf8047c

Please sign in to comment.