Skip to content

Instantly share code, notes, and snippets.

@0x5e
Last active April 26, 2023 08:09
Show Gist options
  • Save 0x5e/344c6a44cffb62d94ca48dcca9adea3f to your computer and use it in GitHub Desktop.
Save 0x5e/344c6a44cffb62d94ca48dcca9adea3f to your computer and use it in GitHub Desktop.
一键关闭微信朋友圈广告
#!/bin/bash
set -e pipefail
uuid=`curl -fsSL "https://open.weixin.qq.com/connect/qrconnect?appid=wxaac6769b766cb943&redirect_uri=http%3A%2F%2Fads.privacy.qq.com%2Foptout%2FwxPassport&response_type=code&scope=snsapi_login&state=gryhphlfgdjhofds#wechat_redirect" | grep 'qrcode-image' | sed -E 's#.*<img class=".*" src="/connect/qrcode/(.*)" />#\1#'`
echo "请使用微信扫码登录..."
echo "二维码地址:https://open.weixin.qq.com/connect/qrcode/$uuid"
while :; do
wx_code=`curl -fsSL "https://long.open.weixin.qq.com/connect/l/qrconnect?uuid=$uuid" | sed -E "s/.*window.wx_code='(.*)';/\1/"`
if [ -n "$wx_code" ]; then
break
fi
sleep 1
done
echo "正在登录..."
cookie=`curl -fsSI "http://ads.privacy.qq.com/optout/wxPassport?code=$wx_code&state=gryhphlfgdjhofds" | grep "Set-Cookie" | sed -E "s/Set-Cookie: (.*); Max-Age=.*/\1/"` # PRI_TOKEN=XXX
echo "登录成功"
target_types=("DEMOGRAPHIC" "REMARKETING" "INTERERST" "DMP") # curl "https://ads.privacy.qq.com/optout/list" -H "Referer: https://privacy.qq.com/ads/optout.html" -H "Cookie: $cookie"
for target_type in ${target_types[@]}; do
curl -fSL "https://ads.privacy.qq.com/optout/add" \
-H "Referer: https://privacy.qq.com/ads/optout.html" \
-H "Cookie: $cookie" \
-H "Content-Type: application/json" \
--data "{\"operateType\":0,\"targetingType\":\"$target_type\"}"
echo ""
done
echo "完成"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment