Skip to content

Commit 51a74a9

Browse files
committed
repo-wide: changes to the flash script to be able to use different host files
0 parents  commit 51a74a9

File tree

9 files changed

+199
-0
lines changed

9 files changed

+199
-0
lines changed
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#!/sbin/sh
2+
3+
#################
4+
# Initialization
5+
#################
6+
7+
umask 022
8+
9+
# echo before loading util_functions
10+
ui_print() { echo "$1"; }
11+
12+
require_new_magisk() {
13+
ui_print "*******************************"
14+
ui_print " Please install Magisk v20.4+! "
15+
ui_print "*******************************"
16+
exit 1
17+
}
18+
19+
#########################
20+
# Load util_functions.sh
21+
#########################
22+
23+
OUTFD=$2
24+
ZIPFILE=$3
25+
26+
mount /data 2>/dev/null
27+
28+
[ -f /data/adb/magisk/util_functions.sh ] || require_new_magisk
29+
. /data/adb/magisk/util_functions.sh
30+
[ $MAGISK_VER_CODE -lt 20400 ] && require_new_magisk
31+
32+
install_module
33+
exit 0
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
#MAGISK

README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Systemless Adblocker
2+
3+
---
4+
## Overview:
5+
- The ultimate ad blocker, with no user interface
6+
- Added key-selector to choose from different hosts
7+
- Automatically downloads the lastest unified-hosts from [@StevenBlack](https://github.com/StevenBlack/hosts) hosts sources
8+
- Support Magisk & KernelSU
9+
10+
---
11+
## Credits:
12+
- [@topjohnwu](https://github.com/topjohnwu) / Magisk - Magisk Module Template
13+
- [@StevenBlack](https://github.com/StevenBlack) / Base hosts sources
14+
- [@JumbomanXDA](https://github.com/JumbomanXDA) / Custom installation script
15+
- [@gloeyisk](https://github.com/gloeyisk/systemless-hosts) / Original source
134 KB
Binary file not shown.
281 KB
Binary file not shown.

addon/install.sh

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# External Tools
2+
chmod -R 0755 $MODPATH/addon/Volume-Key-Selector/tools
3+
4+
chooseport_legacy() {
5+
[ "$1" ] && local delay=$1 || local delay=3
6+
local error=false
7+
while true; do
8+
timeout 0 $MODPATH/addon/Volume-Key-Selector/tools/$ARCH32/keycheck
9+
timeout $delay $MODPATH/addon/Volume-Key-Selector/tools/$ARCH32/keycheck
10+
local sel=$?
11+
if [ $sel -eq 42 ]; then
12+
return 0
13+
elif [ $sel -eq 41 ]; then
14+
return 1
15+
elif $error; then
16+
abort " No version selected, please restart installation"
17+
else
18+
error=true
19+
fi
20+
done
21+
}
22+
23+
chooseport() {
24+
[ "$1" ] && local delay=$1 || local delay=3
25+
local error=false
26+
while true; do
27+
local count=0
28+
while true; do
29+
timeout $delay /system/bin/getevent -lqc 1 2>&1 > $TMPDIR/events &
30+
sleep 0.5; count=$((count + 1))
31+
if (`grep -q 'KEY_VOLUMEUP *DOWN' $TMPDIR/events`); then
32+
return 0
33+
elif (`grep -q 'KEY_VOLUMEDOWN *DOWN' $TMPDIR/events`); then
34+
return 1
35+
fi
36+
[ $count -gt 30 ] && break
37+
done
38+
if $error; then
39+
export chooseport=chooseport_legacy VKSEL=chooseport_legacy
40+
chooseport_legacy $delay
41+
return $?
42+
else
43+
error=true
44+
echo " "
45+
echo " Volume key not detected, try again"
46+
echo " "
47+
fi
48+
done
49+
}
50+
51+
VKSEL=chooseport

customize.sh

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
#!/system/bin/sh
2+
3+
#
4+
# Systemless Hosts by the
5+
# open source loving GL-DP and all contributors;
6+
# Consolidating and extending hosts files from several well-curated sources
7+
# Systemless Hosts by the open source loving GL-DP and all contributors;
8+
# Consolidating and extending hosts files from several well-curated sources
9+
10+
# Checking for installation environment
11+
install_hosts() {
12+
. $MODPATH/addon/install.sh
13+
ui_print " Install Unified Hosts (UH)?"
14+
ui_print " "
15+
ui_print " Vol+ = Yes"
16+
ui_print " Vol- = No"
17+
ui_print " "
18+
if chooseport; then
19+
ui_print "- Unified Hosts Selected"
20+
HOSTS_URL="https://raw.githubusercontent.com/StevenBlack/hosts/master/hosts"
21+
GIT_URL="https://github.com/StevenBlack/hosts"
22+
ui_print "- Downloading latest hosts file from $GIT_URL"
23+
curl -o $MODPATH/hosts $HOSTS_URL
24+
if [ $? -ne 0 ]; then
25+
ui_print "Error: Failed to download hosts file."
26+
exit 1
27+
fi
28+
else
29+
ui_print " Install UH + fakenews + gambling + social ?"
30+
ui_print " "
31+
ui_print " Vol+ = Yes"
32+
ui_print " Vol- = No"
33+
ui_print " "
34+
if chooseport; then
35+
ui_print "- Unified hosts + fakenews + gambling + social Selected"
36+
HOSTS_URL="https://raw.githubusercontent.com/StevenBlack/hosts/master/alternates/fakenews-gambling-social/hosts"
37+
GIT_URL="https://github.com/StevenBlack/hosts"
38+
ui_print "- Downloading latest hosts file from $GIT_URL"
39+
curl -o $MODPATH/hosts $HOSTS_URL
40+
if [ $? -ne 0 ]; then
41+
ui_print "Error: Failed to download hosts file."
42+
exit 1
43+
fi
44+
else
45+
ui_print " Install Unified hosts + fakenews + gambling + porn + social?"
46+
ui_print " "
47+
ui_print " Vol+ = Yes"
48+
ui_print " Vol- = No"
49+
ui_print " "
50+
if chooseport; then
51+
ui_print "- Unified hosts + fakenews + gambling + porn + social Selected"
52+
HOSTS_URL="https://raw.githubusercontent.com/StevenBlack/hosts/master/alternates/fakenews-gambling-porn-social/hosts"
53+
GIT_URL="https://github.com/StevenBlack/hosts"
54+
ui_print "- Downloading latest hosts file from $GIT_URL"
55+
curl -o $MODPATH/hosts $HOSTS_URL
56+
if [ $? -ne 0 ]; then
57+
ui_print "Error: Failed to download hosts file."
58+
exit 1
59+
fi
60+
else
61+
ui_print "- Exiting"
62+
fi
63+
fi
64+
fi
65+
}
66+
67+
patch_hosts() {
68+
PATH=/system/etc
69+
ui_print "- Patching hosts file"
70+
mkdir -p $MODPATH$PATH
71+
mv -f $MODPATH/hosts $MODPATH$PATH
72+
}
73+
74+
cleanup() {
75+
rm -rf $MODPATH/LICENSE
76+
rm -rf $MODPATH/addon 2>/dev/null
77+
rm -f $MODPATH/install.sh 2>/dev/null
78+
}
79+
80+
run_install() {
81+
unzip -o "$ZIPFILE" -x 'META-INF/*' -d $MODPATH >&2
82+
ui_print " "
83+
ui_print " Installing & patching hosts"
84+
install_hosts
85+
patch_hosts
86+
ui_print " "
87+
ui_print " Cleaning up"
88+
cleanup
89+
ui_print " "
90+
}
91+
92+
run_install

hosts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# This is a dummy host file

module.prop

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
id=systemless_adblocker
2+
name=Systemless Adblocker - Ultimate
3+
version=1.0
4+
versionCode=15
5+
author=burhanverse
6+
description=An efficient ad blocker based on @gloeyisk's systemless-host module with no user interface & the lastest hosts from github@StevenBlack

0 commit comments

Comments
 (0)