#!name=知乎
#!desc=某些APP要清除缓存或者重新安装拦截广告才会生效！
#!author=奶思
#!homepage=https://github.com/fmz200/wool_scripts
#!icon=https://raw.githubusercontent.com/fmz200/wool_scripts/main/icons/gif/naisi-01.gif
#!raw-url=https://github.com/fmz200/wool_scripts/raw/main/Loon/plugin/split/partZ/Zhihu.lpx
#!tg-channel=https://t.me/inaisi
#!date=
#############################################

[Argument]
vihu_enable = switch,true,false,tag=知乎-脚本开关

[Rule]
USER-AGENT,AVOS*, REJECT
DOMAIN, appcloud.zhihu.com, REJECT
DOMAIN, appcloud2.in.zhihu.com, REJECT
DOMAIN, mqtt.zhihu.com, REJECT
DOMAIN, sugar.zhihu.com, REJECT
DOMAIN, crash2.zhihu.com, REJECT
DOMAIN, 118.89.204.198, REJECT
IP-CIDR, 118.89.204.198/32, REJECT, no-resolve
IP-CIDR6,2402:4e00:1200:ed00:0:9089:6dac:96b6/128, REJECT, no-resolve


[Rewrite]
DOMAIN, appcloud.zhihu.com, REJECT
DOMAIN, appcloud2.in.zhihu.com, REJECT
DOMAIN, crash2.zhihu.com, REJECT
DOMAIN, mqtt.zhihu.com, REJECT
DOMAIN, sugar.zhihu.com, REJECT
DOMAIN, zxid-m.mobileservice.cn, REJECT
IP-CIDR, 103.41.167.237/32, REJECT, no-resolve
IP-CIDR, 118.89.204.198/32, REJECT, no-resolve
IP-CIDR6, 2402:4e00:1200:ed00:0:9089:6dac:96b6/128, REJECT, no-resolve



[Rewrite]


# 首页 - 悬浮图标、顶部横幅、开屏广告、关注页推荐、推荐信息流、热榜信息流、热榜直播、回答底部卡片
^https:\/\/api\.zhihu\.com\/commercial_api\/(?:answer\/\d+\/bottom-v2|article\/\d+\/bottom-v2|banners_v3\/app_topstory_banner|launch_v2|real_time_launch_v2) reject-dict
^https:\/\/api\.zhihu\.com\/content-distribution-core\/bubble\/common\/settings reject-dict
^https:\/\/api\.zhihu\.com\/(?:moments\/lastread|drama\/hot-drama-list) reject-dict
^https:\/\/api\.zhihu\.com\/root\/window reject-dict
# 会员页面 - 弹窗、悬浮动图
^https:\/\/api\.zhihu\.com\/(?:bazaar\/float_window|market\/popovers_v2) reject-dict
# 我的页面 - 项目列表、会员卡片
^https:\/\/api\.zhihu\.com\/me\/guides reject-dict
^https:\/\/api\.zhihu\.com\/unlimited\/go\/my_card reject
# 搜索页 - 关键词、猜你想搜
^https:\/\/api\.zhihu\.com\/search\/(hot_search|preset_words) reject-dict
^https:\/\/api\.zhihu\.com\/search\/recommend_query\/v2\? response-body-replace-regex "recommend_queries":\{.+\} "recommend_queries":{}
^https:\/\/www\.zhihu\.com\/api\/v4\/search\/related_queries\/(?:article|answer)\/\d+ reject-dict
# 回答详情页 - 评论区顶部、下一个回答
^https:\/\/api\.zhihu\.com\/comment_v5\/(?:articles|answers)\/\d+\/list-headers reject-dict
^https:\/\/api\.zhihu\.com\/prague\/related_suggestion_native\/feed\? reject-dict
^https:\/\/api\.zhihu\.com\/v5\.1\/topics\/answer\/\d+\/relation reject-dict
# 其他 - 服务器推送配置
^https:\/\/api\.zhihu\.com\/ab\/api\/v1\/products\/zhihu\/platforms\/ios\/config reject
^https:\/\/api\.zhihu\.com\/ad-style-service\/request reject-dict
^https:\/\/appcloud2\.zhihu\.com\/v3\/resource\?group_name=mp reject-dict
^https:\/\/link\.zhihu\.com\/\?target=(?:https?)?(?:%3A|:)?(?:\/\/|%2F%2F)?(.*) 302 http://$1
# 网页版去广告 //www.zhihu.com, zhuanlan.zhihu.com
^https:\/\/api\.zhihu\.com\/distribute\/rhea\/qa_ad_card\/h5\/recommendation\? reject-dict
^https:\/\/www\.zhihu\.com\/api\/v4\/hot_recommendation reject
^https:\/\/www\.zhihu\.com\/api\/v4\/mcn\/v2\/linkcards\? reject
^https:\/\/www\.zhihu\.com\/api\/v4/(?:answers|questions)\/\d+/related-readings reject
^https:\/\/www\.zhihu\.com\/commercial_api\/banners_v3\/mobile_banner reject
^https:\/\/zhuanlan\.zhihu\.com\/api\/articles\/\d+\/recommendation reject


