-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmod.sh
50 lines (39 loc) · 2.05 KB
/
mod.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/bin/bash
source /etc/profile
set -o errexit
cd "$(cd "$(dirname "$0")"; pwd)"
[ -e './raw-sources' ] && rm -rf ./raw-sources
mkdir ./raw-sources
rm -rf ./origin-files/*.txt
easylist=(
"https://raw.githubusercontent.com/cjx82630/cjxlist/master/cjx-annoyance.txt"
"https://raw.githubusercontent.com/AdguardTeam/FiltersRegistry/master/filters/filter_224_Chinese/filter.txt"
"https://raw.githubusercontent.com/easylist/easylist/gh-pages/easyprivacy.txt"
"https://raw.githubusercontent.com/AdguardTeam/cname-trackers/master/data/combined_original_trackers.txt"
"https://raw.githubusercontent.com/AdguardTeam/FiltersRegistry/master/filters/filter_11_Mobile/filter.txt"
"https://raw.githubusercontent.com/AdguardTeam/AdGuardSDNSFilter/master/Filters/exceptions.txt"
)
for i in "${!easylist[@]}"; do
echo "Start to download easylist-${i}..."
tMark="$(date +'%Y-%m-%d %H:%M:%S %Z')"
curl -o "./raw-sources/easylist-${i}.txt" --connect-timeout 60 -s "${easylist[$i]}"
echo -e "! easylist-${i} $tMark\n! ${easylist[$i]}" >>./origin-files/upstream-easylist.txt
tr -d '\r' <"./raw-sources/easylist-${i}.txt" |
grep -E '^(@@)?\|\|?[a-zA-Z0-9\.\*-]+\.[a-zA-Z\*]+\^(\$[^=]+)?$' |
sed -e "/\^\$elemhide$/d" -e "/\^\$generichide$/d" |
LC_ALL=C sort -u >>./origin-files/upstream-easylist.txt
done
rm -rf ./raw-sources/
sed -r -e '/^!/d' -e 's=^\|\|?=||=' ./origin-files/upstream-easylist.txt |
grep -E '^\|\|[a-zA-Z0-9\.-]+\.[a-zA-Z]+\^(\$[^~]+)?$' | LC_ALL=C sort -u >./origin-files/base-src-easylist.txt
sed -r -e '/^!/d' -e 's=^\|\|?=||=' ./origin-files/upstream-easylist.txt |
grep -E '\|\|([a-zA-Z0-9\.\*-]+)?\*([a-zA-Z0-9\.\*-]+)?\^(\$[^~]+)?$' | LC_ALL=C sort -u >./origin-files/wildcard-src-easylist.txt
sed -r -e '/^!/d' -e 's=^@@\|\|?=@@||=' ./origin-files/upstream-easylist.txt |
grep -E '^@@\|\|[a-zA-Z0-9\.-]+\.[a-zA-Z]+\^' | LC_ALL=C sort -u >./origin-files/whiterule-src-easylist.txt
cd origin-files
cat dead-hosts*.txt | grep -v -E "^(#|\!)" \
| sort \
| uniq >base-dead-hosts.txt
cd ../
php make-addr.php
php ./tools/easylist-extend.php ../anti-ad-easylist.txt