Skip to content

Commit

Permalink
Add changes
Browse files Browse the repository at this point in the history
  • Loading branch information
rentianyu committed Jan 13, 2025
0 parents commit 82b2783
Show file tree
Hide file tree
Showing 30 changed files with 1,904,891 additions and 0 deletions.
40 changes: 40 additions & 0 deletions .github/workflows/blank.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: CI
on:
push:
branches: [ master ]
watch:
types: [started]
schedule:
- cron: 0 * * * *

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
persist-credentials: false
- name: Create local changes
run: |
sudo rm -rf /etc/localtime
sudo ln -s /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
sudo apt-get install -y dos2unix jq fish sed
fish action_fish.sh
- name: Commit files
run: |
git config --local user.email ${{ secrets.MAIL }}
git config --local user.name ${{ secrets.NAME }}
git commit -m "Add changes" -a
git checkout --orphan new_branch
git add -A
git commit -am 'Add changes'
git branch -D master
git branch -m master
git branch -M master
- name: Push changes
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
branch: ${{ github.ref }}
force : true
55 changes: 55 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
[![rentianyu's GitHub stats](https://github-readme-stats.vercel.app/api?username=rentianyu)](https://github.com/anuraghazra/github-readme-stats)

# Ad-set-hosts

<p align="center">
<img alt="Version" src="https://img.shields.io/badge/release-1.0-blue"/>
<a href="https://github.com/rentianyu">
<img alt="Author" src="https://img.shields.io/badge/author-小贝塔-blueviolet"/>
</a>
</p>

## 1. 简介

- 本项目集合多个去广告 `hosts` 去重
- 本项目已实现GitHub Actions 自动更新,每一小时更新一次
- 仅供学习交流和自用,请勿商用,如有侵权,请联系删除
- 交流群:**[点击加入小贝塔教程资源群](https://jq.qq.com/?_wv=1027&k=Ju2X65DC)**

## 2. 使用方法与版本介绍

- 安卓直接替换 `/system/etc/hosts`,或用 `Magisk` 模块刷入
- 电脑勿用,`hosts` 文件过大会造成电脑卡顿
- `AdGuard` 版(只是把原hosts加入到过滤列表)
- `Github版` 文件地址是GitHub的,镜像版方便国内访问

**文件链接地址:**

- hosts :[Github版](https://raw.githubusercontent.com/rentianyu/Ad-set-hosts/master/hosts)[镜像版](https://p.xbta.cc/https://raw.githubusercontent.com/rentianyu/Ad-set-hosts/master/hosts)
- 含 ipv6 hosts :[Github版](https://raw.githubusercontent.com/rentianyu/Ad-set-hosts/master/hosts6)[镜像版](https://p.xbta.cc/https://raw.githubusercontent.com/rentianyu/Ad-set-hosts/master/hosts6)
- adguard:[Github版](https://raw.githubusercontent.com/rentianyu/Ad-set-hosts/master/adguard)[镜像版](https://p.xbta.cc/https://raw.githubusercontent.com/rentianyu/Ad-set-hosts/master/adguard)

## 3. 在此致谢以下引用的hosts源以及@WQY916提供的帮助

1. ~~依然的爱:https://github.com/E7KMbb/AD-hosts~~
2. yhosts:https://github.com/VeleSila/yhosts
3. 大圣净化:https://github.com/jdlingyu/ad-wars
4. 1024_hosts:https://github.com/Goooler/1024_hosts
5. 小贝塔维护hosts:https://github.com/rentianyu/Ad-set-hosts
6. StevenBlack:https://github.com/StevenBlack/hosts
7. ~~海阔影视去广告hosts~~
8. ilpl:https://github.com/ilpl/ad-hosts
9. iOSAdblockList:https://github.com/BlackJack8/iOSAdblockList
10. QuarkList: https://github.com/francis-zhao/quarklist
11. 手机edge浏览器Adblock Plus规则 https://edge.microsoft.com/abusiveadblocking/api/v1/blocklist
12. anti-AD: https://github.com/mrchi/adaway-hosts

## 推荐一个去广告hosts(体积超大超全)

- 冷莫(trli)的规则唯一一个提供全球比较全的库,规则是24小时更新。
- 冷莫规则文件库:[https://hosts.trli.club](https://hosts.trli.club)
- 冷莫规则说明库:[https://github.com/Potterli20/hosts](https://github.com/Potterli20/hosts)

## 访问量

![](http://profile-counter.glitch.me/rentianyu_Ad-set-hosts/count.svg)
122 changes: 122 additions & 0 deletions action_fish.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
#!/bin/env fish
# 下载去广告hosts合并并去重

set h host
set hs hosts
set hs6 hosts6
set adg adguard

# 准备环境
mkdir -p raw
rm -f raw/*
rm -f *adg*
rm -f *host*

# 手机edege浏览器Adblock Plus
echo 1.edge_phone
curl -s https://edge.microsoft.com/abusiveadblocking/api/v1/blocklist | jq -r '.sites[].url' > raw/edge_phone.host
sed -i "s/^/127.0.0.1 /g" raw/edge_phone.host

# iOSAdblockList:https://github.com/BlackJack8/iOSAdblockList
echo 2.iOSAdblock
curl -s https://p.xbta.cc/https://raw.githubusercontent.com/BlackJack8/iOSAdblockList/master/Regular%20Hosts.txt > raw/iOSAdblock.host
sed -i "s/^/127.0.0.1 /g" raw/iOSAdblock.host

# 下载abp 规则到abp
set n 3
for i in (grep ^http rules.txt)
set name (echo "$i" | sed 's/.* //')
set url (echo "$i" | sed 's/ .*//')
echo $n.$name
set n (math $n + 1)
curl -sL "$url" > raw/$name
# curl -sL "https://p.xbta.cc/$url" > raw/$name
end

# 转换换行符
dos2unix -q *
dos2unix -q */*

# 先处理adg
# cat raw/*adg > all.adg
cp -f all.adg adg.host

# 提取adg.host
sed -n '/^||.*\^$/p' all.adg > adg_raw.adg
# sleep 12000
# 获取adg提取的所有host(含有特殊符号,不纯)
sed -ni 's/^||\(.*\)\^$/\1/p' adg.host

# 准备纯域名 host
cat raw/*host > host.host

# 删除空白符和 # 及后
sed -i "s/\s\|#.*//g" host.host

# 删除127.0.0.1、0.0.0.0,获得hosts.host
sed -ni "s/^\(127.0.0.1\|0.0.0.0\)//p" host.host

# 合并adg和hosts的host
cat adg.host host.host > $h

# 删除含有特殊字符的行
sed -i '/\(。\|\/\|@\|*\|\:\|-$\|_\)/d' $h

# 删除没有.的行
sed -i '/\./!d' $h

# 大写转换为小写
sed -i 's/[A-Z]/\L&/g' $h

# 保留 0-9a-z 开头的行
sed -i "/^[0-9a-z]/!d" $h
echo -n "清洗后域名数:" && wc -l $h

# 排序去重 获得标准去重版 host
sort -u $h -o $h

echo -n "去重后(去除误杀前)域名数:" && wc -l $h

# 去除误杀
for i in (cat white.list)
echo "======$i======"
grep $i $h
echo "-.-.-$i-.-.-"
grep -r $i raw $h
sed -i "/$i/d" $h
echo -e "\n--------------------------------\n"
end > white_del.list
# end|tee white_del.list

echo -n "最终域名数:" && wc -l $h

# 使用声明
set statement "# "(date '+%Y-%m-%d %T')"\n# 小贝塔自用,请勿商用\n# 项目地址:https://github.com/rentianyu/Ad-set-hosts\n\n127.0.0.1 localhost\n127.0.0.1 localhost.localdomain\n127.0.0.1 local\n255.255.255.255 broadcasthost\n::1 localhost\n::1 ip6-localhost\n::1 ip6-loopback\nfe80::1 localhost\nff00::0 ip6-localnet\nff00::0 ip6-mcastprefix\nff02::1 ip6-allnodes\nff02::2 ip6-allrouters\nff02::3 ip6-allhosts\n"

# 获得标准版 hosts
cp $h $hs
sed -i "s/^/127.0.0.1 /g" $hs
sed -i "1 i $statement" $hs

# 获得ipv4、ipv6版 hosts
cp $h $hs6
sed -i "s/^/::1 /g" $hs6
cat $hs >>$hs6
# sort $hs6 -o $hs6
sed -i "1 i $statement" $hs6


# 获得 adguard 版规则
cp $h $adg
sed -i '1d;s/^/||/g;s/$/^/g' $adg

# 查看文件大小
echo 查看文件大小 >info.txt
du -sh * >>info.txt

# 查看每个文件行数
echo -e '\n一级文件行数:' >>info.txt
wc -l * >>info.txt
echo -e '\n二级文件行数:' >>info.txt
wc -l */* >>info.txt

Empty file added adg_raw.adg
Empty file.
Loading

0 comments on commit 82b2783

Please sign in to comment.