[Script]
# 首页 - 悬浮图标、顶部横幅、开屏广告、关注页推荐、推荐信息流、热榜信息流、热榜直播、回答底部卡片、精简顶部标签
http-response ^https:\/\/(?:api|page-info)\.zhihu\.com\/(?:answers|articles)\/v2\/\d+ script-path = https://raw.githubusercontent.com/fmz200/wool_scripts/main/Scripts/zhihu/zhihu.js, requires-body = true, tag = 知乎移除首页推广, enable={vihu_enable}
http-response ^https:\/\/api\.zhihu\.com\/commercial_api\/app_float_layer script-path = https://raw.githubusercontent.com/fmz200/wool_scripts/main/Scripts/zhihu/zhihu.js, requires-body = true, tag = 知乎移除首页推广, enable={vihu_enable}
http-response ^https:\/\/api\.zhihu\.com\/feed\/render\/tab\/config\? script-path = https://raw.githubusercontent.com/fmz200/wool_scripts/main/Scripts/zhihu/zhihu.js, requires-body = true, tag = 知乎移除首页推广, enable={vihu_enable}
http-response ^https:\/\/api\.zhihu\.com\/(?:moments_v3|topstory\/hot-lists\/total|topstory\/recommend) script-path = https://raw.githubusercontent.com/fmz200/wool_scripts/main/Scripts/zhihu/zhihu.js, requires-body = true, tag = 知乎移除首页推广, enable={vihu_enable}
http-response ^https:\/\/api\.zhihu\.com\/root\/tab script-path = https://raw.githubusercontent.com/fmz200/wool_scripts/main/Scripts/zhihu/zhihu.js, requires-body = true, tag = 知乎精简顶部标签, enable={vihu_enable}
http-response ^https:\/\/api\.zhihu\.com\/v2\/topstory\/hot-lists\/everyone-seeing\? script-path = https://raw.githubusercontent.com/fmz200/wool_scripts/main/Scripts/zhihu/zhihu.js, requires-body = true, tag = 知乎移除首页推广, enable={vihu_enable}
# 会员页面 - 弹窗、悬浮动图
http-response ^https:\/\/api\.zhihu\.com\/bazaar\/vip_tab\/header\? script-path = https://raw.githubusercontent.com/fmz200/wool_scripts/main/Scripts/zhihu/zhihu.js, requires-body = true, tag = 知乎移除会员页面推广, enable={vihu_enable}
# 回答详情页 - 评论区顶部、下一个回答
http-response ^https:\/\/api\.zhihu\.com\/next-(?:bff|data|render) script-path = https://raw.githubusercontent.com/fmz200/wool_scripts/main/Scripts/zhihu/zhihu.js, requires-body = true, tag = 知乎移除回答详情页推广, enable={vihu_enable}
http-response ^https:\/\/api\.zhihu\.com\/questions\/\d+(?:\/answers|\/feeds|\?include=) script-path = https://raw.githubusercontent.com/fmz200/wool_scripts/main/Scripts/zhihu/zhihu.js, requires-body = true, tag = 知乎移除回答详情页推广, enable={vihu_enable}
http-response ^https:\/\/www\.zhihu\.com\/api\/v4\/(?:articles|answers)\/\d+\/recommendations?\? script-path = https://raw.githubusercontent.com/fmz200/wool_scripts/main/Scripts/zhihu/zhihu.js, requires-body = true, tag = 知乎移除回答详情页推广, enable={vihu_enable}
# 其他 - 服务器推送配置
http-response ^https:\/\/appcloud2\.zhihu\.com\/v3\/config script-path = https://raw.githubusercontent.com/fmz200/wool_scripts/main/Scripts/zhihu/zhihu.js, requires-body = true, tag = 知乎拦截服务器推送配置, enable={vihu_enable}
http-response ^https:\/\/m-cloud\.zhihu\.com\/api\/cloud\/config\/all\? script-path = https://raw.githubusercontent.com/fmz200/wool_scripts/main/Scripts/zhihu/zhihu.js, requires-body = true, tag = 知乎拦截服务器推送配置, enable={vihu_enable}


[MITM]
hostname = api.zhihu.com, www.zhihu.com, appcloud2.zhihu.com, m-cloud.zhihu.com, zhuanlan.zhihu.com, link.zhihu.com