2022-06-22 10:54:06 +08:00
|
|
|
|
#!/usr/bin/env bash
|
2023-08-03 17:15:58 +08:00
|
|
|
|
#set -e
|
2022-06-22 10:54:06 +08:00
|
|
|
|
set -x
|
2022-05-25 17:33:15 +08:00
|
|
|
|
# 下载去广告hosts合并并去重
|
|
|
|
|
|
2023-06-08 15:28:38 +08:00
|
|
|
|
# 开启curl代理
|
|
|
|
|
mv ~/.curlrc.bak ~/.curlrc
|
|
|
|
|
|
2022-05-25 17:33:15 +08:00
|
|
|
|
t=host hn=hosts an=adguard
|
|
|
|
|
f=host-full hf=hosts-full af=adguard-full
|
|
|
|
|
|
|
|
|
|
# 转换为 adguard 格式函数
|
|
|
|
|
adguard() {
|
|
|
|
|
sed "1d;s/^/||/g;s/$/^/g" $1
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# 去除误杀函数
|
|
|
|
|
manslaughter(){
|
|
|
|
|
sed -i "/tencent\|c\.pc\|xmcdn\|googletagservices\|zhwnlapi\|samizdat/d" $1
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# 海阔影视 hosts 导入成功
|
|
|
|
|
#curl -s https://gitee.com/qiusunshine233/hikerView/raw/master/ad_v1.txt > $t
|
|
|
|
|
#sed -i 's/\&\&/\n/g' $t
|
|
|
|
|
#curl -s https://gitee.com/qiusunshine233/hikerView/raw/master/ad_v2.txt >> $t
|
|
|
|
|
#sed -i '/\(\/\|@\|\*\|^\.\|\:\)/d;s/^/127.0.0.1 /g' $t && echo "海阔影视 hosts 导入成功"
|
|
|
|
|
|
2022-06-21 14:13:46 +08:00
|
|
|
|
|
|
|
|
|
# 导入hosts格式
|
2022-05-25 17:33:15 +08:00
|
|
|
|
while read i;do curl -s "$i">>$t&&echo "下载成功"||echo "$i 下载失败";done<<EOF
|
2023-02-17 10:34:40 +08:00
|
|
|
|
https://gitlab.com/rainmor/Adhosts-block/-/raw/master/sqwei/hosts
|
2022-05-25 17:33:15 +08:00
|
|
|
|
https://raw.githubusercontent.com/francis-zhao/quarklist/master/dist/hosts
|
2022-06-22 10:38:32 +08:00
|
|
|
|
https://raw.githubusercontent.com/hoshsadiq/adblock-nocoin-list/master/hosts.txt
|
2022-07-11 15:33:58 +08:00
|
|
|
|
https://raw.githubusercontent.com/Cats-Team/AdRules/main/hosts.txt
|
2023-02-17 11:16:19 +08:00
|
|
|
|
https://raw.githubusercontent.com/jdlingyu/ad-wars/master/sha_ad_hosts
|
|
|
|
|
https://raw.githubusercontent.com/ilpl/ad-hosts/master/hosts
|
2023-02-17 11:23:45 +08:00
|
|
|
|
https://raw.githubusercontent.com/neodevpro/neodevhost/master/lite_host
|
2023-07-17 10:06:36 +08:00
|
|
|
|
https://raw.githubusercontent.com/StevenBlack/hosts/master/alternates/fakenews-gambling-social-only/hosts
|
2022-05-25 17:33:15 +08:00
|
|
|
|
EOF
|
2022-07-11 16:22:04 +08:00
|
|
|
|
#https://raw.githubusercontent.com/neodevpro/neodevhost/master/lite_host
|
|
|
|
|
#https://raw.githubusercontent.com/Goooler/1024_hosts/master/hosts
|
|
|
|
|
#https://raw.githubusercontent.com/VeleSila/yhosts/master/hosts
|
2022-06-21 15:40:03 +08:00
|
|
|
|
#https://raw.githubusercontent.com/StevenBlack/hosts/master/hosts
|
2022-06-21 13:52:10 +08:00
|
|
|
|
#https://raw.githubusercontent.com/BlackJack8/iOSAdblockList/master/Regular%20Hosts.txt
|
2022-06-21 11:53:07 +08:00
|
|
|
|
#https://hblock.molinero.dev/hosts
|
|
|
|
|
#https://raw.githubusercontent.com/badmojr/1Hosts/master/Xtra/hosts.txt
|
2022-06-21 11:06:36 +08:00
|
|
|
|
#https://raw.githubusercontent.com/E7KMbb/AD-hosts/master/system/etc/hosts
|
2022-05-25 17:33:15 +08:00
|
|
|
|
|
2022-06-21 14:13:46 +08:00
|
|
|
|
# 域名加速hosts
|
2023-09-12 14:02:20 +08:00
|
|
|
|
curl -s https://raw.githubusercontent.com/521xueweihan/GitHub520/master/hosts | sed "/#/d;s/ \{2,\}/ /g" > gh
|
|
|
|
|
#curl -s https://raw.githubusercontent.com/Cats-Team/AdRules/main/rules/fasthosts.txt | sed "/#/d;s/ \{2,\}/ /g" > gh
|
2023-02-17 10:34:40 +08:00
|
|
|
|
curl -s https://gitlab.com/rainmor/Adhosts-block/-/raw/master/sqwei/hosts_rewrite | sed "/#/d;s/ \{2,\}/ /g" >> gh
|
2022-05-25 17:33:15 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# EnergizedProtection 域名白名单
|
|
|
|
|
#curl -s https://raw.githubusercontent.com/EnergizedProtection/unblock/master/basic/formats/domains.txt | sed "/#/d;s/ \{2,\}/ /g" > wlist
|
|
|
|
|
|
|
|
|
|
# 自己维护的域名白名单
|
2023-02-17 10:34:40 +08:00
|
|
|
|
curl -s https://gitlab.com/rainmor/Adhosts-block/-/raw/master/hosts_allow | sed "/#/d;s/ \{2,\}/ /g" >> wlist
|
2022-05-25 17:33:15 +08:00
|
|
|
|
|
2022-06-16 09:26:00 +08:00
|
|
|
|
# keytoolazy
|
2023-02-03 14:29:08 +08:00
|
|
|
|
#curl -s https://keytoolazy.coding.net/p/hms-core/d/HMS-CORE/git/raw/master/ads/allow.prop | sed "/#/d;s/ \{2,\}/ /g" >> wlist
|
2022-06-16 09:26:00 +08:00
|
|
|
|
|
2022-08-10 10:53:02 +08:00
|
|
|
|
|
|
|
|
|
# 泛域名白名单
|
2023-02-17 10:34:40 +08:00
|
|
|
|
curl -s https://gitlab.com/rainmor/Adhosts-block/-/raw/master/hosts_allow_g | sed "/#/d;s/ \{2,\}/ /g" >> g_wlist
|
2022-08-10 10:53:02 +08:00
|
|
|
|
|
2022-05-25 17:33:15 +08:00
|
|
|
|
# 冷莫 hosts
|
|
|
|
|
# curl -s https://file.trli.club/dns/ad-hosts.txt | sed "/==/d;/^$/d;1d;s/0.0.0.0 /127.0.0.1 /g;/^\:\|^\*/d" > $f
|
|
|
|
|
# curl -s https://file.trli.club/dns/ad-domains.txt | sed "/^#/d" | awk '{print "127.0.0.1 "$0}' > $f
|
|
|
|
|
|
|
|
|
|
# 转换换行符
|
|
|
|
|
dos2unix *
|
|
|
|
|
dos2unix */*
|
|
|
|
|
|
|
|
|
|
# 保留必要 host
|
|
|
|
|
# 只保留 127、0 开头的行
|
|
|
|
|
sed -i "/^\s*\(127\|0\)/!d" $t
|
|
|
|
|
# 删除空白符和 # 及后
|
|
|
|
|
sed -i "s/\s\|#.*//g" $t
|
|
|
|
|
# 删除 127.0.0.1 、 0.0.0.0 、 空行、第一行
|
|
|
|
|
sed -i "s/^\(127.0.0.1\|0.0.0.0\)//g" $t
|
2022-06-21 13:52:10 +08:00
|
|
|
|
|
2022-06-21 14:08:42 +08:00
|
|
|
|
#curl -s https://raw.githubusercontent.com/privacy-protection-tools/anti-AD/master/anti-ad-domains.txt | sed "/#/d;s/ \{2,\}/ /g" >> $t
|
|
|
|
|
|
2022-06-21 14:13:46 +08:00
|
|
|
|
# 导入domain list格式
|
2022-06-21 14:08:42 +08:00
|
|
|
|
while read i;do curl -s "$i">>$t&&echo "下载成功"||echo "$i 下载失败";done<<EOF
|
|
|
|
|
https://raw.githubusercontent.com/privacy-protection-tools/anti-AD/master/anti-ad-domains.txt
|
|
|
|
|
EOF
|
|
|
|
|
|
2022-06-21 13:52:10 +08:00
|
|
|
|
|
2022-06-21 14:08:42 +08:00
|
|
|
|
sed -i "s/\s\|#.*//g" $t
|
2022-07-11 16:00:19 +08:00
|
|
|
|
# 删除 . 或 * 或||开头的
|
2022-07-11 16:14:40 +08:00
|
|
|
|
sed -i "/^\.\|^\*\|^|/d" $t
|
2022-05-25 17:33:15 +08:00
|
|
|
|
|
|
|
|
|
# 使用声明
|
2023-02-17 11:45:07 +08:00
|
|
|
|
statement="# 更新时间:$(date '+%Y-%m-%d %T')\n# 开源地址:https://gitlab.com/rainmor/Adhosts-block.git\n# 严正声明:仅供自用,请勿商用\n\n"
|
2022-05-25 17:33:15 +08:00
|
|
|
|
|
|
|
|
|
# 获得标准去重版 host
|
|
|
|
|
sort -u $t -o $t
|
|
|
|
|
sed -i "/^127.0.0.1$/d;/^0.0.0.0$/d;/^\s*$/d" $t
|
|
|
|
|
|
|
|
|
|
# 去除误杀
|
|
|
|
|
#manslaughter $t
|
|
|
|
|
|
|
|
|
|
# 获得标准版 hosts
|
|
|
|
|
#(echo -e $statement && sed "s/^/127.0.0.1 /g" $t && cat gh) > $hn
|
|
|
|
|
(echo -e $statement && sed "s/^/0.0.0.0 /g" $t && cat gh) > $hn
|
|
|
|
|
#(echo -e $statement && sed "s/^/127.0.0.1 /g" $t) > $hn
|
|
|
|
|
|
|
|
|
|
# 配置域名白名单
|
|
|
|
|
for i in `cat wlist`;do
|
|
|
|
|
sed -i "/0.0.0.0 $i$/d" $hn
|
|
|
|
|
done
|
|
|
|
|
|
2022-08-10 10:53:02 +08:00
|
|
|
|
for i in `cat g_wlist`;do
|
|
|
|
|
sed -i "/0.0.0.0 .*.$i$/d" $hn
|
|
|
|
|
done
|
|
|
|
|
|
2022-05-25 17:33:15 +08:00
|
|
|
|
|
|
|
|
|
# 获得标准 adguard 版规则
|
2022-06-22 14:27:54 +08:00
|
|
|
|
#adguard $t > $an
|
2022-05-25 17:33:15 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# 获得拓展去重版 host
|
|
|
|
|
# cat $t $f | sort -u -o $f
|
|
|
|
|
# sed -i "/^127.0.0.1$/d;/^0.0.0.0$/d;/^\s*$/d" $f
|
|
|
|
|
# manslaughter $f
|
|
|
|
|
# 删除 . 或 * 开头的
|
|
|
|
|
# sed -i "/^\.\|^\*/d" $f
|
|
|
|
|
|
|
|
|
|
# 获得拓展版 hosts
|
|
|
|
|
# (echo -e $statement && sed "s/^/127.0.0.1 /g" $f && cat gh) > $hf
|
|
|
|
|
# (echo -e $statement && sed "s/^/127.0.0.1 /g" $f) > $hf
|
|
|
|
|
|
|
|
|
|
# 清洗 127.0.0.1 127.0.0.1
|
|
|
|
|
# sed -i 's+127.0.0.1 127.0.0.1 +127.0.0.1 +g' $hf
|
|
|
|
|
# cat $hf | sort -u -o $hf
|
|
|
|
|
|
|
|
|
|
# 获得拓展 adguard 版规则
|
|
|
|
|
# adguard $f > $af
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#rm $t $f gh
|
|
|
|
|
#rm $t $f
|
2023-02-03 17:31:41 +08:00
|
|
|
|
rm $t gh wlist g_wlist
|
|
|
|
|
#rm $t gh
|
2023-06-08 15:28:38 +08:00
|
|
|
|
|
|
|
|
|
# 关闭curl代理
|
|
|
|
|
mv ~/.curlrc ~/.curlrc.bak
|