From b8a924f809e170f0fa4cd8a751b27bed66100f1e Mon Sep 17 00:00:00 2001 From: sve1r Date: Mon, 4 Sep 2023 18:02:16 +0800 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20feat:=20=E4=BC=98=E5=8C=96=E5=8E=BB?= =?UTF-8?q?=E5=B9=BF=E5=91=8A=E7=9B=B8=E5=85=B3=E8=84=9A=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Rewrite/AdBlock/BiliBili.adblock | 24 +- Rewrite/AdBlock/StartUp.adblock | 33 +- Rewrite/AdBlock/TieBa.adblock | 8 + Rewrite/AdBlock/WebAdBlock.adblock | 40 +- Rewrite/AdBlock/Weibo.adblock | 125 +- Scripts/AdBlock/Bilibili/BiliBili.response.js | 17015 ++++++---------- .../AdBlock/Bilibili/BiliBili.response.min.js | 228 +- Scripts/AdBlock/Other/Tieba-2.js | 107 + Scripts/AdBlock/Other/Tieba-2.min.js | 1 + Scripts/AdBlock/Other/Tieba.js | 253 + Scripts/AdBlock/Other/Tieba.min.js | 1 + Scripts/AdBlock/Zhihu/Zhihu.js | 4023 ++-- Scripts/AdBlock/Zhihu/Zhihu.min.js | 2 +- 13 files changed, 9296 insertions(+), 12564 deletions(-) create mode 100644 Rewrite/AdBlock/TieBa.adblock create mode 100644 Scripts/AdBlock/Other/Tieba-2.js create mode 100644 Scripts/AdBlock/Other/Tieba-2.min.js create mode 100644 Scripts/AdBlock/Other/Tieba.js create mode 100644 Scripts/AdBlock/Other/Tieba.min.js diff --git a/Rewrite/AdBlock/BiliBili.adblock b/Rewrite/AdBlock/BiliBili.adblock index 0c03157..f733a7e 100644 --- a/Rewrite/AdBlock/BiliBili.adblock +++ b/Rewrite/AdBlock/BiliBili.adblock @@ -1,6 +1,6 @@ // ==UserScript== // @ScriptName 哔哩哔哩净化[墨鱼版] -// @Author @ddgksf2013, @blackmatrix7, @app2smile, @yjqiang, @kokoryh, @Maasea +// @Author @ddgksf2013, @blackmatrix7, @app2smile, @yjqiang, @kokoryh, @Maasea, @BiliUniverse // @ForHelp 若有屏蔽广告的需求,可公众号后台回复APP名称 // @TaiWanBilibili https://apps.apple.com/tw/app/id1517062289 // @HKBilibili https://apps.apple.com/hk/app/id1517062289 @@ -9,8 +9,8 @@ // @TgChannel https://t.me/ddgksf2021 // @Contribute https://t.me/ddgksf2013_bot // @Feedback 📮 ddgksf2013@163.com 📮 -// @UpdateTime 2023-08-07 -// @ConfigVersion V2.0.124 +// @UpdateTime 2023-08-17 +// @ConfigVersion V2.0.127 // @Attention 如果广告仍然存在,请清除缓存或卸载应用重新安装 // @Attention 如需引用请注明出处,谢谢合作! // @Function 去广告配置(自用,不定期更新) @@ -81,15 +81,15 @@ hostname = -broadcast.chat.bilibili.com, -*cdn*.biliapi.net, -*tracker*.biliapi. # ~ BiliBili_哔哩哔哩_屏蔽DefaultWord@ddgksf2013 ^https?:\/\/(app\.bilibili\.com|grpc\.biliapi\.net)\/bilibili\.app\.interface\.v1\.Search\/Default url reject # ~ BiliBili_哔哩哔哩_搜索去广告@BiliUniverse -^https?:\/\/(grpc\.biliapi\.net|app\.bilibili\.com)\/bilibili\.polymer\.app\.search\.v1\.Search\/SearchAll$ url script-response-body https://cdn.jsdelivr.net/gh/BiliUniverse/ADBlock@main/js/BiliBili.ADBlock.response.js -# ~ BiliBili_哔哩哔哩_交互点赞投票弹幕@BiliUniverse -^https?:\/\/(app\.bilibili\.com|grpc\.biliapi\.net)\/bilibili\.community\.service\.dm\.v1\.DM\/DmView url script-response-body https://cdn.jsdelivr.net/gh/BiliUniverse/ADBlock@beta/js/BiliBili.ADBlock.response.beta.js +^https?:\/\/(grpc\.biliapi\.net|app\.bilibili\.com)\/bilibili\.polymer\.app\.search\.v1\.Search\/SearchAll$ url script-response-body https://cdn.jsdelivr.net/gh/sve1r/Rules-For-Quantumult-X@develop/Scripts/AdBlock/Bilibili/BiliBili.response.min.js +# ~ BiliBili_哔哩哔哩_交互点赞投票弹幕及会员弹幕@BiliUniverse +^https?:\/\/(app\.bilibili\.com|grpc\.biliapi\.net)\/bilibili\.community\.service\.dm\.v1\.DM\/(DmView|DmSegMobile) url script-response-body https://cdn.jsdelivr.net/gh/sve1r/Rules-For-Quantumult-X@develop/Scripts/AdBlock/Bilibili/BiliBili.response.min.js # ~ BiliBili_哔哩哔哩_青少年弹窗@BiliUniverse -^https:\/\/(grpc\.biliapi\.net|app\.bilibili\.com)\/bilibili\.app\.interface\.v1\.Teenagers\/ModeStatus url script-response-body https://cdn.jsdelivr.net/gh/BiliUniverse/ADBlock@main/js/BiliBili.ADBlock.response.js -# ~ BiliBili_哔哩哔哩_UP主推荐广告[适配ipad端]@app2smile@ddgksf2013 -^https?:\/\/(app\.bilibili\.com|grpc\.biliapi\.net)\/bilibili\.app\.view\.v1\.View\/View$ url script-response-body https://cdn.jsdelivr.net/gh/sve1r/Rules-For-Quantumult-X@develop/Scripts/Unlock/BiliBili.proto.min.js -# ~ BiliBili_哔哩哔哩_动态页面去广告@app2smile@kokoryh@ddgksf2013 -^https?:\/\/(app\.bilibili\.com|grpc\.biliapi\.net)\/bilibili\.app\.dynamic\.v2\.Dynamic\/DynAll$ url script-response-body https://cdn.jsdelivr.net/gh/sve1r/Rules-For-Quantumult-X@develop/Scripts/Unlock/BiliBili.proto.min.js +^https:\/\/(grpc\.biliapi\.net|app\.bilibili\.com)\/bilibili\.app\.interface\.v1\.Teenagers\/ModeStatus url script-response-body https://cdn.jsdelivr.net/gh/sve1r/Rules-For-Quantumult-X@develop/Scripts/AdBlock/Bilibili/BiliBili.response.min.js +# ~ BiliBili_哔哩哔哩_UP主推荐广告[适配ipad端]@BiliUniverse +^https?:\/\/(app\.bilibili\.com|grpc\.biliapi\.net)\/bilibili\.app\.(view|viewunite)\.v1\.View\/(View|TFInfo)$ url script-response-body https://cdn.jsdelivr.net/gh/sve1r/Rules-For-Quantumult-X@develop/Scripts/AdBlock/Bilibili/BiliBili.response.min.js +# ~ BiliBili_哔哩哔哩_动态综合页及视频页去广告@BiliUniverse +^https?:\/\/(app\.bilibili\.com|grpc\.biliapi\.net)\/bilibili\.app\.dynamic\.v2\.Dynamic\/Dyn(All|Video)$ url script-response-body https://cdn.jsdelivr.net/gh/sve1r/Rules-For-Quantumult-X@develop/Scripts/AdBlock/Bilibili/BiliBili.response.min.js # ======= BiliNotAdded ======= # @@ -98,4 +98,4 @@ hostname = -broadcast.chat.bilibili.com, -*cdn*.biliapi.net, -*tracker*.biliapi. # ~ BiliBili_哔哩哔哩_繁体CC字幕转中文简体[自行启用hostname=aisubtitle.hdslb.com,i0.hdslb.com]@ddgksf2013 ;^https?:\/\/.*\.hdslb\.com\/bfs\/subtitle\/.+\.json url script-response-body https://github.com/ddgksf2013/Scripts/raw/master/bilibili_cc.js # ~ BiliBili_哔哩哔哩_去除统一设置的皮肤[注释留存]@ddgksf2013 -;^https?:\/\/app\.bilibili\.com\/x\/resource\/show\/skin\? url script-response-body https://cdn.jsdelivr.net/gh/sve1r/Rules-For-Quantumult-X@develop/Scripts/AdBlock/Bilibili/BiliBili.min.js \ No newline at end of file +;^https?:\/\/app\.bilibili\.com\/x\/resource\/show\/skin\? url script-response-body https://cdn.jsdelivr.net/gh/sve1r/Rules-For-Quantumult-X@develop/Scripts/AdBlock/Bilibili/BiliBili.min.js diff --git a/Rewrite/AdBlock/StartUp.adblock b/Rewrite/AdBlock/StartUp.adblock index dc4ea4d..64c8071 100644 --- a/Rewrite/AdBlock/StartUp.adblock +++ b/Rewrite/AdBlock/StartUp.adblock @@ -5,24 +5,25 @@ // @TgBot https://t.me/ddgksf2013_bot // @WechatID 公众号墨鱼手记 // @Feedback 💡 请通过邮件反馈问题『其它方式一概无视』:𝐝𝐝𝐠𝐤𝐬𝐟𝟐𝟎𝟏𝟑@𝟏𝟔𝟑.𝐜𝐨𝐦 💡 -// @UpdateTime 2023-08-13 +// @UpdateTime 2023-09-02 // @Please 如需引用请注明出处,谢谢合作! // @Function 去除APP首页启动广告和部分应用内广告,如果有需要的去除广告的APP,可以公众号后台直接回复 // @ExtraTxt Only provide the removal of open-screen advertisements for personally used apps -// @Attention QuantumultX能去广告,不代表能去所有广告!(应用个数:218) +// @Attention QuantumultX能去广告,不代表能去所有广告!(应用个数:227) // @Mark 名字后面的*代表该应用启动倒计时仍然存在 -// @APPList 无法通过𝐌𝐈𝐓𝐌去广告的应用:银行类[Most]|抖音|蜂巢|小米运动|万年历|豆瓣[信息流]|虎牙直播|货拉拉|番茄小说|携程旅行[APP] +// @APPList 无法𝐌𝐈𝐓𝐌的应用:银行类[绝大部分]|抖音|蜂巢|滴答清单|Taio|小米运动|有条下载|Fileball|万年历|豆瓣[信息流]|虎牙直播|货拉拉|番茄小说|携程旅行[APP]|凯叔讲故事|七猫小说|醒图|剪映|潮汐|不背单词|高铁管家 // @Attention 如果广告仍然存在,请『卸载应用』重新安装,还是不行则表示『规则里没有或已失效』 // @ScriptURL https://github.com/ddgksf2013/Rewrite/raw/master/AdBlock/StartUp.conf // ==/UserScript== -hostname = mgw.mpaas.cn-hangzhou.aliyuncs.com, ytmsout.radio.cn, api.kmovie.gifshow.com, igetcool-gateway.igetcool.com, *.ahhhhfs.com, open-cms-api.quark.cn, ftapi.10jqka.com.cn, wxa.wxs.qq.com, evs.500.com, j1.pupuapi.com, dq.dxy.cn, m.you.163.com, open-cms-api.uc.cn, *.yuxueyuan.cn, pan-api.bitqiu.com, client.tujia.com, vip7.fzwdyy.cn, run.api.qyfxgd.cn, *cupid.iqiyi.com, gateway.36kr.com, shopapi.io.mi.com, tk.lanjiyin.com, gongdu.youshu.cc, api.21ec74.com, ztoread.ziroom.com, iphone.ac.qq.com, web.chelaile.net.cn, gd.10086.cn, api.00bang.cn, app.hbooker.com, api.sfacg.com, newclient.map.baidu.com, api3.cls.cn, gateway-api.dushu365.com, p0.pipi.cn, jdread-api.jd.com, ms.jr.jd.com, bdsp-x.jd.com, dsp-x.jd.com, api.m.jd.com, router-app-api.jdcloud.com, app.homeinns.com, cdn-evone-ceph.echargenet.com, mlol.qt.qq.com, gg.caixin.com, app-gw.csdn.net, api.gameplus.qq.com, mrobot.pconline.com.cn, djcapp.game.qq.com, mxsa.mxbc.net, cn-acs.m.cainiao.com, zjdr666.com, api.caiyunapp.com, api.ahmobile.cn, gx.10086.cn, emdcadvertise.eastmoney.com, api-sams.walmartmobile.cn, creditcardapp.bankcomm.cn, m.creditcard.ecitic.com, lban.spdb.com.cn, adapi.izuiyou.com, i.ys7.com, apps.api.ke.com, api.yonghuivip.com, access.mypikpak.com, gateway.shouqiev.com, res.pizzahut.com.cn, api.caijingmobile.com, 3g.csair.com, client-api.oray.com, bgw.xinyue.qq.com, api-new.app.acfun.cn, m.client.10010.com, open.fitdays.cn, gha.ghac.cn, ap.dongqiudi.com, sh-gateway.shihuo.cn, wcprd.hilton.com, ad.12306.cn, 103.91.210.141, adx-cn.anythinktech.com, js-ad.ayximgs.com, api.dangdang.com, pzoap.moedot.com, pipi.4kya.com, vip7.fzwdyy.cn, sdk.alibaba.com.ailbaba.me, tft-app.cdtft.cn, bgw.xinyue.qq.com, pan.baidu.com, yunbusiness.ccb.com, client.app.coc.10086.cn, t1.market.xiaomi.com, api.m.mi.com, app.zhuanzhuan.com, api.cloud.189.cn, appwk.baidu.com, us.l.qq.com, open.e.kuaishou.com, mi.gdt.qq.com, emdcadvertise.eastmoney.com, adm.10jqka.com.cn, a.qiumibao.com, api.tipsoon.com, b.appsimg.com, ios.sspai.com, zconfig.alibabausercontent.com, api.touker.com, mpcs.suning.com, api.pinduoduo.com, api.yangkeduo.com, easyreadfs.nosdn.127.net, sp.kaola.com, gw.kaola.com, mime.baidu.com, learn.chaoxing.com, mapi.dangdang.com, api.dangdang.com, open.e.kuaishou.com, client.qunar.com, mpos-pic.helipay.com, dili.bdatu.com, wap.ngchina.cn, ih2.ireader.com, adpai.thepaper.cn, api.haohaozhu.cn, list-app-m.i4.cn, api.xiachufang.com, peisongapi.meituan.com, *gaoqingdianshi.com, *.kakamobi.cn, api.jxedt.com, slapi.oray.net, r.inews.qq.com, app.yinxiang.com, mapi.appvipshop.com, syh.zybang.com, cdn.cmgadx.com, api.internetofcity.cn, img.meituan.net, lcen.xiaote.net, venus.yhd.com, api.shenyin.name, mage*.if.qidian.com, god.gameyw.netease.com, m.ibuscloud.com, e.dangdang.com, app2.autoimg.cn, adproxy.autohome.com.cn, discardrp.umetrip.com, startup.umetrip.com, explorer.tratao.com, overseas.weico.cc, 118.178.214.118, dapis.mting.info, acs.m.taobao.com, open3.vistastory.com, ssp.dzh.com.cn, www.meituan.com, client.mail.163.com, api.izuiyou.com, appapi.huazhu.com, api.wfdata.club, interface*.music.163.com, api.psy-1.com, res.kfc.com.cn, mp.weixin.qq.com, security.wechat.com, weixin110.qq.com, cdn.*.chelaileapp.cn, api.coolapk.com, app3.qdaily.com, daoyu.sdo.com, img.jiemian.com, ccsp-egmas.sf-express.com, *.laichon.com, app.ap.d3yuiw4.com, www.i3zh.com, api.yikaobang.com.cn, api-ad-product.huxiu.com, jad-api.jin10.com, mob.mddcloud.com.cn, appactive.1234567.com.cn, rtbapi.douyucdn.cn, service.busi.inke.cn, gab.122.gov.cn, dispatcher.camera360.com, app.api.versa-ai.com, open.taou.com, api.taou.com, track.mm.taou.com, app.dewu.com, data-collector.soulapp.cn, api.gamer.com.tw, beta-api.crunchyroll.com, api.vistopia.com.cn, pss.txffp.com, m.sd.10086.cn, helper.2bulu.com, 47.100.65.202, api.weibo.cn, mapi.weibo.com, *.uve.weibo.com, new.vip.weibo.cn, wap.js.10086.cn, tagit.hyhuo.com, top-widgets-api.xiaozujian.com, *mangaapi.manhuaren.*, apis.lifeweek.com.cn, support.you.163.com, yanxuan.nosdn.127.net, *.peopleapp.com, new-app-api.ylyk.com, gw.aihuishou.com, *.58cdn.com.cn, app.58.com, api.zhihu.com, creditcardapp.bankcomm.com, res.xiaojukeji.com, 116.85.2.15, 116.85.2.14, lchttpapi.xczim.com, business.msstatic.com, api.kkmh.com, *.chelaile.net.cn, api.jr.mi.com, api.m.mi.com, guanyu.longfor.com, elemecdn.com, fuss10.elemecdn.com, www1.elecfans.com, m.tuniu.com, mapi.mafengwo.cn, api.xiaoyi.com, api.douban.com, otheve.beacon.qq.com, mapi.sfbest.com, api.mwee.cn, sso.ifanr.com, s3plus.meituan.net, flowplus.meituan.net, p*.meituan.net, testflight.apple.com, wmapi.meituan.com, appconf.mail.163.com, dl-cu-hz.lechange.cn, fbchina.flipchina.cn, zone.guiderank-app.com, homefront.qunar.com, afd.baidu.com, j-image.missfresh.cn, ma-adx.ctrip.com, mbd.baidu.com, img.rr.tv, api.rr.tv, *.hoopchina.com, goblin.hupu.com, spclient.wg.spotify.com +hostname = 1jietu.com, bbs-api.miyoushe.com, tcmobileapi.17usoft.com, m.msyc.cc, mgw.mpaas.cn-hangzhou.aliyuncs.com, ytmsout.radio.cn, api.kmovie.gifshow.com, igetcool-gateway.igetcool.com, *.ahhhhfs.com, open-cms-api.quark.cn, ftapi.10jqka.com.cn, wxa.wxs.qq.com, evs.500.com, j1.pupuapi.com, dq.dxy.cn, m.you.163.com, open-cms-api.uc.cn, *.yuxueyuan.cn, pan-api.bitqiu.com, client.tujia.com, vip7.fzwdyy.cn, run.api.qyfxgd.cn, *cupid.iqiyi.com, gateway.36kr.com, shopapi.io.mi.com, tk.lanjiyin.com, gongdu.youshu.cc, api.21ec74.com, ztoread.ziroom.com, iphone.ac.qq.com, web.chelaile.net.cn, gd.10086.cn, api.00bang.cn, app.hbooker.com, api.sfacg.com, newclient.map.baidu.com, api3.cls.cn, gateway-api.dushu365.com, p0.pipi.cn, jdread-api.jd.com, ms.jr.jd.com, bdsp-x.jd.com, dsp-x.jd.com, api.m.jd.com, router-app-api.jdcloud.com, app.homeinns.com, cdn-evone-ceph.echargenet.com, mlol.qt.qq.com, gg.caixin.com, app-gw.csdn.net, api.gameplus.qq.com, mrobot.pconline.com.cn, djcapp.game.qq.com, mxsa.mxbc.net, cn-acs.m.cainiao.com, zjdr666.com, api.caiyunapp.com, api.ahmobile.cn, gx.10086.cn, emdcadvertise.eastmoney.com, api-sams.walmartmobile.cn, creditcardapp.bankcomm.cn, m.creditcard.ecitic.com, lban.spdb.com.cn, adapi.izuiyou.com, i.ys7.com, apps.api.ke.com, api.yonghuivip.com, access.mypikpak.com, gateway.shouqiev.com, res.pizzahut.com.cn, api.caijingmobile.com, 3g.csair.com, client-api.oray.com, bgw.xinyue.qq.com, api-new.app.acfun.cn, m.client.10010.com, open.fitdays.cn, gha.ghac.cn, ap.dongqiudi.com, sh-gateway.shihuo.cn, wcprd.hilton.com, ad.12306.cn, 103.91.210.141, adx-cn.anythinktech.com, js-ad.ayximgs.com, api.dangdang.com, pzoap.moedot.com, pipi.4kya.com, vip7.fzwdyy.cn, sdk.alibaba.com.ailbaba.me, tft-app.cdtft.cn, bgw.xinyue.qq.com, pan.baidu.com, yunbusiness.ccb.com, client.app.coc.10086.cn, t1.market.xiaomi.com, api.m.mi.com, app.zhuanzhuan.com, api.cloud.189.cn, appwk.baidu.com, us.l.qq.com, open.e.kuaishou.com, mi.gdt.qq.com, emdcadvertise.eastmoney.com, adm.10jqka.com.cn, a.qiumibao.com, api.tipsoon.com, b.appsimg.com, ios.sspai.com, zconfig.alibabausercontent.com, api.touker.com, mpcs.suning.com, api.pinduoduo.com, api.yangkeduo.com, easyreadfs.nosdn.127.net, sp.kaola.com, gw.kaola.com, mime.baidu.com, learn.chaoxing.com, mapi.dangdang.com, api.dangdang.com, open.e.kuaishou.com, client.qunar.com, mpos-pic.helipay.com, dili.bdatu.com, wap.ngchina.cn, ih2.ireader.com, adpai.thepaper.cn, api.haohaozhu.cn, list-app-m.i4.cn, api.xiachufang.com, peisongapi.meituan.com, *gaoqingdianshi.com, *.kakamobi.cn, api.jxedt.com, slapi.oray.net, r.inews.qq.com, app.yinxiang.com, mapi.appvipshop.com, syh.zybang.com, cdn.cmgadx.com, api.internetofcity.cn, img.meituan.net, lcen.xiaote.net, venus.yhd.com, api.shenyin.name, mage*.if.qidian.com, god.gameyw.netease.com, m.ibuscloud.com, e.dangdang.com, app2.autoimg.cn, adproxy.autohome.com.cn, discardrp.umetrip.com, startup.umetrip.com, explorer.tratao.com, overseas.weico.cc, 118.178.214.118, dapis.mting.info, acs.m.taobao.com, open3.vistastory.com, ssp.dzh.com.cn, www.meituan.com, client.mail.163.com, api.izuiyou.com, appapi.huazhu.com, api.wfdata.club, interface*.music.163.com, api.psy-1.com, res.kfc.com.cn, mp.weixin.qq.com, security.wechat.com, weixin110.qq.com, cdn.*.chelaileapp.cn, api.coolapk.com, app3.qdaily.com, daoyu.sdo.com, img.jiemian.com, ccsp-egmas.sf-express.com, *.laichon.com, app.ap.d3yuiw4.com, www.i3zh.com, api.yikaobang.com.cn, api-ad-product.huxiu.com, jad-api.jin10.com, mob.mddcloud.com.cn, appactive.1234567.com.cn, rtbapi.douyucdn.cn, service.busi.inke.cn, gab.122.gov.cn, dispatcher.camera360.com, app.api.versa-ai.com, open.taou.com, api.taou.com, track.mm.taou.com, app.dewu.com, data-collector.soulapp.cn, api.gamer.com.tw, beta-api.crunchyroll.com, api.vistopia.com.cn, pss.txffp.com, m.sd.10086.cn, helper.2bulu.com, 47.100.65.202, api.weibo.cn, mapi.weibo.com, *.uve.weibo.com, new.vip.weibo.cn, wap.js.10086.cn, tagit.hyhuo.com, top-widgets-api.xiaozujian.com, *mangaapi.manhuaren.*, apis.lifeweek.com.cn, support.you.163.com, yanxuan.nosdn.127.net, *.peopleapp.com, new-app-api.ylyk.com, gw.aihuishou.com, *.58cdn.com.cn, app.58.com, api.zhihu.com, creditcardapp.bankcomm.com, res.xiaojukeji.com, 116.85.2.15, 116.85.2.14, lchttpapi.xczim.com, business.msstatic.com, api.kkmh.com, *.chelaile.net.cn, api.jr.mi.com, api.m.mi.com, guanyu.longfor.com, elemecdn.com, fuss10.elemecdn.com, www1.elecfans.com, m.tuniu.com, mapi.mafengwo.cn, api.xiaoyi.com, api.douban.com, otheve.beacon.qq.com, mapi.sfbest.com, api.mwee.cn, sso.ifanr.com, s3plus.meituan.net, flowplus.meituan.net, p*.meituan.net, testflight.apple.com, wmapi.meituan.com, appconf.mail.163.com, dl-cu-hz.lechange.cn, fbchina.flipchina.cn, zone.guiderank-app.com, homefront.qunar.com, afd.baidu.com, j-image.missfresh.cn, ma-adx.ctrip.com, mbd.baidu.com, img.rr.tv, api.rr.tv, *.hoopchina.com, goblin.hupu.com, spclient.wg.spotify.com + # ======= 0~9 ======= # # > version -^https?:\/\/2023.08.13/v2.0.338 url reject-200 +^https?:\/\/2023.09.02/v2.0.346 url reject-200 # > 10 ^https?:\/\/ftapi\.10jqka\.com\.cn\/futgwapi\/api\/om\/v\d\/ad\/common\/transfer url reject # > 58 @@ -53,7 +54,7 @@ hostname = mgw.mpaas.cn-hangzhou.aliyuncs.com, ytmsout.radio.cn, api.kmovie.gifs # > amdc ^http:\/\/amdc\.m\.taobao\.com url script-response-body https://cdn.jsdelivr.net/gh/sve1r/Rules-For-Quantumult-X@develop/Scripts/AdBlock/Other/Amdc.min.js # > ahfs -^https?:\/\/.*ahhhhfs.com\/($|[0-9a-zA-Z]+\/$) url script-response-body https://cdn.jsdelivr.net/gh/sve1r/Rules-For-Quantumult-X@develop/Scripts/AdBlock/Other/Ahfs.js +^https?:\/\/.*ahhhhfs\.com\/($|[0-9a-zA-Z_/]+\/$) url script-response-body https://cdn.jsdelivr.net/gh/sve1r/Rules-For-Quantumult-X@develop/Scripts/AdBlock/Other/Ahfs.js # ======= B ======= # @@ -137,7 +138,7 @@ https?:\/\/res\.xiaojukeji\.com\/resapi\/activity\/get(Ruled|Preload|PasMultiNot ^https:\/\/app\.dewu\.com\/api\/v1\/app\/advertisement\/ url reject # > donghuafeng ^https?:\/\/api\.gamer\.com\.tw\/mobile_app\/anime\/v\d\/anime_get_question\.php url reject-dict -;^https:\/\/api\.gamer\.com\.tw\/mobile_app\/anime\/v\d\/(token|m3u8).php\? url script-response-body https://cdn.jsdelivr.net/gh/sve1r/Rules-For-Quantumult-X@develop/Scripts/AdBlock/Other/BahamutAnimeAds.min.js +;^https:\/\/api\.gamer\.com\.tw\/mobile_app\/anime\/v\d\/(token|m3u8).php\? url script-response-body https://raw.githubusercontent.com/NobyDa/Script/master/Bahamut/BahamutAnimeAds.js # > dazhihui ^https?://ssp\.dzh\.com\.cn/v2api/adgroupjson url reject # > dangdangyuedu @@ -278,7 +279,7 @@ https://fbchina.flipchina.cn/v2/ad/query/* url reject # > jianhanglife ^https?:\/\/yunbusiness\.ccb\.com\/clp_service\/txCtrl\?txcode=A3341A00(2|9) url reject # > jike -^https?:\/\/mgw\.mpaas\.cn-hangzhou\.aliyuncs\.com\/mgw\.htm url reject +;^https?:\/\/mgw\.mpaas\.cn-hangzhou\.aliyuncs\.com\/mgw\.htm url reject # ======= K ======= # @@ -363,6 +364,8 @@ https?:\/\/helper\.2bulu\.com\/(greenPea\/queryTasks|proSpecial\/allData|saveSpl ^https:\/\/mxsa\.mxbc\.net\/api\/v1\/adinfo\/limitedAds$ url reject # > maoyan* ^https?:\/\/p0\.pipi\.cn\/adAdmin\/\w+.jpg\? url reject-img +# > miyoushe +^https?:\/\/bbs-api\.miyoushe\.com\/apihub\/api\/getAppSplash url reject # ======= N ======= # @@ -428,8 +431,8 @@ https://ios.sspai.com/api/v3/recommend/page/get\?ad.*ios_home_modal url reject # > ShunFengYouXuan ^https://mapi.sfbest.com\/brokerservice-server\/cms\/getPositionById.* url reject # > spotify pro -^https:\/\/spclient\.wg\.spotify\.com\/(bootstrap\/v1\/bootstrap|user-customization-service\/v1\/customize)$ url script-response-body https://raw.githubusercontent.com/app2smile/rules/master/js/spotify-proto.js -^https:\/\/spclient\.wg\.spotify\.com\/(artistview\/v1\/artist|album-entity-view\/v2\/album)\/ url script-request-header https://raw.githubusercontent.com/app2smile/rules/master/js/spotify-json.js +;^https:\/\/spclient\.wg\.spotify\.com\/(bootstrap\/v1\/bootstrap|user-customization-service\/v1\/customize)$ url script-response-body https://raw.githubusercontent.com/app2smile/rules/master/js/spotify-proto.js +;^https:\/\/spclient\.wg\.spotify\.com\/(artistview\/v1\/artist|album-entity-view\/v2\/album)\/ url script-request-header https://raw.githubusercontent.com/app2smile/rules/master/js/spotify-json.js # > spotify ^https?://spclient.wg.spotify.com/(ad-logic|ads|.+ad_slot|.+banners|.+canvases|.+cards|.+crashlytics|.+doubleclick.net|.+enabled-tracks|.+promoted_offer) url reject-img ^https?:\/\/api\d?\.musical\.ly\/api\/ad\/ url reject-img @@ -475,7 +478,7 @@ https://ccsp-egmas.sf-express.com/cx-app-base/base/app/ad/queryAdImages url reje # > TuNiu ^https?:\/\/m\.tuniu\.com\/api\/operation\/splash\/ url reject # > TaoPiaoPiao -^https://acs.m.taobao.com\/gw\/mtop.film.mtopadvertiseapi.queryadvertise\/5.0.* url reject +^https?:\/\/acs\.m\.taobao\.com\/gw\/mtop\.film\.mtopadvertiseapi\.queryadvertise\/ url reject # > TianTianJiJin ^https?:\/\/appactive\.1234567\.com\.cn\/AppoperationApi\/OperationService\/GetAppStartImg url reject # > topwidget @@ -489,6 +492,8 @@ https://top-widgets-api.xiaozujian.com/api/ad/config url reject ^https?:\/\/adm\.10jqka\.com\.cn\/interface\/ad\/recommend url reject # > tengxundongman ^https?:\/\/iphone\.ac\.qq\.com\/.*\/Support\/(getSystemConf|bootScreen) url reject +# > tongchenglvxing +^https?:\/\/tcmobileapi\.17usoft\.com\/appindexnew\/index\/getappindexconfig url reject # > tujiaminxu ^https?:\/\/client\.tujia\.com\/bnbapp-node\/app\/portal\/getStartPictureAdvertising url reject @@ -600,6 +605,10 @@ https://new-app-api.ylyk.com/v1/user/myinfo/adviser url reject ^https?:\/\/acs\.m\.taobao\.com\/gw\/mtop\.etao\.noah\.query.*etao_splash url reject # > yunting ^https?:\/\/ytmsout\.radio\.cn\/publish\/recScreen\/getLoadPage url reject +# > yangcong +^https?:\/\/m\.msyc\.cc\/app\/getBootPage\/v\d url reject +# > yijietu +^https?:\/\/1jietu\.com\/apiv\d\/ad url reject # ======= Z ======= # @@ -631,7 +640,7 @@ https?:\/\/m\.sd\.10086\.cn\/zapi\/app_common\/homeWelcome\/welcome.do url rejec ^https?:\/\/adapi\.izuiyou\.com\/ url reject ^https?:\/\/api\.izuiyou\.com\/ad\/ url reject # > Zhihu -^https?:\/\/api\.zhihu\.com\/commercial_api.*launch_v2 url script-response-body https://cdn.jsdelivr.net/gh/sve1r/Rules-For-Quantumult-X@develop/Scripts/AdBlock/Zhihu/OpenAds.js +^https?:\/\/api\.zhihu\.com\/commercial_api.*launch_v2 url script-response-body https://github.com/ddgksf2013/Scripts/raw/master/zhihu_openads.js # > zhuishushenqi ^https?:\/\/adx-cn\.anythinktech\.com\/bid url reject # > zhangshangdaojucheng diff --git a/Rewrite/AdBlock/TieBa.adblock b/Rewrite/AdBlock/TieBa.adblock new file mode 100644 index 0000000..664afd7 --- /dev/null +++ b/Rewrite/AdBlock/TieBa.adblock @@ -0,0 +1,8 @@ +# 贴吧去广告-qx(>=iOS15) +# qx加载本重写前,须同时加载对应的贴吧分流,否则不能完全去广告 +# 仓库地址 https://github.com/app2smile/rules +# 开屏广告;推荐和吧内帖子列表的直播及广告;详情页直播/关联商品/广告;看图模式广告;首页和帖子详情页右下角悬浮广告;部分吧内的置顶/最新中间的广告/head图片广告/head直播 + +hostname = tiebac.baidu.com +^http(s:\/\/tiebac|:\/\/c\.tieba)\.baidu\.com\/(c\/f\/(frs\/(page|threadlist|generalTabList)|pb\/page|excellent\/personalized)$|tiebaads\/commonbatch|c\/s\/sync$) url script-response-body https://cdn.jsdelivr.net/gh/sve1r/Rules-For-Quantumult-X@develop/Scripts/AdBlock/Other/Tieba.min.js +^http(s:\/\/tiebac|:\/\/c\.tieba)\.baidu\.com\/c\/f\/(frs\/(page|threadlist|generalTabList)|pb\/page|excellent\/personalized)\?cmd url script-response-body https://cdn.jsdelivr.net/gh/sve1r/Rules-For-Quantumult-X@develop/Scripts/AdBlock/Other/Tieba-2.min.js \ No newline at end of file diff --git a/Rewrite/AdBlock/WebAdBlock.adblock b/Rewrite/AdBlock/WebAdBlock.adblock index 0637752..fe2b587 100644 --- a/Rewrite/AdBlock/WebAdBlock.adblock +++ b/Rewrite/AdBlock/WebAdBlock.adblock @@ -7,57 +7,63 @@ // @Contribute https://t.me/ddgksf2013_bot // @Feedback 📮 ddgksf2013@163.com 📮 // @Attention 如需引用请注明出处,谢谢合作! -// @UpdateTime 2023-07-24 +// @UpdateTime 2023-09-02 // @Function 自用影视网站去广告配置(不定期更新) // @Suitable 自行观看"# > "注释内容 // @Explain 推荐使用手机版Chrome或Alook浏览器(仅供墨鱼本人及小部分QX用户使用) // @ScriptURL https://github.com/ddgksf2013/Rewrite/raw/master/Html/WebAdBlock.conf // ==/UserScript== -hostname=www.freeok.vip, *netflix*, *bdys*,*cupfox*,*cokemv*,*pornhub.com,*lezhutv*,*bimi*,18comic.org,*5y*,*gimy*,*tkznp*,*czzy*,*ikandy*,*libvio* + + +hostname=m.nivod4.tv, www.freeok.vip, *netflix*, *bdys*,*cupfox*,*cokemv*,*pornhub.com,*lezhutv*,*bimi*,18comic.org,*5y*,*gimy*,*tkznp*,*czzy*,*ikandy*,*libvio* + + +# > 16 泥巴影视[网页优化]@Adblock4limbo - 网站地址:https://m.nivod4.tv +^https?:\/\/.*nivod.*\/($|[0-9a-zA-Z=_/-]+\.html) url script-response-body https://github.com/ddgksf2013/Scripts/raw/master/nivod.js # > 15 FreeOk[网页优化]@ddgksf2013 - 网站地址:https://www.freeok.vip -^https?:\/\/www\.freeok\.vip(\/$|\/[0-9a-zA-Z=_/-]+\.html$) url script-response-body https://cdn.jsdelivr.net/gh/ddgksf2013/Scripts@master/freeok.js +^https?:\/\/www\.freeok\.vip(\/$|\/[0-9a-zA-Z=_/-]+\.html$) url script-response-body https://github.com/ddgksf2013/Scripts/raw/master/freeok.js # > 14 奈飞鸭[网页优化]@ddgksf2013 - 网站地址:https://yanetflix.com [未测试] -^https?:\/\/.*netflix.*\/($|[0-9a-zA-Z=_/-]+\.html$) url script-response-body https://cdn.jsdelivr.net/gh/ddgksf2013/Scripts@master/netflix.js +^https?:\/\/.*netflix.*\/($|[0-9a-zA-Z=_/-]+\.html$) url script-response-body https://github.com/ddgksf2013/Scripts/raw/master/netflix.js # > 13 哔嘀影视[网页优化]@ddgksf2013 - 网站地址:https://www.bdys01.com -^https?:\/\/.*bdys.*com\/($|([a-z]+)\/(play\/)?\d+.*$) url script-response-body https://cdn.jsdelivr.net/gh/ddgksf2013/Scripts@master/bdys.js +^https?:\/\/.*bdys.*com\/($|([a-z]+)\/(play\/)?\d+.*$) url script-response-body https://github.com/ddgksf2013/Scripts/raw/master/bdys.js # > 12 茶杯狐[网页优化]@ddgksf2013 - 网站地址:https://cupfox.app -^https?:/\/.*cupfox\.app\/($|[\u4E00-\u9FFFa-zA-Z0-9%=_/-]+$) url script-response-body https://cdn.jsdelivr.net/gh/ddgksf2013/Scripts@master/cupbox.js +^https?:/\/.*cupfox\.app\/($|[\u4E00-\u9FFFa-zA-Z0-9%=_/-]+$) url script-response-body https://github.com/ddgksf2013/Scripts/raw/master/cupbox.js # > 11 Cokemv[网页优化]@ddgksf2013 - 网站地址:https://cokemv.me -^https?:/\/cokemv\.me\/($|vod.*$) url script-response-body https://cdn.jsdelivr.net/gh/ddgksf2013/Scripts@master/cokemv.js +^https?:/\/cokemv\.me\/($|vod.*$) url script-response-body https://github.com/ddgksf2013/Scripts/raw/master/cokemv.js # > 10 PornHub[网页优化]@ddgksf2013 - 网站地址:https://cn.pornhub.com ^https:\/\/(cn|www)\.pornhub\.com\/_xa\/ads url reject-dict -^https?:/\/(cn|www)\.pornhub\.com\/($|(view|video).*$) url script-response-body https://cdn.jsdelivr.net/gh/ddgksf2013/Scripts@master/pornhub.js +^https?:/\/(cn|www)\.pornhub\.com\/($|(view|video).*$) url script-response-body https://github.com/ddgksf2013/Scripts/raw/master/pornhub.js # > 09 LeZhu[网页优化]@ddgksf2013 - 网站地址:http://www.lezhutv.com -^https?:/\/.*lezhutv\.com\/($|(type|detail|play|index).*$) url script-response-body https://cdn.jsdelivr.net/gh/ddgksf2013/Scripts@master/lezhu.js +^https?:/\/.*lezhutv\.com\/($|(type|detail|play|index).*$) url script-response-body https://github.com/ddgksf2013/Scripts/raw/master/lezhu.js # > 08 Bimi[网页优化]@ddgksf2013 - 网站地址:https://www.bimi.net -^https?:/\/.*bimi.*net\/($|(vodshow|bangumi|type)\/[0-9a-z-\/]+\/$) url script-response-body https://cdn.jsdelivr.net/gh/ddgksf2013/Scripts@master/bimi.js +^https?:/\/.*bimi.*net\/($|(vodshow|bangumi|type)\/[0-9a-z-\/]+\/$) url script-response-body https://github.com/ddgksf2013/Scripts/raw/master/bimi.js # > 07 禁漫天堂[网页优化]@ddgksf2013 - 网站地址:https://18comic.org -^https?:\/\/.*18comic\.org\/($|(album|photo).*$) url script-response-body https://cdn.jsdelivr.net/gh/ddgksf2013/Scripts@master/18comic.js +^https?:\/\/.*18comic\.org\/($|(album|photo).*$) url script-response-body https://github.com/ddgksf2013/Scripts/raw/master/18comic.js # > 06 555影视[网页优化]@ddgksf2013 - 网站地址:https://555yy6.com -^https?:\/\/.*5y.*\/($|[0-9a-zA-Z=_/-]+\.html$) url script-response-body https://cdn.jsdelivr.net/gh/ddgksf2013/Scripts@master/555.js +^https?:\/\/.*5y.*\/($|[0-9a-zA-Z=_/-]+\.html$) url script-response-body https://github.com/ddgksf2013/Scripts/raw/master/555.js # > 05 剧迷[网页优化]@ddgksf2013 - 网站地址:https://gimys.app -^https?:\/\/.*gimy.*\/($|[0-9a-zA-Z=_/-]+\.html$) url script-response-body https://cdn.jsdelivr.net/gh/ddgksf2013/Scripts@master/gimytv.js +^https?:\/\/.*gimy.*\/($|[0-9a-zA-Z=_/-]+\.html$) url script-response-body https://github.com/ddgksf2013/Scripts/raw/master/gimytv.js # > 04 天空影视[网页优化]@ddgksf2013 - 网站地址:https://tkznp.com/ [未测试] -^https?:\/\/.*tkznp.*com\/($|[0-9a-zA-Z=_/-]+\.html$) url script-response-body https://cdn.jsdelivr.net/gh/ddgksf2013/Scripts@master/tkys.js +^https?:\/\/.*tkznp.*com\/($|[0-9a-zA-Z=_/-]+\.html$) url script-response-body https://github.com/ddgksf2013/Scripts/raw/master/tkys.js # > 03 厂长电影[网页优化]@ddgksf2013 - 网站地址:https://czzy.art/ -^https?:\/\/.*czzy.*\/($|\?btwaf=\w+$|[0-9a-zA-Z=_/-]+\.html) url script-response-body https://cdn.jsdelivr.net/gh/ddgksf2013/Scripts@master/qianoo.js +^https?:\/\/.*czzy.*\/($|\?btwaf=\w+$|[0-9a-zA-Z=_/-]+\.html) url script-response-body https://github.com/ddgksf2013/Scripts/raw/master/qianoo.js # > 02 真不卡[网页优化]@ddgksf2013 - 网站地址:https://www.ikandy.fun -^https?:\/\/.*ikandy.*fun\/($|(vod|top).*$) url script-response-body https://cdn.jsdelivr.net/gh/ddgksf2013/Scripts@master/zhenbuka.js +^https?:\/\/.*ikandy.*fun\/($|(vod|top).*$) url script-response-body https://github.com/ddgksf2013/Scripts/raw/master/zhenbuka.js # > 01 libvio[网页优化]@ddgksf2013 - 网站地址:https://www.libvio.me -^https?:\/\/.*libvio.*me\/($|[0-9a-zA-Z=_/-]+\.html$) url script-response-body https://cdn.jsdelivr.net/gh/ddgksf2013/Scripts@master/libvio.js \ No newline at end of file +^https?:\/\/.*libvio.*me\/($|[0-9a-zA-Z=_/-]+\.html$) url script-response-body https://github.com/ddgksf2013/Scripts/raw/master/libvio.js diff --git a/Rewrite/AdBlock/Weibo.adblock b/Rewrite/AdBlock/Weibo.adblock index 21b8905..10edf01 100644 --- a/Rewrite/AdBlock/Weibo.adblock +++ b/Rewrite/AdBlock/Weibo.adblock @@ -14,30 +14,109 @@ // @ScriptURL https://github.com/ddgksf2013/Rewrite/raw/master/AdBlock/Weibo.conf // ==/UserScript== +# 𝐂𝐮𝐭𝐭𝐥𝐞𝐟𝐢𝐬𝐡 𝐒𝐞𝐥𝐟-𝐮𝐬𝐞 𝐑𝐞𝐰𝐫𝐢𝐭𝐞 𝐂𝐨𝐧𝐟𝐢𝐠𝐮𝐫𝐚𝐭𝐢𝐨𝐧 𝐂𝐡𝐚𝐧𝐠𝐞𝐥𝐨𝐠 𝐂𝐫𝐞𝐚𝐭𝐞𝐝 𝐛𝐲 𝐝𝐝𝐠𝐤𝐬𝐟𝟐𝟎𝟏𝟑 𝐚𝐧𝐝 𝐳𝐦𝐪𝐜𝐡𝐞𝐫𝐢𝐬𝐡 +# [+]202X-XX-XX 01、删除首页(tab1)流和超话中的广告、热推删除视频号(tab2)流中的广告,删除发现页(tab3)轮播广告图 +# [+]202X-XX-XX 02、删除个人页(tab5)中的创作者中心下方的轮播图、为你推荐、用户任务和VIP一栏(可配置) +# [+]202X-XX-XX 03、删除微博详情页的广告、相关推荐、微博主好物种草和关注博主模块(可配置),删除微博开屏广告 | 参考@yichahucha +# [+]202X-XX-XX 04、删除tab2菜单中的虚假通知,删除tab1顶部的签到和直播(可配置),删除微博详情页菜单栏的新鲜事头像挂件等(可配置) +# [+]202X-XX-XX 05、删除微博详情页评论区相关内容(可配置,默认关闭),删除微博详情页评论区推荐内容(可配置,默认打开) +# [+]202X-XX-XX 06、删除超话中可能感兴趣的超话、超话中的好友、超话好友关注、用户页可能感兴趣的人(可配置,默认关闭) +# [+]202X-XX-XX 07、删除搜索结果页广告,将个人主页关注按钮默认值由推荐改为关注的人 +# [+]202X-XX-XX 08、自定义个人主页图标(可配置,默认关闭)效果图,关闭自动播放下一个视频(可配置,默认关闭) +# [+]202X-XX-XX 09、删除微博详情页打赏模块(可配置,默认关闭),自定义底部tab图标(可配置,默认关闭)效果图 +# [+]202X-XX-XX 10、已删除移除tab5新任务通知,原样式,删除绿洲模块(可配置,默认关闭) +# [+]202X-XX-XX 11、待定自定义开屏图片/视频。如有需求,可以考虑开发,删除个人页让“红包飞模块” +# [+]2022-03-12 12、新增屏蔽用户功能,如果有不得已需要关注的人(比如某些抽奖关注),但是又不想看TA的内容可以使用此配置。 +# [+]2022-05-22 13、重新删除发现页(tab3)轮播广告图,需要配置weibo_config.js -> removeSearchWindow为true,其实轮播中有些不是广告,一起杀 +# [+]2022-07-12 14、删除消息页动态流的广告 +# [+]2022-08-22 15、删除超话tab页无关元素(可配置) +# [+]2022-08-23 16、删除微博详情页超话新帖和新用户相关提示 +# [+]2022-09-02 17、删除初次打开搜索页的轮播图 +# [+]2022-09-12 18、修复超话无法签到bug +# [+]2022-10-11 19、移除首页新版广告 +# [+]2022-10-24 20、移除用户页新版广告 +# [+]2022-10-24 XX、🍁以上1-20条为@zmqcherish所写,下面21条开始为@墨鱼所写🍁 +# [+]2022-12-14 21、将微博国际版去广告与微博去广告二合一,删除微博发现页的轮播图,add key removeSearchWindow for true +# [+]2022-12-15 22、更换微博国际版去广告的search_topic +# [+]2022-12-15 23、微博国际版去广告不再采用单一reject方式,利用脚本去广告 +# [+]2022-12-15 24、去除微博我的页面“绿荫总动员”条幅,去除微博搜索框填词 +# [+]2022-12-15 25、修复微博热搜界面“要闻”与“同城”无法打开的bug +# [+]2022-12-15 26、去除我的、热搜、文娱列表广告内容 +# [+]2022-12-16 27、请手动添加后面的分流至本地 host, sdkapp.uve.weibo.com, direct +# [+]2022-12-16 28、删除主页顶部“#记录周五的开心时刻#”,去除搜索页面“实况热聊”栏以及group栏 +# [+]2022-12-16 29、删除微博评论详情页面最底部的“已过滤不当言论,部分评论暂不展示”等文字 +# [-]2022-12-17 30、脚本weibo_json.js已解除限制,其它工具诸如surge、Loon、小火箭亦可使用 +# [+]2022-12-18 31、优化超话tab看帖页面,保留搜索(去除自动填充内容)及感兴趣的超话以及去除一些无关group和card +# [+]2022-12-20 32、删除超话搜索栏目下方的“可能感兴趣”、“热门超话”、“影视超话”、“游戏超话”等card +# [+]2022-12-21 33、去除搜索页面tab中热搜下面一排圆圈图标内容 +# [+]2022-12-23 34、屏蔽hot_hours_spotlight请求 +# [+]2022-12-24 35、修复主页浏览动态微博时广告图片的空白占位问题,修复每日首次打开SearchTab页面广告轮播失效问题 +# [+]2022-12-24 36、删除发现页下拉刷新时的背景广告图片,瞬间清爽 +# [+]2022-12-24 37、删除微博短视频流中的广告,让你无广告享受刷短视频的快感 +# [+]2022-12-25 38、删除搜索页面热搜顶部偶尔出现的HotSearchPush +# [+]2022-12-27 39、删除微博用户页“可能感兴趣的人”内容 +# [+]2022-12-29 40、删除微博信息流中商品橱窗内容(并未将整个CARD一起删除) +# [+]2023-01-01 41、删除微博首页顶部感兴趣的人group推荐,并兼容微博国际版 +# [+]2023-01-03 42、去除微博国际版热搜列表的置顶内容 +# [+]2023-01-05 43、添加屏蔽sdkconfig请求及应用内弹窗广告请求 +# [+]2023-01-06 44、去除微博我的页面中Myname后面的续费VIP_Icon内容 +# [+]2023-01-08 45、屏蔽发现页面顶部搜索框热词,将热词恢复为‘搜索’ +# [+]2023-01-16 46、去除微博短视频中的右下角的红包`转发有礼`与左下角商品推广`进店逛逛`等推广标志 +# [+]2023-01-18 47、屏蔽微博客户端首页左上角每日的弹窗tips +# [+]2023-01-22 48、去除微博热搜对应某关键词下信息流中的遗留广告 +# [+]2023-01-24 49、去除微博底部超话栏表层浮icon及tips +# [+]2023-02-03 50、解决微博用户置顶博文消失的bug,同时新增去除搜索框下方的猜你想搜条目 +# [+]2023-02-08 51、修复首页‘可能感兴趣的人’card失效bug,同时去除搜索页面中部比较窄的‘热门微博’字样的CARD,使信息流保持一致 +# [+]2023-02-09 52、自动删除我的页面除[超话社区]CARD以外的所有推广内容(再也不用手动移除),另外[超话社区]依然支持自主移除或添加到我的页面内 +# [+]2023-02-09 53、我的页面Card白名单新增[我的最近访问],以方便群友,依然支持自主移除或添加 +# [+]2023-02-13 54、修复某些用户微博页面最近动态不显示的bug,增加微博视频detail处理 +# [+]2023-02-15 55、在有缓存的情况下,处理微博搜索框下的‘猜你想搜’栏目以及‘猜你想搜偏好设置’栏目[code not added] +# [+]2023-02-16 56、处理部分用户每日首次打开微博的开屏广告请求[部分用户是指未将boot.biz.weibo.com域名添加黑名单] +# [+]2023-02-18 57、修复微博在繁体字下评论区屏蔽用户推荐失效的问题 +# [+]2023-02-22 58、处理信息流中视频左上角的"红包派送中"Tag[code not added] +# [+]2023-02-25 59、处理用户反馈的微博国际版‘微博会员’推广CARD +# [+]2023-02-25 60、修改MITM写法,使小火箭工具能够MITM本重写的域名[后续新的重写配置也将注意此问题] +# [+]2023-03-04 61、调整boot.biz.weibo.com屏蔽策略,缩短微博应用启动时间,提高用户使用体验[或在本地添加分流host,boot.biz.weibo.com,reject(Anti已包含)] +# [+]2023-03-09 62、微博在未登录状态下,新增对首页[关注]与[热门]信息流广告的处理 +# [+]2023-03-31 63、修复微博开屏广告屏蔽失效的bug +# [+]2023-04-02 64、去除微博超话[广场]tab页面顶部广告推送以及搜索框下方的“我的热搜”内容 +# [+]2023-04-11 65、移除视频20s预览的限制 +# [+]2023-04-15 66、修复超话个人页面无法打开的问题 +# [+]2023-04-16 67、针对用户反馈的开屏广告预加载问题[已有缓存的情况下]进行处理 +# [+]2023-04-16 68、针对用户反馈的微博国际版内容搜索不全问题进行处理 +# [+]2023-04-27 69、在已有缓存的情况下去除微博搜索框下方的'猜你想搜'、'我的热搜'、'猜你想搜偏好设置'等内容 +# [+]2023-05-19 70、新增屏蔽推荐关注用户的弹窗 +# [+]2023-06-02 71、修复微博发现页"微博热搜"Group丢失的问题 +# [+]2023-07-03 72、移除部分微博详情页面顶部的“30天内,博主已拉黑恶意评论用户...”等文字Tips +# [+]2023-07-05 73、移除微博帖子下方的贴片广告[忘了更新日志,补上] +# [+]2023-08-11 74、移除微博国际版趋势页下的热门影片,恢复方法,打开解析器重写后面添加#out=v_f即可 + + hostname = api.weibo.*, *.api.weibo.*, mapi.weibo.*, *.uve.weibo.com, new.vip.weibo.cn, boot.biz.weibo.com # > 微博_请手动添加以下分流至本地@ddgksf2013 ; host, sdkapp.uve.weibo.com, direct + # > 微博国际版_趋势页热门影片@ddgksf2013 ^https?:\/\/api\.weibo\.cn\/\d\/cardlist\?v_f=.*Weibo_intl url reject-dict # > 微博_用户推荐弹窗@ddgksf2013 -;^https?:\/\/api\.weibo\.cn\/\d\/profile\/recommend_popuser url reject-dict +^https?:\/\/api\.weibo\.cn\/\d\/profile\/recommend_popuser url reject-dict # > 微博_开屏广告预加载处理@ddgksf2013 -^https?:\/\/boot.*weibo\.com\/v\d\/ad\/preload url script-response-body https://cdn.jsdelivr.net/gh/sve1r/Rules-For-Quantumult-X@develop/Scripts/AdBlock/Weibo/weibo.min.js +^https?:\/\/boot.*weibo\.com\/v\d\/ad\/preload url script-response-body https://github.com/ddgksf2013/Scripts/raw/master/weibo_json.js # > 微博_未登陆状态下首页信息流处理@ddgksf2013 -^https?:\/\/api\.weibo\.cn\/\d\/\w{5}\/(statuses_unread_hot_timeline|timeline) url script-response-body https://cdn.jsdelivr.net/gh/sve1r/Rules-For-Quantumult-X@develop/Scripts/AdBlock/Weibo/weibo.min.js +^https?:\/\/api\.weibo\.cn\/\d\/\w{5}\/(statuses_unread_hot_timeline|timeline) url script-response-body https://github.com/ddgksf2013/Scripts/raw/master/weibo_json.js # > 微博_每日一次的开屏广告请求@ddgksf2013 ^https?:\/\/boot.*weibo\.com\/v\d\/ad\/realtime url reject-200 # > 微博_视频信息处理@ddgksf2013 -^https?:\/\/api\.weibo\.cn\/\d\/video\/tiny_stream_mid_detail url script-response-body https://cdn.jsdelivr.net/gh/sve1r/Rules-For-Quantumult-X@develop/Scripts/AdBlock/Weibo/weibo.min.js +^https?:\/\/api\.weibo\.cn\/\d\/video\/tiny_stream_mid_detail url script-response-body https://github.com/ddgksf2013/Scripts/raw/master/weibo_json.js # > 微博_去除底部超话栏表层浮icon及tips@ddgksf2013 ^https?:\/\/api\.weibo\.cn\/\d\/!\/huati\/discovery_home_bottom_getdotinfo url reject-dict # > 微博_屏蔽首页左上角每日的弹窗tips@ddgksf2013 ^https?:\/\/m?api\.weibo\.c(n|om)\/\d/push/daily url reject-dict # > 微博_屏蔽发现页面搜索框热词@ddgksf2013 -^https?:\/\/m?api\.weibo\.c(n|om)\/\d\/\w{5}\/cardlist url script-response-body https://cdn.jsdelivr.net/gh/sve1r/Rules-For-Quantumult-X@develop/Scripts/AdBlock/Weibo/weibo.min.js +^https?:\/\/m?api\.weibo\.c(n|om)\/\d\/\w{5}\/cardlist url script-response-body https://github.com/ddgksf2013/Scripts/raw/master/weibo_json.js # > 微博_应用内弹窗广告@ddgksf2013 ^https?:\/\/(preload-click|preload-impression)\.uve\.weibo\.com\/(interface\/wbpullad\/wbpullad_click\.php|wbapplua\/get_wbpullad_log\.lua) url reject # > 微博_屏蔽sdkconfig请求@ddgksf2013 @@ -45,34 +124,34 @@ hostname = api.weibo.*, *.api.weibo.*, mapi.weibo.*, *.uve.weibo.com, new.vip.we # > 微博_Spotlight@ddgksf2013 ^https?:\/\/m?api\.weibo\.c(n|om)\/\d\/hot\/hours_spotlight url reject-dict # > 微博_自定义tab皮肤@zmqcherish -^https://api.weibo.cn/2/!/client/light_skin url script-response-body https://cdn.jsdelivr.net/gh/sve1r/Rules-For-Quantumult-X@develop/Scripts/AdBlock/Weibo/weibo.min.js +^https://api.weibo.cn/2/!/client/light_skin url script-response-body https://github.com/ddgksf2013/Scripts/raw/master/weibo_json.js # > 微博_非会员设置tab皮肤@zmqcherish -^https://new.vip.weibo.cn/littleskin/preview url script-response-body https://cdn.jsdelivr.net/gh/sve1r/Rules-For-Quantumult-X@develop/Scripts/AdBlock/Weibo/weibo.min.js +^https://new.vip.weibo.cn/littleskin/preview url script-response-body https://github.com/ddgksf2013/Scripts/raw/master/weibo_json.js # > 微博_去广告以及去除各部分推广模块@zmqcherish,@ddgksf2013 -^https?:\/\/m?api\.weibo\.c(n|om)\/\d\/(searchall|page\?|messageflow) url script-response-body https://cdn.jsdelivr.net/gh/sve1r/Rules-For-Quantumult-X@develop/Scripts/AdBlock/Weibo/weibo.min.js -^https?:\/\/m?api\.weibo\.c(n|om)\/\d\/statuses/(unread_)?friends(/|_)timeline url script-response-body https://cdn.jsdelivr.net/gh/sve1r/Rules-For-Quantumult-X@develop/Scripts/AdBlock/Weibo/weibo.min.js -^https?:\/\/m?api\.weibo\.c(n|om)\/\d\/groups/timeline url script-response-body https://cdn.jsdelivr.net/gh/sve1r/Rules-For-Quantumult-X@develop/Scripts/AdBlock/Weibo/weibo.min.js -^https?:\/\/m?api\.weibo\.c(n|om)\/\d\/statuses/(container_timeline|unread_hot_timeline|extend|video_mixtimeline|unread_topic_timeline) url script-response-body https://cdn.jsdelivr.net/gh/sve1r/Rules-For-Quantumult-X@develop/Scripts/AdBlock/Weibo/weibo.min.js -^https?:\/\/m?api\.weibo\.c(n|om)\/\d\/profile/(me|container_timeline) url script-response-body https://cdn.jsdelivr.net/gh/sve1r/Rules-For-Quantumult-X@develop/Scripts/AdBlock/Weibo/weibo.min.js -^https?:\/\/m?api\.weibo\.c(n|om)\/\d\/video/(community_tab|remind_info|tiny_stream_video_list) url script-response-body https://cdn.jsdelivr.net/gh/sve1r/Rules-For-Quantumult-X@develop/Scripts/AdBlock/Weibo/weibo.min.js -^https?:\/\/m?api\.weibo\.c(n|om)\/\d\/search/(finder|container_timeline|container_discover) url script-response-body https://cdn.jsdelivr.net/gh/sve1r/Rules-For-Quantumult-X@develop/Scripts/AdBlock/Weibo/weibo.min.js -^https?:\/\/m?api\.weibo\.c(n|om)\/\d\/(checkin/show|\!/live/media_homelist|comments/build_comments|container/get_item) url script-response-body https://cdn.jsdelivr.net/gh/sve1r/Rules-For-Quantumult-X@develop/Scripts/AdBlock/Weibo/weibo.min.js -^https?:\/\/m?api\.weibo\.c(n|om)\/\d\/cardlist url script-response-body https://cdn.jsdelivr.net/gh/sve1r/Rules-For-Quantumult-X@develop/Scripts/AdBlock/Weibo/weibo.min.js +^https?:\/\/m?api\.weibo\.c(n|om)\/\d\/(searchall|page\?|messageflow) url script-response-body https://github.com/ddgksf2013/Scripts/raw/master/weibo_json.js +^https?:\/\/m?api\.weibo\.c(n|om)\/\d\/statuses/(unread_)?friends(/|_)timeline url script-response-body https://github.com/ddgksf2013/Scripts/raw/master/weibo_json.js +^https?:\/\/m?api\.weibo\.c(n|om)\/\d\/groups/timeline url script-response-body https://github.com/ddgksf2013/Scripts/raw/master/weibo_json.js +^https?:\/\/m?api\.weibo\.c(n|om)\/\d\/statuses/(container_timeline|unread_hot_timeline|extend|video_mixtimeline|unread_topic_timeline) url script-response-body https://github.com/ddgksf2013/Scripts/raw/master/weibo_json.js +^https?:\/\/m?api\.weibo\.c(n|om)\/\d\/profile/(me|container_timeline) url script-response-body https://github.com/ddgksf2013/Scripts/raw/master/weibo_json.js +^https?:\/\/m?api\.weibo\.c(n|om)\/\d\/video/(community_tab|remind_info|tiny_stream_video_list) url script-response-body https://github.com/ddgksf2013/Scripts/raw/master/weibo_json.js +^https?:\/\/m?api\.weibo\.c(n|om)\/\d\/search/(finder|container_timeline|container_discover) url script-response-body https://github.com/ddgksf2013/Scripts/raw/master/weibo_json.js +^https?:\/\/m?api\.weibo\.c(n|om)\/\d\/(checkin/show|\!/live/media_homelist|comments/build_comments|container/get_item) url script-response-body https://github.com/ddgksf2013/Scripts/raw/master/weibo_json.js +^https?:\/\/m?api\.weibo\.c(n|om)\/\d\/cardlist url script-response-body https://github.com/ddgksf2013/Scripts/raw/master/weibo_json.js # > 微博国际版_屏蔽hotsearch@ddgksf2013 ^https?:\/\/weibointl\.api\.weibo\.c(n|om)\/portal\.php\?a=hot_search_users url reject-dict # > 微博国际版_屏蔽热推荐@ddgksf2013 ^https?:\/\/m?api\.weibo\.c(n|om)\/\d\/ad\/weibointl\? url reject-dict # > 微博国际版_屏蔽searching_info@shiro -^https?:\/\/weibointl\.api\.weibo\.c(n|om)\/portal\.php.*user&a=get_searching_info url echo-response text/html echo-response https://cdn.jsdelivr.net/gh/sve1r/Rules-For-Quantumult-X@develop/Scripts/AdBlock/Weibo/weibo_search_info.json +^https?:\/\/weibointl\.api\.weibo\.c(n|om)\/portal\.php.*user&a=get_searching_info url echo-response text/html echo-response https://github.com/ddgksf2013/Scripts/raw/master/weibo_search_info.json # > 微博国际版_屏蔽search_topic@shiro -^https?:\/\/weibointl\.api\.weibo\.c(n|om)\/portal\.php.*feed&a=search_topic url echo-response text/html echo-response https://cdn.jsdelivr.net/gh/sve1r/Rules-For-Quantumult-X@develop/Scripts/AdBlock/Weibo/weibo_search_topic.json +^https?:\/\/weibointl\.api\.weibo\.c(n|om)\/portal\.php.*feed&a=search_topic url echo-response text/html echo-response https://github.com/ddgksf2013/Scripts/raw/master/weibo_search_topic.json # > 微博国际版_屏蔽开屏广告@ddgksf2013 -^https?:\/\/weibointl\.api\.weibo\.c(n|om)\/portal\.php.*get_coopen_ads url script-response-body https://cdn.jsdelivr.net/gh/sve1r/Rules-For-Quantumult-X@develop/Scripts/AdBlock/Weibo/weibo.min.js +^https?:\/\/weibointl\.api\.weibo\.c(n|om)\/portal\.php.*get_coopen_ads url script-response-body https://github.com/ddgksf2013/Scripts/raw/master/weibo_json.js # > 微博国际版_屏蔽sdkad@ddgksf2013 -^https?://(sdk|wb)app\.uve\.weibo\.com(/interface/sdk/sdkad.php|/wbapplua/wbpullad.lua) url script-response-body https://cdn.jsdelivr.net/gh/sve1r/Rules-For-Quantumult-X@develop/Scripts/AdBlock/Weibo/weibo.min.js +^https?://(sdk|wb)app\.uve\.weibo\.com(/interface/sdk/sdkad.php|/wbapplua/wbpullad.lua) url script-response-body https://github.com/ddgksf2013/Scripts/raw/master/weibo_json.js # > 微博国际版_趋势顶部Card去广告@ddgksf2013 -^https?:\/\/weibointl\.api\.weibo\.c(n|om)\/portal\.php.*feed&a=trends url script-response-body https://cdn.jsdelivr.net/gh/sve1r/Rules-For-Quantumult-X@develop/Scripts/AdBlock/Weibo/weibo.min.js +^https?:\/\/weibointl\.api\.weibo\.c(n|om)\/portal\.php.*feed&a=trends url script-response-body https://github.com/ddgksf2013/Scripts/raw/master/weibo_json.js # > 微博国际版_屏蔽用户VIP栏@ddgksf2013 -^https?:\/\/weibointl\.api\.weibo\.cn\/portal\.php\?a=user_center url script-response-body https://cdn.jsdelivr.net/gh/sve1r/Rules-For-Quantumult-X@develop/Scripts/AdBlock/Weibo/weibo.min.js +^https?:\/\/weibointl\.api\.weibo\.cn\/portal\.php\?a=user_center url script-response-body https://github.com/ddgksf2013/Scripts/raw/master/weibo_json.js # > 微博国际版_热搜处理@ddgksf2013 -^https?:\/\/weibointl\.api\.weibo\.cn\/portal\.php\?a=search_topic url script-response-body https://cdn.jsdelivr.net/gh/sve1r/Rules-For-Quantumult-X@develop/Scripts/AdBlock/Weibo/weibo.min.js \ No newline at end of file +^https?:\/\/weibointl\.api\.weibo\.cn\/portal\.php\?a=search_topic url script-response-body https://github.com/ddgksf2013/Scripts/raw/master/weibo_json.js diff --git a/Scripts/AdBlock/Bilibili/BiliBili.response.js b/Scripts/AdBlock/Bilibili/BiliBili.response.js index 1ffe415..f45e5cb 100644 --- a/Scripts/AdBlock/Bilibili/BiliBili.response.js +++ b/Scripts/AdBlock/Bilibili/BiliBili.response.js @@ -2,10263 +2,6294 @@ WEBSITE: https://biliuniverse.io README: https://github.com/BiliUniverse */ -const $ = new Env('📺 BiliBili: 🛡️ ADBlock v0.3.1(2) response'); +const $ = new Env("📺 BiliBili: 🛡️ ADBlock v0.4.0(2) response"); const URL = new URLs(); const DataBase = { - ADBlock: { - Settings: { - Switch: true, - Detail: { - splash: true, - feed: true, - activity: false, - story: true, - cinema: true, - view: true, - search: true, - commandDms: false, - colorfulDms: false, - MainList: true, - xlive: true, - Hot_search: true, - Hot_topics: true, - Most_visited: true, - Dynamic_adcard: true, - }, + "ADBlock": { + "Settings": { + "Switch": true, + "Detail": { + "splash": true, + "feed": true, + "activity": false, + "story": true, + "cinema": true, + "view": true, + "search": true, + "commandDms": false, + "colorfulDms": false, + "MainList": true, + "xlive": true, + "Hot_search": true, + "Hot_topics": true, + "Most_visited": true, + "Dynamic_adcard": true + } + } }, - }, - Default: { - Settings: { Switch: true }, - }, + "Default": { + "Settings": {"Switch": true} + } }; /***************** Processing *****************/ (async () => { - const { Settings, Caches, Configs } = setENV('BiliBili', 'ADBlock', DataBase); - switch (Settings?.Switch) { - case true: - default: - let url = URL.parse($request?.url); - const METHOD = $request?.method, - HOST = url?.host, - PATH = url?.path, - PATHs = PATH.split('/'); - // 解析格式 - const FORMAT = ( - $response?.headers?.['Content-Type'] ?? - $response?.headers?.['content-type'] - )?.split(';')?.[0]; - $.log( - `⚠ ${$.name}`, - `METHOD: ${METHOD}`, - `HOST: ${HOST}`, - `PATH: ${PATH}`, - `PATHs: ${PATHs}`, - `FORMAT: ${FORMAT}`, - '' - ); - // 创建空数据 - let body = { code: 0, message: '0', data: {} }; - // 格式判断 - switch (FORMAT) { - case undefined: // 视为无body - break; - case 'application/x-www-form-urlencoded': - case 'text/plain': - case 'text/html': + const {Settings, Caches, Configs} = setENV("BiliBili", "ADBlock", DataBase); + $.log(`⚠ ${$.name}`, `Settings.Switch: ${Settings?.Switch}`, ""); + switch (Settings.Switch) { + case true: default: - break; - case 'text/xml': - case 'text/plist': - case 'application/xml': - case 'application/plist': - case 'application/x-plist': - break; - case 'text/json': - case 'application/json': - body = JSON.parse($response.body); - // 解析链接 - switch (HOST) { - case 'www.bilibili.com': - break; - case 'app.bilibili.com': - case 'app.biliapi.net': - switch (PATH) { - case 'x/v2/splash/show': // 开屏页 - case 'x/v2/splash/list': // 开屏页 - case 'x/v2/splash/brand/list': // 开屏页 - case 'x/v2/splash/event/list2': // 开屏页 - switch (Settings?.Detail?.splash) { - case true: - default: - const item = ['account', 'event_list', 'preload', 'show']; - if (body.data) { - item.forEach((i) => { - delete body.data[i]; - }); - $.log(`🎉 ${$.name}`, '开屏页广告去除'); - } - break; - case false: - $.log(`🚧 ${$.name}`, '用户设置开屏页广告不去除'); - break; - } - break; - case 'x/v2/feed/index': // 推荐页 - switch (Settings?.Detail?.feed) { - case true: - default: - if (body.data.items?.length) { - let params = url?.params; //区分pad与phone - body.data.items = await Promise.all( - body.data.items.map(async (item) => { - const { card_type: cardType, card_goto: cardGoto } = - item; - if (cardType && cardGoto) { - if ( - ['banner_v8', 'banner_ipad_v8'].includes( - cardType - ) && - cardGoto === 'banner' - ) { - switch (Settings?.Detail?.activity) { - case true: - default: - Caches.banner_hash = item.hash; - $.setjson( - Caches, - '@BiliBili.ADBlock.Caches' - ); // 获取banner_hash,无此字段会有活动页且此字段无法伪造. - $.log(`🎉 ${$.name}`, '推荐页活动大图去除'); - return undefined; - case false: - if (item.banner_item) { - item.banner_item = - item.banner_item.filter((i) => { - if (i.type === 'ad') { - $.log( - `🎉 ${$.name}`, - '推荐页大图广告去除' - ); - return false; - } - return true; - }); + let url = URL.parse($request?.url); + const METHOD = $request?.method, HOST = url?.host, PATH = url?.path, PATHs = url?.paths; + // 解析格式 + const FORMAT = ($response?.headers?.["Content-Type"] ?? $response?.headers?.["content-type"])?.split(";")?.[0]; + $.log(`⚠ ${$.name}`, `METHOD: ${METHOD}`, `HOST: ${HOST}`, `PATH: ${PATH}`, `PATHs: ${PATHs}`, `FORMAT: ${FORMAT}`, ""); + // 创建空数据 + let body = {"code": 0, "message": "0", "data": {}}; + // 格式判断 + switch (FORMAT) { + case undefined: // 视为无body + break; + case "application/x-www-form-urlencoded": + case "text/plain": + case "text/html": + default: + break; + case "application/x-mpegURL": + case "application/x-mpegurl": + case "application/vnd.apple.mpegurl": + break; + case "text/xml": + case "text/plist": + case "application/xml": + case "application/plist": + case "application/x-plist": + break; + case "text/json": + case "application/json": + body = JSON.parse($response.body); + // 解析链接 + switch (HOST) { + case "www.bilibili.com": + break; + case "app.bilibili.com": + case "app.biliapi.net": + switch (PATH) { + case "x/v2/splash/show": // 开屏页 + case "x/v2/splash/list": // 开屏页 + case "x/v2/splash/brand/list": // 开屏页 + case "x/v2/splash/event/list2": // 开屏页 + switch (Settings?.Detail?.splash) { + case true: + default: + const item = ["account", "event_list", "preload", "show"]; + if (body.data) { + item.forEach((i) => { + delete body.data[i]; + }); + $.log(`🎉 ${$.name}`, "开屏页广告去除"); + } + break; + case false: + $.log(`🚧 ${$.name}`, "用户设置开屏页广告不去除"); + break; + } + ; + break; + case "x/v2/feed/index": // 推荐页 + switch (Settings?.Detail?.feed) { + case true: + default: + if (body.data.items?.length) { + //区分pad与phone + body.data.items = await Promise.all(body.data.items.map(async item => { + const {card_type: cardType, card_goto: cardGoto} = item; + if (cardType && cardGoto) { + if (['banner_v8', 'banner_ipad_v8'].includes(cardType) && cardGoto === 'banner') { + switch (Settings?.Detail?.activity) { + case true: + default: + Caches.banner_hash = item.hash; + $.setjson(Caches, "@BiliBili.ADBlock.Caches"); // 获取banner_hash,无此字段会有活动页且此字段无法伪造. + $.log(`🎉 ${$.name}`, "推荐页活动大图去除"); + return undefined; + case false: + if (item.banner_item) { + item.banner_item = item.banner_item.filter(i => { + if (i.type === 'ad') { + $.log(`🎉 ${$.name}`, "推荐页大图广告去除"); + return false; + } + return true; + }); + } + break; + } + } else if (['cm_v2', 'cm_v1'].includes(cardType) && ['ad_web_s', 'ad_av', 'ad_web_gif'].includes(cardGoto)) { + // ad_player大视频广告 ad_web_gif大gif广告 ad_web_s普通小广告 ad_av创作推广广告 ad_inline_3d 上方大的视频3d广告 ad_inline_eggs 上方大的视频广告 + $.log(`🎉 ${$.name}`, `${cardGoto}广告去除`); + if (url?.query?.device !== "phone") { + return undefined;//pad直接去除 + } else { + await fixPosition().then(result => item = result);//小广告补位 + } + } else if (cardGoto === 'live' && cardType === 'small_cover_v9') { + let blockUpLiveList = Settings?.Detail?.blockUpLiveList; + if (typeof blockUpLiveList === 'number') { + blockUpLiveList = blockUpLiveList.toString(); + } + if (blockUpLiveList && blockUpLiveList.includes(item?.args?.up_id?.toString())) { + $.log(`🎉 ${$.name}`, `屏蔽Up主<${item?.args?.up_name}>直播推广`); + await fixPosition().then(result => item = result);//小广告补位 + } + } else if (cardType === 'cm_v2' && ['ad_player', 'ad_inline_3d', 'ad_inline_eggs'].includes(cardGoto)) { + $.log(`🎉 ${$.name}`, `${cardGoto}广告去除`); + return undefined;//大广告直接去除 + } else if (cardType === 'small_cover_v10' && cardGoto === 'game') { + $.log(`🎉 ${$.name}`, "游戏广告去除"); + if (url?.query?.device !== "phone") { + return undefined;//pad直接去除 + } else { + await fixPosition().then(result => item = result);//小广告补位 + } + } else if (cardType === 'cm_double_v9' && cardGoto === 'ad_inline_av') { + $.log(`🎉 ${$.name}`, "大视频广告去除"); + return undefined;//大广告直接去除 + } + } + return item; + })); + body.data.items = body.data.items.filter(fix => fix !== undefined); + } + + async function fixPosition() { + let itemsCache = $.getdata("@BiliBili.Index.Caches", ""); + let singleItem = {}; + if (itemsCache && itemsCache.length > 0) { + singleItem = itemsCache.pop(); + $.log(`🎉 ${$.name}`, "推荐页空缺位填充成功"); + } else {//重新获取填充位 + const myRequest = { + url: $request.url, + headers: $request.heders + } + await $.http.get(myRequest).then(response => { + try { + const body = $.toObj(response.body) + if (body?.code === 0 && body?.message === "0") { + body.data.items = body.data.items.map(item => { + const {card_type: cardType, card_goto: cardGoto} = item; + if (cardType && cardGoto) { + if (cardType === 'banner_v8' && cardGoto === 'banner') { + return undefined; + } else if (cardType === 'cm_v2' && ['ad_web_s', 'ad_av', 'ad_web_gif', 'ad_player', 'ad_inline_3d', 'ad_inline_eggs'].includes(cardGoto)) { + return undefined; + } else if (cardType === 'small_cover_v10' && cardGoto === 'game') { + return undefined; + } else if (cardType === 'cm_double_v9' && cardGoto === 'ad_inline_av') { + return undefined; + } else if (cardType === 'large_cover_v9' && cardGoto === 'inline_av_v2') {//补位不需要大视频 + return undefined; + } + } + return item; + }).filter(fix => fix !== undefined); + $.setdata(body.data.items, "@BiliBili.Index.Caches"); + $.log(`🎉 ${$.name}`, "推荐页缓存数组补充成功"); + } else { + $.log(`🚧 ${$.name}`, "访问推荐页尝试填补失败"); + } + } catch (e) { + $.logErr(e, response) + } + }) + itemsCache = $.getdata("@BiliBili.Index.Caches", ""); + if (itemsCache.length > 0) { + singleItem = itemsCache.pop(); + $.log(`🎉 ${$.name}`, "推荐页空缺位填充成功"); + } + } + $.setdata(itemsCache, "@BiliBili.Index.Caches"); + return singleItem; + } + + break; + case false: + $.log(`🚧 ${$.name}`, "用户设置推荐页广告不去除"); + break; + } + ; + break; + case "x/v2/feed/index/story": // 首页短视频流 + switch (Settings?.Detail?.story) { + case true: + default: + if (body.data?.items) { + // vertical_live 直播内容 + // vertical_pgc 大会员专享 + body.data.items = body.data.items.filter((i) => !( + i.hasOwnProperty("ad_info") || + ["vertical_ad_av", "vertical_pgc"].includes(i.card_goto) + ) + ); + $.log(`🎉 ${$.name}`, "首页短视频流广告去除"); + } + break; + case false: + $.log(`🚧 ${$.name}`, "用户设置首页短视频流广告不去除"); + break; + } + ; + break; + case "x/v2/search/square": // 搜索页 + switch (Settings?.Detail?.Hot_search) { + case true: + default: + body.data = body.data.filter((i) => !(i.type === "trending")); + $.log(`🎉 ${$.name}`, "搜索页热搜内容去除"); + break; + case false: + $.log(`🚧 ${$.name}`, "用户设置搜索页热搜内容不去除"); + break; } break; - } - } else if ( - ['cm_v2', 'cm_v1'].includes(cardType) && - ['ad_web_s', 'ad_av', 'ad_web_gif'].includes( - cardGoto - ) - ) { - // ad_player大视频广告 ad_web_gif大gif广告 ad_web_s普通小广告 ad_av创作推广广告 ad_inline_3d 上方大的视频3d广告 ad_inline_eggs 上方大的视频广告 - $.log(`🎉 ${$.name}`, `${cardGoto}广告去除`); - if (params.device !== 'phone') { - return undefined; //pad直接去除 - } else { - await fixPosition().then( - (result) => (item = result) - ); //小广告补位 - } - } else if ( - cardGoto === 'live' && - cardType === 'small_cover_v9' - ) { - let blockUpLiveList = - Settings?.Detail?.blockUpLiveList; - if (typeof blockUpLiveList === 'number') { - blockUpLiveList = blockUpLiveList.toString(); - } - if ( - blockUpLiveList && - blockUpLiveList.includes( - item?.args?.up_id?.toString() - ) - ) { - $.log( - `🎉 ${$.name}`, - `屏蔽Up主<${item?.args?.up_name}>直播推广` - ); - await fixPosition().then( - (result) => (item = result) - ); //小广告补位 - } - } else if ( - cardType === 'cm_v2' && - [ - 'ad_player', - 'ad_inline_3d', - 'ad_inline_eggs', - ].includes(cardGoto) - ) { - $.log(`🎉 ${$.name}`, `${cardGoto}广告去除`); - return undefined; //大广告直接去除 - } else if ( - cardType === 'small_cover_v10' && - cardGoto === 'game' - ) { - $.log(`🎉 ${$.name}`, '游戏广告去除'); - if (params.device !== 'phone') { - return undefined; //pad直接去除 - } else { - await fixPosition().then( - (result) => (item = result) - ); //小广告补位 - } - } else if ( - cardType === 'cm_double_v9' && - cardGoto === 'ad_inline_av' - ) { - $.log(`🎉 ${$.name}`, '大视频广告去除'); - return undefined; //大广告直接去除 - } } - return item; - }) - ); - body.data.items = body.data.items.filter( - (fix) => fix !== undefined - ); - } - async function fixPosition() { - let itemsCache = $.getdata( - '@BiliBili.Index.Caches', - '' - ); - let singleItem = {}; - if (itemsCache && itemsCache.length > 0) { - singleItem = itemsCache.pop(); - $.log(`🎉 ${$.name}`, '推荐页空缺位填充成功'); - } else { - //重新获取填充位 - const myRequest = { - url: $request.url, - headers: $request.heders, - }; - await $.http.get(myRequest).then((response) => { - try { - const body = $.toObj(response.body); - if (body?.code === 0 && body?.message === '0') { - body.data.items = body.data.items - .map((item) => { - const { - card_type: cardType, - card_goto: cardGoto, - } = item; - if (cardType && cardGoto) { - if ( - cardType === 'banner_v8' && - cardGoto === 'banner' - ) { - return undefined; - } else if ( - cardType === 'cm_v2' && - [ - 'ad_web_s', - 'ad_av', - 'ad_web_gif', - 'ad_player', - 'ad_inline_3d', - 'ad_inline_eggs', - ].includes(cardGoto) - ) { - return undefined; - } else if ( - cardType === 'small_cover_v10' && - cardGoto === 'game' - ) { - return undefined; - } else if ( - cardType === 'cm_double_v9' && - cardGoto === 'ad_inline_av' - ) { - return undefined; - } else if ( - cardType === 'large_cover_v9' && - cardGoto === 'inline_av_v2' - ) { - //补位不需要大视频 - return undefined; - } - } - return item; - }) - .filter((fix) => fix !== undefined); - $.setdata( - body.data.items, - '@BiliBili.Index.Caches' - ); - $.log(`🎉 ${$.name}`, '推荐页缓存数组补充成功'); - } else { - $.log(`🚧 ${$.name}`, '访问推荐页尝试填补失败'); - } - } catch (e) { - $.logErr(e, response); - } - }); - itemsCache = $.getdata('@BiliBili.Index.Caches', ''); - if (itemsCache.length > 0) { - singleItem = itemsCache.pop(); - $.log(`🎉 ${$.name}`, '推荐页空缺位填充成功'); - } - } - $.setdata(itemsCache, '@BiliBili.Index.Caches'); - return singleItem; - } - break; - case false: - $.log(`🚧 ${$.name}`, '用户设置推荐页广告不去除'); - break; - } - break; - case 'x/v2/feed/index/story': // 首页短视频流 - switch (Settings?.Detail?.story) { - case true: - default: - if (body.data?.items) { - // vertical_live 直播内容 - // vertical_pgc 大会员专享 - body.data.items = body.data.items.filter( - (i) => - !( - i.hasOwnProperty('ad_info') || - ['vertical_ad_av', 'vertical_pgc'].includes( - i.card_goto - ) - ) - ); - $.log(`🎉 ${$.name}`, '首页短视频流广告去除'); - } - break; - case false: - $.log(`🚧 ${$.name}`, '用户设置首页短视频流广告不去除'); - break; - } - break; - case 'x/v2/search/square': // 搜索页 - switch (Settings?.Detail?.Hot_search) { - case true: - default: - body.data = body.data.filter( - (i) => !(i.type === 'trending') - ); - $.log(`🎉 ${$.name}`, '搜索页热搜内容去除'); - break; - case false: - $.log(`🚧 ${$.name}`, '用户设置搜索页热搜内容不去除'); - break; - } - break; - } - break; - case 'api.bilibili.com': - case 'api.biliapi.net': - switch (PATH) { - case 'pgc/player/api/playurl': // 番剧-播放地址-api - case 'pgc/player/web/playurl': // 番剧-播放地址-web - case 'pgc/player/web/playurl/html5': // 番剧-播放地址-web-HTML5 - break; - case 'pgc/view/v2/app/season': // 番剧页面-内容-app - break; - case 'pgc/view/web/season': // 番剧-内容-web - case 'pgc/view/pc/season': // 番剧-内容-pc - break; - case 'pgc/page/bangumi': // 追番页 - case 'pgc/page/cinema/tab': // 观影页 - switch (Settings?.Detail?.cinema) { - case true: - default: - if (body.result?.modules) { - body.result.modules.forEach((i) => { - if (i.style.startsWith('banner')) { - i.items = i.items.filter((j) => - j.link.includes('play') - ); - } else if (i.style.startsWith('function')) { - i.items = i.items.filter((j) => - j.blink.startsWith('bilibili') - ); - } else if ( - [241, 1283, 1284, 1441].includes(i.module_id) - ) { - i.items = []; - } else if (i.style.startsWith('tip')) { - i.items = []; - } - }); - $.log(`🎉 ${$.name}`, '观影页广告去除'); - } - break; - case false: - $.log(`🚧 ${$.name}`, '用户设置观影页广告不去除'); - break; - } - break; - case 'x/player/wbi/playurl': // UGC-用户生产内容-播放地址 - break; - case 'x/web-interface/wbi/index/top/feed/rcmd': // web首页 - switch (Settings?.Detail?.feed) { - case true: - default: - body.data.item = body.data.item.filter( - (i) => !(i.goto === 'ad') - ); - $.log(`🎉 ${$.name}`, '首页广告内容去除'); - break; - case false: - $.log(`🚧 ${$.name}`, '用户设置首页广告不去除'); - break; - } - break; - case 'x/space/acc/info': // 用户空间-账号信息-pc - case 'x/space/wbi/acc/info': // 用户空间-账号信息-wbi - switch (url.params?.vmid || url.params?.mid) { - case '11783021': // 哔哩哔哩番剧出差 - case '1988098633': // b站_戲劇咖 - case '2042149112': // b站_綜藝咖 - break; - default: - break; - } - break; - } - break; - case 'api.live.bilibili.com': - switch (PATH) { - case 'xlive/app-room/v1/index/getInfoByRoom': // 直播 - switch (Settings?.Detail?.xlive) { - case true: - default: - if (body.data?.activity_banner_info) { - body.data.activity_banner_info = null; - $.log(`🎉 ${$.name}`, '直播banner广告去除'); - } - if (body.data?.shopping_info) { - body.data.shopping_info = { - is_show: 0, - }; - $.log(`🎉 ${$.name}`, '直播购物广告去除'); - } - if (body.data?.new_tab_info?.outer_list?.length > 0) { - body.data.new_tab_info.outer_list = - body.data.new_tab_info.outer_list.filter( - (i) => i.biz_id !== 33 - ); - } - break; - case false: - $.log(`🚧 ${$.name}`, '用户设置直播页广告不去除'); - break; - } - break; - } - break; - } - $response.body = JSON.stringify(body); - break; - case 'application/x-protobuf': - case 'application/grpc': - case 'application/grpc+proto': - case 'applecation/octet-stream': - let rawBody = $.isQuanX() - ? new Uint8Array($response.bodyBytes) - : $response.body; - //$.log(`🚧 ${$.name}`, `isBuffer? ${ArrayBuffer.isView(rawBody)}: ${JSON.stringify(rawBody)}`, ""); - /****************** initialization start *******************/ - // timostamm/protobuf-ts - !(function (i) { - 'use strict'; - function _(n, e, i) { - return e <= n && n <= i; - } - 'undefined' != typeof module && - module.exports && - !i['encoding-indexes'] && - (i['encoding-indexes'] = require('./encoding-indexes.js')[ - 'encoding-indexes' - ]); - var l = Math.floor; - function s(n) { - if (void 0 === n) return {}; - if (n === Object(n)) return n; - throw TypeError('Could not convert argument to dictionary'); - } - function u(n) { - return 0 <= n && n <= 127; - } - var a = u, - b = -1; - function c(n) { - (this.tokens = [].slice.call(n)), this.tokens.reverse(); - } - c.prototype = { - endOfStream: function () { - return !this.tokens.length; - }, - read: function () { - return this.tokens.length ? this.tokens.pop() : b; - }, - prepend: function (n) { - if (Array.isArray(n)) - for (var e = n; e.length; ) this.tokens.push(e.pop()); - else this.tokens.push(n); - }, - push: function (n) { - if (Array.isArray(n)) - for (var e = n; e.length; ) this.tokens.unshift(e.shift()); - else this.tokens.unshift(n); - }, - }; - var w = -1; - function m(n, e) { - if (n) throw TypeError('Decoder error'); - return e || 65533; - } - function f(n) { - throw TypeError('The code point ' + n + ' could not be encoded.'); - } - function r(n) { - return ( - (n = String(n).trim().toLowerCase()), - Object.prototype.hasOwnProperty.call(d, n) ? d[n] : null - ); - } - var t, - o, - n = [ - { - encodings: [ - { - labels: ['unicode-1-1-utf-8', 'utf-8', 'utf8'], - name: 'UTF-8', - }, - ], - heading: 'The Encoding', - }, - { - encodings: [ - { - labels: ['866', 'cp866', 'csibm866', 'ibm866'], - name: 'IBM866', - }, - { - labels: [ - 'csisolatin2', - 'iso-8859-2', - 'iso-ir-101', - 'iso8859-2', - 'iso88592', - 'iso_8859-2', - 'iso_8859-2:1987', - 'l2', - 'latin2', - ], - name: 'ISO-8859-2', - }, - { - labels: [ - 'csisolatin3', - 'iso-8859-3', - 'iso-ir-109', - 'iso8859-3', - 'iso88593', - 'iso_8859-3', - 'iso_8859-3:1988', - 'l3', - 'latin3', - ], - name: 'ISO-8859-3', - }, - { - labels: [ - 'csisolatin4', - 'iso-8859-4', - 'iso-ir-110', - 'iso8859-4', - 'iso88594', - 'iso_8859-4', - 'iso_8859-4:1988', - 'l4', - 'latin4', - ], - name: 'ISO-8859-4', - }, - { - labels: [ - 'csisolatincyrillic', - 'cyrillic', - 'iso-8859-5', - 'iso-ir-144', - 'iso8859-5', - 'iso88595', - 'iso_8859-5', - 'iso_8859-5:1988', - ], - name: 'ISO-8859-5', - }, - { - labels: [ - 'arabic', - 'asmo-708', - 'csiso88596e', - 'csiso88596i', - 'csisolatinarabic', - 'ecma-114', - 'iso-8859-6', - 'iso-8859-6-e', - 'iso-8859-6-i', - 'iso-ir-127', - 'iso8859-6', - 'iso88596', - 'iso_8859-6', - 'iso_8859-6:1987', - ], - name: 'ISO-8859-6', - }, - { - labels: [ - 'csisolatingreek', - 'ecma-118', - 'elot_928', - 'greek', - 'greek8', - 'iso-8859-7', - 'iso-ir-126', - 'iso8859-7', - 'iso88597', - 'iso_8859-7', - 'iso_8859-7:1987', - 'sun_eu_greek', - ], - name: 'ISO-8859-7', - }, - { - labels: [ - 'csiso88598e', - 'csisolatinhebrew', - 'hebrew', - 'iso-8859-8', - 'iso-8859-8-e', - 'iso-ir-138', - 'iso8859-8', - 'iso88598', - 'iso_8859-8', - 'iso_8859-8:1988', - 'visual', - ], - name: 'ISO-8859-8', - }, - { - labels: ['csiso88598i', 'iso-8859-8-i', 'logical'], - name: 'ISO-8859-8-I', - }, - { - labels: [ - 'csisolatin6', - 'iso-8859-10', - 'iso-ir-157', - 'iso8859-10', - 'iso885910', - 'l6', - 'latin6', - ], - name: 'ISO-8859-10', - }, - { - labels: ['iso-8859-13', 'iso8859-13', 'iso885913'], - name: 'ISO-8859-13', - }, - { - labels: ['iso-8859-14', 'iso8859-14', 'iso885914'], - name: 'ISO-8859-14', - }, - { - labels: [ - 'csisolatin9', - 'iso-8859-15', - 'iso8859-15', - 'iso885915', - 'iso_8859-15', - 'l9', - ], - name: 'ISO-8859-15', - }, - { labels: ['iso-8859-16'], name: 'ISO-8859-16' }, - { - labels: ['cskoi8r', 'koi', 'koi8', 'koi8-r', 'koi8_r'], - name: 'KOI8-R', - }, - { labels: ['koi8-ru', 'koi8-u'], name: 'KOI8-U' }, - { - labels: [ - 'csmacintosh', - 'mac', - 'macintosh', - 'x-mac-roman', - ], - name: 'macintosh', - }, - { - labels: [ - 'dos-874', - 'iso-8859-11', - 'iso8859-11', - 'iso885911', - 'tis-620', - 'windows-874', - ], - name: 'windows-874', - }, - { - labels: ['cp1250', 'windows-1250', 'x-cp1250'], - name: 'windows-1250', - }, - { - labels: ['cp1251', 'windows-1251', 'x-cp1251'], - name: 'windows-1251', - }, - { - labels: [ - 'ansi_x3.4-1968', - 'ascii', - 'cp1252', - 'cp819', - 'csisolatin1', - 'ibm819', - 'iso-8859-1', - 'iso-ir-100', - 'iso8859-1', - 'iso88591', - 'iso_8859-1', - 'iso_8859-1:1987', - 'l1', - 'latin1', - 'us-ascii', - 'windows-1252', - 'x-cp1252', - ], - name: 'windows-1252', - }, - { - labels: ['cp1253', 'windows-1253', 'x-cp1253'], - name: 'windows-1253', - }, - { - labels: [ - 'cp1254', - 'csisolatin5', - 'iso-8859-9', - 'iso-ir-148', - 'iso8859-9', - 'iso88599', - 'iso_8859-9', - 'iso_8859-9:1989', - 'l5', - 'latin5', - 'windows-1254', - 'x-cp1254', - ], - name: 'windows-1254', - }, - { - labels: ['cp1255', 'windows-1255', 'x-cp1255'], - name: 'windows-1255', - }, - { - labels: ['cp1256', 'windows-1256', 'x-cp1256'], - name: 'windows-1256', - }, - { - labels: ['cp1257', 'windows-1257', 'x-cp1257'], - name: 'windows-1257', - }, - { - labels: ['cp1258', 'windows-1258', 'x-cp1258'], - name: 'windows-1258', - }, - { - labels: ['x-mac-cyrillic', 'x-mac-ukrainian'], - name: 'x-mac-cyrillic', - }, - ], - heading: 'Legacy single-byte encodings', - }, - { - encodings: [ - { - labels: [ - 'chinese', - 'csgb2312', - 'csiso58gb231280', - 'gb2312', - 'gb_2312', - 'gb_2312-80', - 'gbk', - 'iso-ir-58', - 'x-gbk', - ], - name: 'GBK', - }, - { labels: ['gb18030'], name: 'gb18030' }, - ], - heading: 'Legacy multi-byte Chinese (simplified) encodings', - }, - { - encodings: [ - { - labels: [ - 'big5', - 'big5-hkscs', - 'cn-big5', - 'csbig5', - 'x-x-big5', - ], - name: 'Big5', - }, - ], - heading: 'Legacy multi-byte Chinese (traditional) encodings', - }, - { - encodings: [ - { - labels: ['cseucpkdfmtjapanese', 'euc-jp', 'x-euc-jp'], - name: 'EUC-JP', - }, - { - labels: ['csiso2022jp', 'iso-2022-jp'], - name: 'ISO-2022-JP', - }, - { - labels: [ - 'csshiftjis', - 'ms932', - 'ms_kanji', - 'shift-jis', - 'shift_jis', - 'sjis', - 'windows-31j', - 'x-sjis', - ], - name: 'Shift_JIS', - }, - ], - heading: 'Legacy multi-byte Japanese encodings', - }, - { - encodings: [ - { - labels: [ - 'cseuckr', - 'csksc56011987', - 'euc-kr', - 'iso-ir-149', - 'korean', - 'ks_c_5601-1987', - 'ks_c_5601-1989', - 'ksc5601', - 'ksc_5601', - 'windows-949', - ], - name: 'EUC-KR', - }, - ], - heading: 'Legacy multi-byte Korean encodings', - }, - { - encodings: [ - { - labels: [ - 'csiso2022kr', - 'hz-gb-2312', - 'iso-2022-cn', - 'iso-2022-cn-ext', - 'iso-2022-kr', - ], - name: 'replacement', - }, - { labels: ['utf-16be'], name: 'UTF-16BE' }, - { labels: ['utf-16', 'utf-16le'], name: 'UTF-16LE' }, - { labels: ['x-user-defined'], name: 'x-user-defined' }, - ], - heading: 'Legacy miscellaneous encodings', - }, - ], - d = {}, - h = - (n.forEach(function (n) { - n.encodings.forEach(function (e) { - e.labels.forEach(function (n) { - d[n] = e; - }); - }); - }), - {}), - g = {}; - function y(n, e) { - return (e && e[n]) || null; - } - function p(n, e) { - e = e.indexOf(n); - return -1 === e ? null : e; - } - function v(n) { - if ('encoding-indexes' in i) return i['encoding-indexes'][n]; - throw Error( - 'Indexes missing. Did you forget to include encoding-indexes.js first?' - ); - } - var x = 'utf-8'; - function O(n, e) { - if (!(this instanceof O)) - throw TypeError("Called as a function. Did you forget 'new'?"); - (n = void 0 !== n ? String(n) : x), - (e = s(e)), - (this._encoding = null), - (this._decoder = null), - (this._ignoreBOM = !1), - (this._BOMseen = !1), - (this._error_mode = 'replacement'), - (this._do_not_flush = !1); - var i = r(n); - if (null === i || 'replacement' === i.name) - throw RangeError('Unknown encoding: ' + n); - if (g[i.name]) - return ( - ((n = this)._encoding = i), - Boolean(e.fatal) && (n._error_mode = 'fatal'), - Boolean(e.ignoreBOM) && (n._ignoreBOM = !0), - Object.defineProperty || - ((this.encoding = n._encoding.name.toLowerCase()), - (this.fatal = 'fatal' === n._error_mode), - (this.ignoreBOM = n._ignoreBOM)), - n - ); - throw Error( - 'Decoder not present. Did you forget to include encoding-indexes.js first?' - ); - } - function k(n, e) { - if (!(this instanceof k)) - throw TypeError("Called as a function. Did you forget 'new'?"); - (e = s(e)), - (this._encoding = null), - (this._encoder = null), - (this._do_not_flush = !1), - (this._fatal = Boolean(e.fatal) ? 'fatal' : 'replacement'); - if (Boolean(e.NONSTANDARD_allowLegacyEncoding)) { - e = r((n = void 0 !== n ? String(n) : x)); - if (null === e || 'replacement' === e.name) - throw RangeError('Unknown encoding: ' + n); - if (!h[e.name]) - throw Error( - 'Encoder not present. Did you forget to include encoding-indexes.js first?' - ); - this._encoding = e; - } else - (this._encoding = r('utf-8')), - void 0 !== n && - 'console' in i && - console.warn( - 'TextEncoder constructor called with encoding label, which is ignored.' - ); - return ( - Object.defineProperty || - (this.encoding = this._encoding.name.toLowerCase()), - this - ); - } - function e(n) { - var r = n.fatal, - t = 0, - o = 0, - s = 0, - l = 128, - a = 191; - this.handler = function (n, e) { - if (e === b && 0 !== s) return (s = 0), m(r); - if (e === b) return w; - if (0 === s) { - if (_(e, 0, 127)) return e; - if (_(e, 194, 223)) (s = 1), (t = 31 & e); - else if (_(e, 224, 239)) - 224 === e && (l = 160), - 237 === e && (a = 159), - (s = 2), - (t = 15 & e); - else { - if (!_(e, 240, 244)) return m(r); - 240 === e && (l = 144), - 244 === e && (a = 143), - (s = 3), - (t = 7 & e); - } - return null; - } - var i; - return _(e, l, a) - ? ((l = 128), - (a = 191), - (t = (t << 6) | (63 & e)), - (o += 1) !== s ? null : ((i = t), (t = s = o = 0), i)) - : ((t = s = o = 0), (l = 128), (a = 191), n.prepend(e), m(r)); - }; - } - function E(n) { - n.fatal; - this.handler = function (n, e) { - if (e === b) return w; - if (a(e)) return e; - _(e, 128, 2047) - ? ((i = 1), (r = 192)) - : _(e, 2048, 65535) - ? ((i = 2), (r = 224)) - : _(e, 65536, 1114111) && ((i = 3), (r = 240)); - for (var i, r, t = [(e >> (6 * i)) + r]; 0 < i; ) - t.push(128 | (63 & (e >> (6 * (i - 1))))), --i; - return t; - }; - } - function j(i, n) { - var r = n.fatal; - this.handler = function (n, e) { - return e === b - ? w - : u(e) - ? e - : null === (e = i[e - 128]) - ? m(r) - : e; - }; - } - function B(r, n) { - n.fatal; - this.handler = function (n, e) { - var i; - return e === b - ? w - : a(e) - ? e - : (null === (i = p(e, r)) && f(e), i + 128); - }; - } - function S(n) { - var o = n.fatal, - s = 0, - l = 0, - a = 0; - this.handler = function (n, e) { - var i, r, t; - return e === b && 0 === s && 0 === l && 0 === a - ? w - : (e !== b || - (0 === s && 0 === l && 0 === a) || - ((a = l = s = 0), m(o)), - 0 !== a - ? ((i = null), - _(e, 48, 57) && - (i = (function (n) { - if ((39419 < n && n < 189e3) || 1237575 < n) - return null; - if (7457 === n) return 59335; - for ( - var e = 0, i = 0, r = v('gb18030-ranges'), t = 0; - t < r.length; - ++t - ) { - var o = r[t]; - if (!(o[0] <= n)) break; - (e = o[0]), (i = o[1]); - } - return i + n - e; - })( - 10 * (126 * (10 * (s - 129) + l - 48) + a - 129) + - e - - 48 - )), - (r = [l, a, e]), - (a = l = s = 0), - null === i ? (n.prepend(r), m(o)) : i) - : 0 !== l - ? _(e, 129, 254) - ? ((a = e), null) - : (n.prepend([l, e]), (l = s = 0), m(o)) - : 0 !== s - ? _(e, 48, 57) - ? ((l = e), null) - : ((r = s), - (s = 0), - (t = null) === - (i = - null === - (t = - _(e, 64, 126) || _(e, 128, 254) - ? 190 * (r - 129) + (e - (e < 127 ? 64 : 65)) - : t) - ? null - : y(t, v('gb18030'))) && - u(e) && - n.prepend(e), - null === i ? m(o) : i) - : u(e) - ? e - : 128 === e - ? 8364 - : _(e, 129, 254) - ? ((s = e), null) - : m(o)); - }; - } - function T(n, t) { - n.fatal; - this.handler = function (n, e) { - var i, r; - return e === b - ? w - : a(e) - ? e - : 58853 === e - ? f(e) - : t && 8364 === e - ? 128 - : null !== (i = p(e, v('gb18030'))) - ? ((r = i % 190), [l(i / 190) + 129, r + (r < 63 ? 64 : 65)]) - : t - ? f(e) - : ((i = (function (n) { - if (59335 === n) return 7457; - for ( - var e = 0, i = 0, r = v('gb18030-ranges'), t = 0; - t < r.length; - ++t - ) { - var o = r[t]; - if (!(o[1] <= n)) break; - (e = o[1]), (i = o[0]); - } - return i + n - e; - })(e)), - [ - (r = l(i / 10 / 126 / 10)) + 129, - (e = l((i -= 10 * r * 126 * 10) / 10 / 126)) + 48, - (r = l((i -= 10 * e * 126) / 10)) + 129, - 48 + (i - 10 * r), - ]); - }; - } - function I(n) { - var t = n.fatal, - o = 0; - this.handler = function (n, e) { - if (e === b && 0 !== o) return (o = 0), m(t); - if (e === b && 0 === o) return w; - if (0 === o) - return u(e) ? e : _(e, 129, 254) ? ((o = e), null) : m(t); - var i = o, - r = null; - switch ( - ((o = 0), - (r = - _(e, 64, 126) || _(e, 161, 254) - ? 157 * (i - 129) + (e - (e < 127 ? 64 : 98)) - : r)) - ) { - case 1133: - return [202, 772]; - case 1135: - return [202, 780]; - case 1164: - return [234, 772]; - case 1166: - return [234, 780]; - } - i = null === r ? null : y(r, v('big5')); - return ( - null === i && u(e) && n.prepend(e), null === i ? m(t) : i - ); - }; - } - function U(n) { - n.fatal; - this.handler = function (n, e) { - var i, r; - return e === b - ? w - : a(e) - ? e - : ((i = e), - (r = o = - o || - v('big5').map(function (n, e) { - return e < 5024 ? null : n; - })), - null === - (i = - 9552 === i || - 9566 === i || - 9569 === i || - 9578 === i || - 21313 === i || - 21317 === i - ? r.lastIndexOf(i) - : p(i, r)) || (r = l(i / 157) + 129) < 161 - ? f(e) - : [r, (e = i % 157) + (e < 63 ? 64 : 98)]); - }; - } - function C(n) { - var t = n.fatal, - o = !1, - s = 0; - this.handler = function (n, e) { - var i, r; - return e === b && 0 !== s - ? ((s = 0), m(t)) - : e === b && 0 === s - ? w - : 142 === s && _(e, 161, 223) - ? ((s = 0), 65216 + e) - : 143 === s && _(e, 161, 254) - ? ((o = !0), (s = e), null) - : 0 !== s - ? ((i = s), - (s = 0), - (r = null), - _(i, 161, 254) && - _(e, 161, 254) && - (r = y( - 94 * (i - 161) + (e - 161), - v(o ? 'jis0212' : 'jis0208') - )), - (o = !1), - _(e, 161, 254) || n.prepend(e), - null === r ? m(t) : r) - : u(e) - ? e - : 142 === e || 143 === e || _(e, 161, 254) - ? ((s = e), null) - : m(t); - }; - } - function P(n) { - n.fatal; - this.handler = function (n, e) { - var i; - return e === b - ? w - : a(e) - ? e - : 165 === e - ? 92 - : 8254 === e - ? 126 - : _(e, 65377, 65439) - ? [142, e - 65377 + 161] - : null === (i = p((e = 8722 === e ? 65293 : e), v('jis0208'))) - ? f(e) - : [l(i / 94) + 161, (i % 94) + 161]; - }; - } - function D(n) { - var t = n.fatal, - o = 0, - s = 1, - l = 2, - a = 3, - u = 4, - c = 5, - f = 6, - d = o, - h = o, - g = 0, - p = !1; - this.handler = function (n, e) { - switch (d) { - default: - case o: - return 27 === e - ? ((d = c), null) - : _(e, 0, 127) && 14 !== e && 15 !== e && 27 !== e - ? ((p = !1), e) - : e === b - ? w - : ((p = !1), m(t)); - case s: - return 27 === e - ? ((d = c), null) - : 92 === e - ? ((p = !1), 165) - : 126 === e - ? ((p = !1), 8254) - : _(e, 0, 127) && - 14 !== e && - 15 !== e && - 27 !== e && - 92 !== e && - 126 !== e - ? ((p = !1), e) - : e === b - ? w - : ((p = !1), m(t)); - case l: - return 27 === e - ? ((d = c), null) - : _(e, 33, 95) - ? ((p = !1), 65344 + e) - : e === b - ? w - : ((p = !1), m(t)); - case a: - return 27 === e - ? ((d = c), null) - : _(e, 33, 126) - ? ((p = !1), (g = e), (d = u), null) - : e === b - ? w - : ((p = !1), m(t)); - case u: - if (27 === e) d = c; - else { - if (_(e, 33, 126)) - return ( - (d = a), - null === (i = y(94 * (g - 33) + e - 33, v('jis0208'))) - ? m(t) - : i - ); - e === b ? ((d = a), n.prepend(e)) : (d = a); - } - return m(t); - case c: - return 36 === e || 40 === e - ? ((g = e), (d = f), null) - : (n.prepend(e), (p = !1), (d = h), m(t)); - case f: - var i = g, - r = ((g = 0), null); - return (40 === i && 66 === e && (r = o), - 40 === i && 74 === e && (r = s), - 40 === i && 73 === e && (r = l), - null !== (r = 36 !== i || (64 !== e && 66 !== e) ? r : a)) - ? ((d = r), (r = p), (p = !0), r ? m(t) : null) - : (n.prepend([i, e]), (p = !1), (d = h), m(t)); - } - }; - } - function F(n) { - n.fatal; - var r = 0, - t = 1, - o = 2, - s = r; - this.handler = function (n, e) { - if (e === b && s !== r) - return n.prepend(e), (s = r), [27, 40, 66]; - if (e === b && s === r) return w; - if ( - !((s !== r && s !== t) || (14 !== e && 15 !== e && 27 !== e)) - ) - return f(65533); - if (s === r && a(e)) return e; - if ( - s === t && - ((a(e) && 92 !== e && 126 !== e) || 165 == e || 8254 == e) - ) { - if (a(e)) return e; - if (165 === e) return 92; - if (8254 === e) return 126; - } - var i; - return a(e) && s !== r - ? (n.prepend(e), (s = r), [27, 40, 66]) - : (165 !== e && 8254 !== e) || s === t - ? null === (i = p((e = 8722 === e ? 65293 : e), v('jis0208'))) - ? f(e) - : s !== o - ? (n.prepend(e), (s = o), [27, 36, 66]) - : [l(i / 94) + 33, (i % 94) + 33] - : (n.prepend(e), (s = t), [27, 40, 74]); - }; - } - function J(n) { - var t = n.fatal, - o = 0; - this.handler = function (n, e) { - var i, r; - return e === b && 0 !== o - ? ((o = 0), m(t)) - : e === b && 0 === o - ? w - : 0 !== o - ? ((r = o), - (i = null), - (o = 0), - (_(e, 64, 126) || _(e, 128, 252)) && - (i = - 188 * (r - (r < 160 ? 129 : 193)) + - e - - (e < 127 ? 64 : 65)), - _(i, 8836, 10715) - ? 48508 + i - : (null === - (r = null === i ? null : y(i, v('jis0208'))) && - u(e) && - n.prepend(e), - null === r ? m(t) : r)) - : u(e) || 128 === e - ? e - : _(e, 161, 223) - ? 65216 + e - : _(e, 129, 159) || _(e, 224, 252) - ? ((o = e), null) - : m(t); - }; - } - function K(n) { - n.fatal; - this.handler = function (n, e) { - var i; - return e === b - ? w - : a(e) || 128 === e - ? e - : 165 === e - ? 92 - : 8254 === e - ? 126 - : _(e, 65377, 65439) - ? e - 65377 + 161 - : ((i = e = 8722 === e ? 65293 : e), - null === - (i = (t = - t || - v('jis0208').map(function (n, e) { - return _(e, 8272, 8835) ? null : n; - })).indexOf(i)) - ? f(e) - : [ - (e = l(i / 188)) + (e < 31 ? 129 : 193), - (e = i % 188) + (e < 63 ? 64 : 65), - ]); - }; - } - function R(n) { - var t = n.fatal, - o = 0; - this.handler = function (n, e) { - var i, r; - return e === b && 0 !== o - ? ((o = 0), m(t)) - : e === b && 0 === o - ? w - : 0 !== o - ? ((r = o), - (o = 0), - (r = - (i = null) === - (i = _(e, 65, 254) ? 190 * (r - 129) + (e - 65) : i) - ? null - : y(i, v('euc-kr'))), - null === i && u(e) && n.prepend(e), - null === r ? m(t) : r) - : u(e) - ? e - : _(e, 129, 254) - ? ((o = e), null) - : m(t); - }; - } - function G(n) { - n.fatal; - this.handler = function (n, e) { - var i; - return e === b - ? w - : a(e) - ? e - : null === (i = p(e, v('euc-kr'))) - ? f(e) - : [l(i / 190) + 129, (i % 190) + 65]; - }; - } - function A(n, e) { - var i = n >> 8, - n = 255 & n; - return e ? [i, n] : [n, i]; - } - function L(r, n) { - var t = n.fatal, - o = null, - s = null; - this.handler = function (n, e) { - var i; - return e !== b || (null === o && null === s) - ? e === b && null === o && null === s - ? w - : null === o - ? ((o = e), null) - : ((e = r ? (o << 8) + e : (e << 8) + o), - (o = null) !== s - ? ((i = s), - (s = null), - _(e, 56320, 57343) - ? 65536 + 1024 * (i - 55296) + (e - 56320) - : (n.prepend(A(e, r)), m(t))) - : _(e, 55296, 56319) - ? ((s = e), null) - : _(e, 56320, 57343) - ? m(t) - : e) - : m(t); - }; - } - function M(r, n) { - n.fatal; - this.handler = function (n, e) { - var i; - return e === b - ? w - : _(e, 0, 65535) - ? A(e, r) - : ((i = A(55296 + ((e - 65536) >> 10), r)), - (e = A(56320 + ((e - 65536) & 1023), r)), - i.concat(e)); - }; - } - function N(n) { - n.fatal; - this.handler = function (n, e) { - return e === b ? w : u(e) ? e : 63360 + e - 128; - }; - } - function q(n) { - n.fatal; - this.handler = function (n, e) { - return e === b - ? w - : a(e) - ? e - : _(e, 63360, 63487) - ? e - 63360 + 128 - : f(e); - }; - } - Object.defineProperty && - (Object.defineProperty(O.prototype, 'encoding', { - get: function () { - return this._encoding.name.toLowerCase(); - }, - }), - Object.defineProperty(O.prototype, 'fatal', { - get: function () { - return 'fatal' === this._error_mode; - }, - }), - Object.defineProperty(O.prototype, 'ignoreBOM', { - get: function () { - return this._ignoreBOM; - }, - })), - (O.prototype.decode = function (n, e) { - n = - 'object' == typeof n && n instanceof ArrayBuffer - ? new Uint8Array(n) - : 'object' == typeof n && - 'buffer' in n && - n.buffer instanceof ArrayBuffer - ? new Uint8Array(n.buffer, n.byteOffset, n.byteLength) - : new Uint8Array(0); - (e = s(e)), - this._do_not_flush || - ((this._decoder = g[this._encoding.name]({ - fatal: 'fatal' === this._error_mode, - })), - (this._BOMseen = !1)), - (this._do_not_flush = Boolean(e.stream)); - for (var i, r = new c(n), t = []; ; ) { - var o = r.read(); - if (o === b) break; - if ((i = this._decoder.handler(r, o)) === w) break; - null !== i && - (Array.isArray(i) ? t.push.apply(t, i) : t.push(i)); - } - if (!this._do_not_flush) { - for ( - ; - (i = this._decoder.handler(r, r.read())) !== w && - (null !== i && - (Array.isArray(i) ? t.push.apply(t, i) : t.push(i)), - !r.endOfStream()); - - ); - this._decoder = null; - } - return function (n) { - (e = ['UTF-8', 'UTF-16LE', 'UTF-16BE']), - (i = this._encoding.name), - -1 === e.indexOf(i) || - this._ignoreBOM || - this._BOMseen || - (0 < n.length && 65279 === n[0] - ? ((this._BOMseen = !0), n.shift()) - : 0 < n.length && (this._BOMseen = !0)); - for (var e, i, r = n, t = '', o = 0; o < r.length; ++o) { - var s = r[o]; - s <= 65535 - ? (t += String.fromCharCode(s)) - : ((s -= 65536), - (t += String.fromCharCode( - 55296 + (s >> 10), - 56320 + (1023 & s) - ))); - } - return t; - }.call(this, t); - }), - Object.defineProperty && - Object.defineProperty(k.prototype, 'encoding', { - get: function () { - return this._encoding.name.toLowerCase(); - }, - }), - (k.prototype.encode = function (n, e) { - (n = void 0 === n ? '' : String(n)), - (e = s(e)), - this._do_not_flush || - (this._encoder = h[this._encoding.name]({ - fatal: 'fatal' === this._fatal, - })), - (this._do_not_flush = Boolean(e.stream)); - for ( - var i, - r = new c( - (function (n) { - for ( - var e = String(n), i = e.length, r = 0, t = []; - r < i; - - ) { - var o, - s = e.charCodeAt(r); - s < 55296 || 57343 < s - ? t.push(s) - : 56320 <= s && s <= 57343 - ? t.push(65533) - : 55296 <= s && - s <= 56319 && - (r !== i - 1 && - 56320 <= (o = e.charCodeAt(r + 1)) && - o <= 57343 - ? (t.push( - 65536 + ((1023 & s) << 10) + (1023 & o) - ), - (r += 1)) - : t.push(65533)), - (r += 1); - } - return t; - })(n) - ), - t = []; - ; - - ) { - var o = r.read(); - if (o === b) break; - if ((i = this._encoder.handler(r, o)) === w) break; - Array.isArray(i) ? t.push.apply(t, i) : t.push(i); - } - if (!this._do_not_flush) { - for (;;) { - if ((i = this._encoder.handler(r, r.read())) === w) break; - Array.isArray(i) ? t.push.apply(t, i) : t.push(i); - } - this._encoder = null; - } - return new Uint8Array(t); - }), - (h['UTF-8'] = function (n) { - return new E(n); - }), - (g['UTF-8'] = function (n) { - return new e(n); - }), - 'encoding-indexes' in i && - n.forEach(function (n) { - 'Legacy single-byte encodings' === n.heading && - n.encodings.forEach(function (n) { - var n = n.name, - e = v(n.toLowerCase()); - (g[n] = function (n) { - return new j(e, n); - }), - (h[n] = function (n) { - return new B(e, n); - }); - }); - }), - (g.GBK = function (n) { - return new S(n); - }), - (h.GBK = function (n) { - return new T(n, !0); - }), - (h.gb18030 = function (n) { - return new T(n); - }), - (g.gb18030 = function (n) { - return new S(n); - }), - (h.Big5 = function (n) { - return new U(n); - }), - (g.Big5 = function (n) { - return new I(n); - }), - (h['EUC-JP'] = function (n) { - return new P(n); - }), - (g['EUC-JP'] = function (n) { - return new C(n); - }), - (h['ISO-2022-JP'] = function (n) { - return new F(n); - }), - (g['ISO-2022-JP'] = function (n) { - return new D(n); - }), - (h.Shift_JIS = function (n) { - return new K(n); - }), - (g.Shift_JIS = function (n) { - return new J(n); - }), - (h['EUC-KR'] = function (n) { - return new G(n); - }), - (g['EUC-KR'] = function (n) { - return new R(n); - }), - (h['UTF-16BE'] = function (n) { - return new M(!0, n); - }), - (g['UTF-16BE'] = function (n) { - return new L(!0, n); - }), - (h['UTF-16LE'] = function (n) { - return new M(!1, n); - }), - (g['UTF-16LE'] = function (n) { - return new L(!1, n); - }), - (h['x-user-defined'] = function (n) { - return new q(n); - }), - (g['x-user-defined'] = function (n) { - return new N(n); - }), - i.TextEncoder || (i.TextEncoder = k), - i.TextDecoder || (i.TextDecoder = O), - 'undefined' != typeof module && - module.exports && - (module.exports = { - TextEncoder: i.TextEncoder, - TextDecoder: i.TextDecoder, - EncodingIndexes: i['encoding-indexes'], - }); - })(this || {}); - // @protobuf-ts/runtime - var UnknownFieldHandler, - WireType, - ScalarType, - LongType, - RepeatType, - __defProp = Object.defineProperty, - __defProps = Object.defineProperties, - __getOwnPropDescs = Object.getOwnPropertyDescriptors, - __getOwnPropSymbols = Object.getOwnPropertySymbols, - __hasOwnProp = Object.prototype.hasOwnProperty, - __propIsEnum = Object.prototype.propertyIsEnumerable, - __defNormalProp = (e, r, t) => - r in e - ? __defProp(e, r, { - enumerable: !0, - configurable: !0, - writable: !0, - value: t, - }) - : (e[r] = t), - __spreadValues = (e, r) => { - for (var t in (r = r || {})) - __hasOwnProp.call(r, t) && __defNormalProp(e, t, r[t]); - if (__getOwnPropSymbols) - for (var t of __getOwnPropSymbols(r)) - __propIsEnum.call(r, t) && __defNormalProp(e, t, r[t]); - return e; - }, - __spreadProps = (e, r) => __defProps(e, __getOwnPropDescs(r)); - function varint64read() { - let r = 0, - t = 0; - for (let e = 0; e < 28; e += 7) { - var a = this.buf[this.pos++]; - if (((r |= (127 & a) << e), 0 == (128 & a))) - return this.assertBounds(), [r, t]; - } - var e = this.buf[this.pos++]; - if (((r |= (15 & e) << 28), (t = (112 & e) >> 4), 0 == (128 & e))) - return this.assertBounds(), [r, t]; - for (let e = 3; e <= 31; e += 7) { - var n = this.buf[this.pos++]; - if (((t |= (127 & n) << e), 0 == (128 & n))) - return this.assertBounds(), [r, t]; - } - throw new Error('invalid varint'); - } - function varint64write(r, t, a) { - for (let e = 0; e < 28; e += 7) { - var n = r >>> e, - s = !(n >>> 7 == 0 && 0 == t); - if ((a.push(255 & (s ? 128 | n : n)), !s)) return; - } - var e = ((r >>> 28) & 15) | ((7 & t) << 4), - i = !(t >> 3 == 0); - if ((a.push(255 & (i ? 128 | e : e)), i)) { - for (let e = 3; e < 31; e += 7) { - var o = t >>> e, - l = !(o >>> 7 == 0); - if ((a.push(255 & (l ? 128 | o : o)), !l)) return; - } - a.push((t >>> 31) & 1); - } - } - const TWO_PWR_32_DBL$1 = 4294967296; - function int64fromString(t) { - var e = '-' == t[0]; - e && (t = t.slice(1)); - let a = 0, - n = 0; - function r(e, r) { - e = Number(t.slice(e, r)); - (n *= 1e6), - (a = 1e6 * a + e) >= TWO_PWR_32_DBL$1 && - ((n += (a / TWO_PWR_32_DBL$1) | 0), (a %= TWO_PWR_32_DBL$1)); - } - return r(-24, -18), r(-18, -12), r(-12, -6), r(-6), [e, a, n]; - } - function int64toString(e, r) { - if (r <= 2097151) return '' + (TWO_PWR_32_DBL$1 * r + e); - var t = (((e >>> 24) | (r << 8)) >>> 0) & 16777215, - r = (r >> 16) & 65535; - let a = (16777215 & e) + 6777216 * t + 6710656 * r, - n = t + 8147497 * r, - s = 2 * r; - e = 1e7; - function i(e, r) { - e = e ? String(e) : ''; - return r ? '0000000'.slice(e.length) + e : e; - } - return ( - a >= e && ((n += Math.floor(a / e)), (a %= e)), - n >= e && ((s += Math.floor(n / e)), (n %= e)), - i(s, 0) + i(n, s) + i(a, 1) - ); - } - function varint32write(r, t) { - if (0 <= r) { - for (; 127 < r; ) t.push((127 & r) | 128), (r >>>= 7); - t.push(r); - } else { - for (let e = 0; e < 9; e++) t.push((127 & r) | 128), (r >>= 7); - t.push(1); - } - } - function varint32read() { - let r = this.buf[this.pos++]; - var e = 127 & r; - if (0 == (128 & r)) return this.assertBounds(), e; - if ( - ((e |= (127 & (r = this.buf[this.pos++])) << 7), 0 == (128 & r)) - ) - return this.assertBounds(), e; - if ( - ((e |= (127 & (r = this.buf[this.pos++])) << 14), 0 == (128 & r)) - ) - return this.assertBounds(), e; - if ( - ((e |= (127 & (r = this.buf[this.pos++])) << 21), 0 == (128 & r)) - ) - return this.assertBounds(), e; - e |= (15 & (r = this.buf[this.pos++])) << 28; - for (let e = 5; 0 != (128 & r) && e < 10; e++) - r = this.buf[this.pos++]; - if (0 != (128 & r)) throw new Error('invalid varint'); - return this.assertBounds(), e >>> 0; - } - function detectBi() { - var e = new DataView(new ArrayBuffer(8)); - return void 0 !== globalThis.BigInt && - 'function' == typeof e.getBigInt64 && - 'function' == typeof e.getBigUint64 && - 'function' == typeof e.setBigInt64 && - 'function' == typeof e.setBigUint64 - ? { - MIN: BigInt('-9223372036854775808'), - MAX: BigInt('9223372036854775807'), - UMIN: BigInt('0'), - UMAX: BigInt('18446744073709551615'), - C: BigInt, - V: e, - } - : void 0; - } - const BI = detectBi(); - function assertBi(e) { - if (!e) - throw new Error( - 'BigInt unavailable, see https://github.com/timostamm/protobuf-ts/blob/v1.0.8/MANUAL.md#bigint-support' - ); - } - const RE_DECIMAL_STR = /^-?[0-9]+$/, - TWO_PWR_32_DBL = 4294967296; - class SharedPbLong { - constructor(e, r) { - (this.lo = 0 | e), (this.hi = 0 | r); - } - isZero() { - return 0 == this.lo && 0 == this.hi; - } - toNumber() { - var e = this.hi * TWO_PWR_32_DBL + (this.lo >>> 0); - if (Number.isSafeInteger(e)) return e; - throw new Error('cannot convert to safe number'); - } - } - const _PbULong = class extends SharedPbLong { - static from(e) { - if (BI) - switch (typeof e) { - case 'string': - if ('0' == e) return this.ZERO; - if ('' == e) throw new Error('string is no integer'); - e = BI.C(e); - case 'number': - if (0 === e) return this.ZERO; - e = BI.C(e); - case 'bigint': - if (!e) return this.ZERO; - if (e < BI.UMIN) throw new Error('signed value for ulong'); - if (e > BI.UMAX) throw new Error('ulong too large'); - return ( - BI.V.setBigUint64(0, e, !0), - new _PbULong(BI.V.getInt32(0, !0), BI.V.getInt32(4, !0)) - ); - } - else - switch (typeof e) { - case 'string': - if ('0' == e) return this.ZERO; - if (((e = e.trim()), !RE_DECIMAL_STR.test(e))) - throw new Error('string is no integer'); - var [r, t, a] = int64fromString(e); - if (r) throw new Error('signed value'); - return new _PbULong(t, a); - case 'number': - if (0 == e) return this.ZERO; - if (!Number.isSafeInteger(e)) - throw new Error('number is no integer'); - if (e < 0) throw new Error('signed value for ulong'); - return new _PbULong(e, e / TWO_PWR_32_DBL); - } - throw new Error('unknown value ' + typeof e); - } - toString() { - return BI - ? this.toBigInt().toString() - : int64toString(this.lo, this.hi); - } - toBigInt() { - return ( - assertBi(BI), - BI.V.setInt32(0, this.lo, !0), - BI.V.setInt32(4, this.hi, !0), - BI.V.getBigUint64(0, !0) - ); - } - }; - let PbULong = _PbULong; - PbULong.ZERO = new _PbULong(0, 0); - const _PbLong = class extends SharedPbLong { - static from(e) { - if (BI) - switch (typeof e) { - case 'string': - if ('0' == e) return this.ZERO; - if ('' == e) throw new Error('string is no integer'); - e = BI.C(e); - case 'number': - if (0 === e) return this.ZERO; - e = BI.C(e); - case 'bigint': - if (!e) return this.ZERO; - if (e < BI.MIN) throw new Error('ulong too small'); - if (e > BI.MAX) throw new Error('ulong too large'); - return ( - BI.V.setBigInt64(0, e, !0), - new _PbLong(BI.V.getInt32(0, !0), BI.V.getInt32(4, !0)) - ); - } - else - switch (typeof e) { - case 'string': - if ('0' == e) return this.ZERO; - var r, t, a; - if (((e = e.trim()), RE_DECIMAL_STR.test(e))) - return ( - ([r, a, t] = int64fromString(e)), - (a = new _PbLong(a, t)), - r ? a.negate() : a - ); - throw new Error('string is no integer'); - case 'number': - if (0 == e) return this.ZERO; - if (Number.isSafeInteger(e)) - return 0 < e - ? new _PbLong(e, e / TWO_PWR_32_DBL) - : new _PbLong(-e, -e / TWO_PWR_32_DBL).negate(); - throw new Error('number is no integer'); - } - throw new Error('unknown value ' + typeof e); - } - isNegative() { - return 0 != (2147483648 & this.hi); - } - negate() { - let e = ~this.hi, - r = this.lo; - return r ? (r = 1 + ~r) : (e += 1), new _PbLong(r, e); - } - toString() { - var e; - return BI - ? this.toBigInt().toString() - : this.isNegative() - ? '-' + int64toString((e = this.negate()).lo, e.hi) - : int64toString(this.lo, this.hi); - } - toBigInt() { - return ( - assertBi(BI), - BI.V.setInt32(0, this.lo, !0), - BI.V.setInt32(4, this.hi, !0), - BI.V.getBigInt64(0, !0) - ); - } - }; - let PbLong = _PbLong; - PbLong.ZERO = new _PbLong(0, 0); - class BinaryReader { - constructor(e, r) { - (this.varint64 = varint64read), - (this.uint32 = varint32read), - (this.buf = e), - (this.len = e.length), - (this.pos = 0), - (this.view = new DataView( - e.buffer, - e.byteOffset, - e.byteLength - )), - (this.textDecoder = - null != r ? r : new TextDecoder('utf-8', { fatal: !0 })); - } - tag() { - var e = this.uint32(), - r = e >>> 3, - e = 7 & e; - if (r <= 0 || e < 0 || 5 < e) - throw new Error( - 'illegal tag: field no ' + r + ' wire type ' + e - ); - return [r, e]; - } - skip(e) { - var r, - t = this.pos; - switch (e) { - case WireType.Varint: - for (; 128 & this.buf[this.pos++]; ); - break; - case WireType.Bit64: - this.pos += 4; - case WireType.Bit32: - this.pos += 4; - break; - case WireType.LengthDelimited: - var a = this.uint32(); - this.pos += a; - break; - case WireType.StartGroup: - for (; (r = this.tag()[1]) !== WireType.EndGroup; ) - this.skip(r); - break; - default: - throw new Error('cant skip wire type ' + e); - } - return this.assertBounds(), this.buf.subarray(t, this.pos); - } - assertBounds() { - if (this.pos > this.len) throw new RangeError('premature EOF'); - } - int32() { - return 0 | this.uint32(); - } - sint32() { - var e = this.uint32(); - return (e >>> 1) ^ -(1 & e); - } - int64() { - return new PbLong(...this.varint64()); - } - uint64() { - return new PbULong(...this.varint64()); - } - sint64() { - var [e, r] = this.varint64(), - t = -(1 & e), - e = ((e >>> 1) | ((1 & r) << 31)) ^ t, - r = (r >>> 1) ^ t; - return new PbLong(e, r); - } - bool() { - var [e, r] = this.varint64(); - return 0 !== e || 0 !== r; - } - fixed32() { - return this.view.getUint32((this.pos += 4) - 4, !0); - } - sfixed32() { - return this.view.getInt32((this.pos += 4) - 4, !0); - } - fixed64() { - return new PbULong(this.sfixed32(), this.sfixed32()); - } - sfixed64() { - return new PbLong(this.sfixed32(), this.sfixed32()); - } - float() { - return this.view.getFloat32((this.pos += 4) - 4, !0); - } - double() { - return this.view.getFloat64((this.pos += 8) - 8, !0); - } - bytes() { - var e = this.uint32(), - r = this.pos; - return ( - (this.pos += e), - this.assertBounds(), - this.buf.subarray(r, r + e) - ); - } - string() { - return this.textDecoder.decode(this.bytes()); - } - } - function assert(e, r) { - if (!e) throw new Error(r); - } - const FLOAT32_MAX = 34028234663852886e22, - FLOAT32_MIN = -34028234663852886e22, - UINT32_MAX = 4294967295, - INT32_MAX = 2147483647, - INT32_MIN = -2147483648; - function assertInt32(e) { - if ('number' != typeof e) - throw new Error('invalid int 32: ' + typeof e); - if (!Number.isInteger(e) || e > INT32_MAX || e < INT32_MIN) - throw new Error('invalid int 32: ' + e); - } - function assertUInt32(e) { - if ('number' != typeof e) - throw new Error('invalid uint 32: ' + typeof e); - if (!Number.isInteger(e) || e > UINT32_MAX || e < 0) - throw new Error('invalid uint 32: ' + e); - } - function assertFloat32(e) { - if ('number' != typeof e) - throw new Error('invalid float 32: ' + typeof e); - if (Number.isFinite(e) && (e > FLOAT32_MAX || e < FLOAT32_MIN)) - throw new Error('invalid float 32: ' + e); - } - class BinaryWriter { - constructor(e) { - (this.stack = []), - (this.textEncoder = null != e ? e : new TextEncoder()), - (this.chunks = []), - (this.buf = []); - } - finish() { - this.chunks.push(new Uint8Array(this.buf)); - let r = 0; - for (let e = 0; e < this.chunks.length; e++) - r += this.chunks[e].length; - var t = new Uint8Array(r); - let a = 0; - for (let e = 0; e < this.chunks.length; e++) - t.set(this.chunks[e], a), (a += this.chunks[e].length); - return (this.chunks = []), t; - } - fork() { - return ( - this.stack.push({ chunks: this.chunks, buf: this.buf }), - (this.chunks = []), - (this.buf = []), - this - ); - } - join() { - var e = this.finish(), - r = this.stack.pop(); - if (r) - return ( - (this.chunks = r.chunks), - (this.buf = r.buf), - this.uint32(e.byteLength), - this.raw(e) - ); - throw new Error('invalid state, fork stack empty'); - } - tag(e, r) { - return this.uint32(((e << 3) | r) >>> 0); - } - raw(e) { - return ( - this.buf.length && - (this.chunks.push(new Uint8Array(this.buf)), (this.buf = [])), - this.chunks.push(e), - this - ); - } - uint32(e) { - for (assertUInt32(e); 127 < e; ) - this.buf.push((127 & e) | 128), (e >>>= 7); - return this.buf.push(e), this; - } - int32(e) { - return assertInt32(e), varint32write(e, this.buf), this; - } - bool(e) { - return this.buf.push(e ? 1 : 0), this; - } - bytes(e) { - return this.uint32(e.byteLength), this.raw(e); - } - string(e) { - e = this.textEncoder.encode(e); - return this.uint32(e.byteLength), this.raw(e); - } - float(e) { - assertFloat32(e); - var r = new Uint8Array(4); - return new DataView(r.buffer).setFloat32(0, e, !0), this.raw(r); - } - double(e) { - var r = new Uint8Array(8); - return new DataView(r.buffer).setFloat64(0, e, !0), this.raw(r); - } - fixed32(e) { - assertUInt32(e); - var r = new Uint8Array(4); - return new DataView(r.buffer).setUint32(0, e, !0), this.raw(r); - } - sfixed32(e) { - assertInt32(e); - var r = new Uint8Array(4); - return new DataView(r.buffer).setInt32(0, e, !0), this.raw(r); - } - sint32(e) { - return ( - assertInt32(e), - varint32write((e = ((e << 1) ^ (e >> 31)) >>> 0), this.buf), - this - ); - } - sfixed64(e) { - var r = new Uint8Array(8), - t = new DataView(r.buffer), - e = PbLong.from(e); - return ( - t.setInt32(0, e.lo, !0), t.setInt32(4, e.hi, !0), this.raw(r) - ); - } - fixed64(e) { - var r = new Uint8Array(8), - t = new DataView(r.buffer), - e = PbULong.from(e); - return ( - t.setInt32(0, e.lo, !0), t.setInt32(4, e.hi, !0), this.raw(r) - ); - } - int64(e) { - e = PbLong.from(e); - return varint64write(e.lo, e.hi, this.buf), this; - } - sint64(e) { - var e = PbLong.from(e), - r = e.hi >> 31; - return ( - varint64write( - (e.lo << 1) ^ r, - ((e.hi << 1) | (e.lo >>> 31)) ^ r, - this.buf - ), - this - ); - } - uint64(e) { - e = PbULong.from(e); - return varint64write(e.lo, e.hi, this.buf), this; - } - } - function binaryWriteOptions(e) { - return e - ? __spreadValues(__spreadValues({}, defaultsWrite$1), e) - : defaultsWrite$1; - } - function binaryReadOptions(e) { - return e - ? __spreadValues(__spreadValues({}, defaultsRead$1), e) - : defaultsRead$1; - } - !(function (i) { - (i.symbol = Symbol.for('protobuf-ts/unknown')), - (i.onRead = (e, r, t, a, n) => { - (s(r) ? r[i.symbol] : (r[i.symbol] = [])).push({ - no: t, - wireType: a, - data: n, - }); - }), - (i.onWrite = (e, r, t) => { - for (var { no: a, wireType: n, data: s } of i.list(r)) - t.tag(a, n).raw(s); - }), - (i.list = (e, r) => - s(e) - ? ((e = e[i.symbol]), r ? e.filter((e) => e.no == r) : e) - : []), - (i.last = (e, r) => i.list(e, r).slice(-1)[0]); - const s = (e) => e && Array.isArray(e[i.symbol]); - })((UnknownFieldHandler = UnknownFieldHandler || {})); - const defaultsRead$1 = { - readUnknownField: !0, - readerFactory: (e) => new BinaryReader(e), - }, - defaultsWrite$1 = { - writeUnknownFields: !0, - writerFactory: () => new BinaryWriter(), - }, - MESSAGE_TYPE = - (!(function (e) { - (e[(e.Varint = 0)] = 'Varint'), - (e[(e.Bit64 = 1)] = 'Bit64'), - (e[(e.LengthDelimited = 2)] = 'LengthDelimited'), - (e[(e.StartGroup = 3)] = 'StartGroup'), - (e[(e.EndGroup = 4)] = 'EndGroup'), - (e[(e.Bit32 = 5)] = 'Bit32'); - })((WireType = WireType || {})), - Symbol.for('protobuf-ts/message-type')); - function lowerCamelCase(r) { - let t = !1; - var a = []; - for (let e = 0; e < r.length; e++) { - var n = r.charAt(e); - '_' == n - ? (t = !0) - : /\d/.test(n) - ? (a.push(n), (t = !0)) - : t - ? (a.push(n.toUpperCase()), (t = !1)) - : 0 == e - ? a.push(n.toLowerCase()) - : a.push(n); - } - return a.join(''); - } - function normalizeFieldInfo(e) { - var r; - return ( - (e.localName = - null != (r = e.localName) ? r : lowerCamelCase(e.name)), - (e.jsonName = - null != (r = e.jsonName) ? r : lowerCamelCase(e.name)), - (e.repeat = null != (r = e.repeat) ? r : 0), - (e.opt = - null != (r = e.opt) - ? r - : !e.repeat && !e.oneof && 'message' == e.kind), - e - ); - } - function isOneofGroup(e) { - if ( - 'object' != typeof e || - null === e || - !e.hasOwnProperty('oneofKind') - ) - return !1; - switch (typeof e.oneofKind) { - case 'string': - return void 0 === e[e.oneofKind] - ? !1 - : 2 == Object.keys(e).length; - case 'undefined': - return 1 == Object.keys(e).length; - default: - return !1; - } - } - !(function (e) { - (e[(e.DOUBLE = 1)] = 'DOUBLE'), - (e[(e.FLOAT = 2)] = 'FLOAT'), - (e[(e.INT64 = 3)] = 'INT64'), - (e[(e.UINT64 = 4)] = 'UINT64'), - (e[(e.INT32 = 5)] = 'INT32'), - (e[(e.FIXED64 = 6)] = 'FIXED64'), - (e[(e.FIXED32 = 7)] = 'FIXED32'), - (e[(e.BOOL = 8)] = 'BOOL'), - (e[(e.STRING = 9)] = 'STRING'), - (e[(e.BYTES = 12)] = 'BYTES'), - (e[(e.UINT32 = 13)] = 'UINT32'), - (e[(e.SFIXED32 = 15)] = 'SFIXED32'), - (e[(e.SFIXED64 = 16)] = 'SFIXED64'), - (e[(e.SINT32 = 17)] = 'SINT32'), - (e[(e.SINT64 = 18)] = 'SINT64'); - })((ScalarType = ScalarType || {})), - (function (e) { - (e[(e.BIGINT = 0)] = 'BIGINT'), - (e[(e.STRING = 1)] = 'STRING'), - (e[(e.NUMBER = 2)] = 'NUMBER'); - })((LongType = LongType || {})), - (function (e) { - (e[(e.NO = 0)] = 'NO'), - (e[(e.PACKED = 1)] = 'PACKED'), - (e[(e.UNPACKED = 2)] = 'UNPACKED'); - })((RepeatType = RepeatType || {})); - class ReflectionTypeCheck { - constructor(e) { - this.fields = null != (e = e.fields) ? e : []; - } - prepare() { - if (!this.data) { - var e, - r = [], - t = [], - a = []; - for (e of this.fields) - if (e.oneof) - a.includes(e.oneof) || - (a.push(e.oneof), r.push(e.oneof), t.push(e.oneof)); - else - switch ((t.push(e.localName), e.kind)) { - case 'scalar': - case 'enum': - (e.opt && !e.repeat) || r.push(e.localName); - break; - case 'message': - e.repeat && r.push(e.localName); - break; - case 'map': - r.push(e.localName); - } - this.data = { req: r, known: t, oneofs: Object.values(a) }; - } - } - is(e, a, n = !1) { - if (!(a < 0)) { - if (null == e || 'object' != typeof e) return !1; - this.prepare(); - let r = Object.keys(e), - t = this.data; - if ( - r.length < t.req.length || - t.req.some((e) => !r.includes(e)) - ) - return !1; - if (!n && r.some((e) => !t.known.includes(e))) return !1; - if (!(a < 1)) { - for (const i of t.oneofs) { - const o = e[i]; - if (!isOneofGroup(o)) return !1; - if (void 0 !== o.oneofKind) { - var s = this.fields.find( - (e) => e.localName === o.oneofKind - ); - if (!s) return !1; - if (!this.field(o[o.oneofKind], s, n, a)) return !1; - } - } - for (const l of this.fields) - if ( - void 0 === l.oneof && - !this.field(e[l.localName], l, n, a) - ) - return !1; - } - } - return !0; - } - field(e, r, t, a) { - var n = r.repeat; - switch (r.kind) { - case 'scalar': - return void 0 === e - ? r.opt - : n - ? this.scalars(e, r.T, a, r.L) - : this.scalar(e, r.T, r.L); - case 'enum': - return void 0 === e - ? r.opt - : n - ? this.scalars(e, ScalarType.INT32, a) - : this.scalar(e, ScalarType.INT32); - case 'message': - return void 0 === e - ? !0 - : n - ? this.messages(e, r.T(), t, a) - : this.message(e, r.T(), t, a); - case 'map': - if ('object' != typeof e || null === e) return !1; - if (a < 2) return !0; - if (!this.mapKeys(e, r.K, a)) return !1; - switch (r.V.kind) { - case 'scalar': - return this.scalars(Object.values(e), r.V.T, a, r.V.L); - case 'enum': - return this.scalars( - Object.values(e), - ScalarType.INT32, - a - ); - case 'message': - return this.messages(Object.values(e), r.V.T(), t, a); - } - } - return !0; - } - message(e, r, t, a) { - return t ? r.isAssignable(e, a) : r.is(e, a); - } - messages(r, t, e, a) { - if (!Array.isArray(r)) return !1; - if (!(a < 2)) - if (e) { - for (let e = 0; e < r.length && e < a; e++) - if (!t.isAssignable(r[e], a - 1)) return !1; - } else - for (let e = 0; e < r.length && e < a; e++) - if (!t.is(r[e], a - 1)) return !1; - return !0; - } - scalar(e, r, t) { - var a = typeof e; - switch (r) { - case ScalarType.UINT64: - case ScalarType.FIXED64: - case ScalarType.INT64: - case ScalarType.SFIXED64: - case ScalarType.SINT64: - switch (t) { - case LongType.BIGINT: - return 'bigint' == a; - case LongType.NUMBER: - return 'number' == a && !isNaN(e); - default: - return 'string' == a; - } - case ScalarType.BOOL: - return 'boolean' == a; - case ScalarType.STRING: - return 'string' == a; - case ScalarType.BYTES: - return e instanceof Uint8Array; - case ScalarType.DOUBLE: - case ScalarType.FLOAT: - return 'number' == a && !isNaN(e); - default: - return 'number' == a && Number.isInteger(e); - } - } - scalars(r, t, a, n) { - if (!Array.isArray(r)) return !1; - if (!(a < 2) && Array.isArray(r)) - for (let e = 0; e < r.length && e < a; e++) - if (!this.scalar(r[e], t, n)) return !1; - return !0; - } - mapKeys(e, r, t) { - var a = Object.keys(e); - switch (r) { - case ScalarType.INT32: - case ScalarType.FIXED32: - case ScalarType.SFIXED32: - case ScalarType.SINT32: - case ScalarType.UINT32: - return this.scalars( - a.slice(0, t).map((e) => parseInt(e)), - r, - t - ); - case ScalarType.BOOL: - return this.scalars( - a - .slice(0, t) - .map((e) => 'true' == e || ('false' != e && e)), - r, - t - ); - default: - return this.scalars(a, r, t, LongType.STRING); - } - } - } - function typeofJsonValue(e) { - var r = typeof e; - if ('object' == r) { - if (Array.isArray(e)) return 'array'; - if (null === e) return 'null'; - } - return r; - } - function isJsonObject(e) { - return null !== e && 'object' == typeof e && !Array.isArray(e); - } - let encTable = - 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'.split( - '' - ), - decTable = []; - for (let e = 0; e < encTable.length; e++) - decTable[encTable[e].charCodeAt(0)] = e; - function base64decode(r) { - let e = (3 * r.length) / 4, - t = - ('=' == r[r.length - 2] - ? (e -= 2) - : '=' == r[r.length - 1] && --e, - new Uint8Array(e)), - a = 0, - n = 0, - s, - i = 0; - for (let e = 0; e < r.length; e++) { - if (void 0 === (s = decTable[r.charCodeAt(e)])) - switch (r[e]) { - case '=': - n = 0; - case '\n': - case '\r': - case '\t': - case ' ': - continue; - default: - throw Error('invalid base64 string.'); - } - switch (n) { - case 0: - (i = s), (n = 1); - break; - case 1: - (t[a++] = (i << 2) | ((48 & s) >> 4)), (i = s), (n = 2); - break; - case 2: - (t[a++] = ((15 & i) << 4) | ((60 & s) >> 2)), - (i = s), - (n = 3); - break; - case 3: - (t[a++] = ((3 & i) << 6) | s), (n = 0); - } - } - if (1 == n) throw Error('invalid base64 string.'); - return t.subarray(0, a); - } - function base64encode(r) { - let t = '', - a = 0, - n, - s = 0; - for (let e = 0; e < r.length; e++) - switch (((n = r[e]), a)) { - case 0: - (t += encTable[n >> 2]), (s = (3 & n) << 4), (a = 1); - break; - case 1: - (t += encTable[s | (n >> 4)]), (s = (15 & n) << 2), (a = 2); - break; - case 2: - (t = (t += encTable[s | (n >> 6)]) + encTable[63 & n]), - (a = 0); - } - return a && ((t = t + encTable[s] + '='), 1 == a && (t += '=')), t; - } - function reflectionLongConvert(e, r) { - switch (r) { - case LongType.BIGINT: - return e.toBigInt(); - case LongType.NUMBER: - return e.toNumber(); - default: - return e.toString(); - } - } - (decTable['-'.charCodeAt(0)] = encTable.indexOf('+')), - (decTable['_'.charCodeAt(0)] = encTable.indexOf('/')); - class ReflectionJsonReader { - constructor(e) { - this.info = e; - } - prepare() { - var e; - if (void 0 === this.fMap) { - this.fMap = {}; - for (const r of null != (e = this.info.fields) ? e : []) - (this.fMap[r.name] = r), - (this.fMap[r.jsonName] = r), - (this.fMap[r.localName] = r); - } - } - assert(e, r, t) { - if (!e) { - let e = typeofJsonValue(t); - throw ( - (('number' != e && 'boolean' != e) || (e = t.toString()), - new Error( - `Cannot parse JSON ${e} for ${this.info.typeName}#` + r - )) - ); - } - } - read(e, r, t) { - this.prepare(); - var a, - n, - s = []; - for ([a, n] of Object.entries(e)) { - var i = this.fMap[a]; - if (!i) { - if (t.ignoreUnknownFields) continue; - throw new Error( - `Found unknown field while reading ${this.info.typeName} from JSON format. JSON key: ` + - a - ); - } - var o = i.localName; - let e; - if (i.oneof) { - if (s.includes(i.oneof)) - throw new Error( - `Multiple members of the oneof group "${i.oneof}" of ${this.info.typeName} are present in JSON.` - ); - s.push(i.oneof), (e = r[i.oneof] = { oneofKind: o }); - } else e = r; - if ('map' == i.kind) { - if (null !== n) { - this.assert(isJsonObject(n), i.name, n); - var l, - c, - u = e[o]; - for ([l, c] of Object.entries(n)) { - this.assert(null !== c, i.name + ' map value', null); - let e; - switch (i.V.kind) { - case 'message': - e = i.V.T().internalJsonRead(c, t); - break; - case 'enum': - if ( - !1 === - (e = this.enum( - i.V.T(), - c, - i.name, - t.ignoreUnknownFields - )) - ) - continue; - break; - case 'scalar': - e = this.scalar(c, i.V.T, i.V.L, i.name); - } - this.assert(void 0 !== e, i.name + ' map value', c); - let r = l; - i.K == ScalarType.BOOL && - (r = 'true' == r || ('false' != r && r)), - (u[ - (r = this.scalar( - r, - i.K, - LongType.STRING, - i.name - ).toString()) - ] = e); - } - } - } else if (i.repeat) { - if (null !== n) { - this.assert(Array.isArray(n), i.name, n); - var f = e[o]; - for (const p of n) { - this.assert(null !== p, i.name, null); - let e; - switch (i.kind) { - case 'message': - e = i.T().internalJsonRead(p, t); - break; - case 'enum': - if ( - !1 === - (e = this.enum( - i.T(), - p, - i.name, - t.ignoreUnknownFields - )) - ) - continue; - break; - case 'scalar': - e = this.scalar(p, i.T, i.L, i.name); - } - this.assert(void 0 !== e, i.name, n), f.push(e); - } - } - } else - switch (i.kind) { - case 'message': - null === n && 'google.protobuf.Value' != i.T().typeName - ? this.assert( - void 0 === i.oneof, - i.name + ' (oneof member)', - null - ) - : (e[o] = i.T().internalJsonRead(n, t, e[o])); - break; - case 'enum': - var h = this.enum( - i.T(), - n, - i.name, - t.ignoreUnknownFields - ); - !1 !== h && (e[o] = h); - break; - case 'scalar': - e[o] = this.scalar(n, i.T, i.L, i.name); - } - } - } - enum(r, t, a, n) { - if ( - ('google.protobuf.NullValue' == r[0] && - assert( - null === t, - `Unable to parse field ${this.info.typeName}#${a}, enum ${r[0]} only accepts null.` - ), - null === t) - ) - return 0; - switch (typeof t) { - case 'number': - return ( - assert( - Number.isInteger(t), - `Unable to parse field ${this.info.typeName}#${a}, enum can only be integral number, got ${t}.` - ), - t - ); - case 'string': - let e = t; - r[2] && - t.substring(0, r[2].length) === r[2] && - (e = t.substring(r[2].length)); - var s = r[1][e]; - return void 0 === s && n - ? !1 - : (assert( - 'number' == typeof s, - `Unable to parse field ${this.info.typeName}#${a}, enum ${r[0]} has no value for "${t}".` - ), - s); - } - assert( - !1, - `Unable to parse field ${ - this.info.typeName - }#${a}, cannot parse enum value from ${typeof t}".` - ); - } - scalar(r, t, a, e) { - let n; - try { - switch (t) { - case ScalarType.DOUBLE: - case ScalarType.FLOAT: - if (null === r) return 0; - if ('NaN' === r) return Number.NaN; - if ('Infinity' === r) return Number.POSITIVE_INFINITY; - if ('-Infinity' === r) return Number.NEGATIVE_INFINITY; - if ('' === r) n = 'empty string'; - else if ( - 'string' == typeof r && - r.trim().length !== r.length - ) - n = 'extra whitespace'; - else if ('string' == typeof r || 'number' == typeof r) { - var s = Number(r); - if (Number.isNaN(s)) n = 'not a number'; - else { - if (Number.isFinite(s)) - return t == ScalarType.FLOAT && assertFloat32(s), s; - n = 'too large or small'; - } - } - break; - case ScalarType.INT32: - case ScalarType.FIXED32: - case ScalarType.SFIXED32: - case ScalarType.SINT32: - case ScalarType.UINT32: - if (null === r) return 0; - let e; - if ( - ('number' == typeof r - ? (e = r) - : '' === r - ? (n = 'empty string') - : 'string' == typeof r && - (r.trim().length !== r.length - ? (n = 'extra whitespace') - : (e = Number(r))), - void 0 === e) - ) - break; - return ( - (t == ScalarType.UINT32 ? assertUInt32 : assertInt32)(e), - e - ); - case ScalarType.INT64: - case ScalarType.SFIXED64: - case ScalarType.SINT64: - if (null === r) - return reflectionLongConvert(PbLong.ZERO, a); - if ('number' != typeof r && 'string' != typeof r) break; - return reflectionLongConvert(PbLong.from(r), a); - case ScalarType.FIXED64: - case ScalarType.UINT64: - if (null === r) - return reflectionLongConvert(PbULong.ZERO, a); - if ('number' != typeof r && 'string' != typeof r) break; - return reflectionLongConvert(PbULong.from(r), a); - case ScalarType.BOOL: - if (null === r) return !1; - if ('boolean' != typeof r) break; - return r; - case ScalarType.STRING: - if (null === r) return ''; - if ('string' != typeof r) { - n = 'extra whitespace'; - break; - } - try { - encodeURIComponent(r); - } catch (e) { - 0; - break; - } - return r; - case ScalarType.BYTES: - if (null === r || '' === r) return new Uint8Array(0); - if ('string' != typeof r) break; - return base64decode(r); - } - } catch (e) { - n = e.message; - } - this.assert(!1, e + (n ? ' - ' + n : ''), r); - } - } - class ReflectionJsonWriter { - constructor(e) { - this.fields = null != (e = e.fields) ? e : []; - } - write(e, r) { - var t, - a, - n = {}, - s = e; - for (const i of this.fields) - i.oneof - ? (t = s[i.oneof]).oneofKind === i.localName && - ((a = - 'scalar' == i.kind || 'enum' == i.kind - ? __spreadProps(__spreadValues({}, r), { - emitDefaultValues: !0, - }) - : r), - assert(void 0 !== (t = this.field(i, t[i.localName], a))), - (n[r.useProtoFieldName ? i.name : i.jsonName] = t)) - : void 0 !== (a = this.field(i, s[i.localName], r)) && - (n[r.useProtoFieldName ? i.name : i.jsonName] = a); - return n; - } - field(r, t, a) { - let e = void 0; - if ('map' == r.kind) { - assert('object' == typeof t && null !== t); - var n = {}; - switch (r.V.kind) { - case 'scalar': - for (var [s, i] of Object.entries(t)) { - i = this.scalar(r.V.T, i, r.name, !1, !0); - assert(void 0 !== i), (n[s.toString()] = i); - } - break; - case 'message': - var o, - l, - c = r.V.T(); - for ([o, l] of Object.entries(t)) { - var u = this.message(c, l, r.name, a); - assert(void 0 !== u), (n[o.toString()] = u); - } - break; - case 'enum': - var f, - h, - p = r.V.T(); - for ([f, h] of Object.entries(t)) { - assert(void 0 === h || 'number' == typeof h); - var d = this.enum(p, h, r.name, !1, !0, a.enumAsInteger); - assert(void 0 !== d), (n[f.toString()] = d); - } - } - (a.emitDefaultValues || 0 < Object.keys(n).length) && (e = n); - } else if (r.repeat) { - assert(Array.isArray(t)); - var y = []; - switch (r.kind) { - case 'scalar': - for (let e = 0; e < t.length; e++) { - var T = this.scalar(r.T, t[e], r.name, r.opt, !0); - assert(void 0 !== T), y.push(T); - } - break; - case 'enum': - var g = r.T(); - for (let e = 0; e < t.length; e++) { - assert(void 0 === t[e] || 'number' == typeof t[e]); - var b = this.enum( - g, - t[e], - r.name, - r.opt, - !0, - a.enumAsInteger - ); - assert(void 0 !== b), y.push(b); - } - break; - case 'message': - var m = r.T(); - for (let e = 0; e < t.length; e++) { - var w = this.message(m, t[e], r.name, a); - assert(void 0 !== w), y.push(w); - } - } - (a.emitDefaultValues || 0 < y.length || a.emitDefaultValues) && - (e = y); - } else - switch (r.kind) { - case 'scalar': - e = this.scalar(r.T, t, r.name, r.opt, a.emitDefaultValues); - break; - case 'enum': - e = this.enum( - r.T(), - t, - r.name, - r.opt, - a.emitDefaultValues, - a.enumAsInteger - ); - break; - case 'message': - e = this.message(r.T(), t, r.name, a); - } - return e; - } - enum(e, r, t, a, n, s) { - if ('google.protobuf.NullValue' == e[0]) return null; - if (void 0 === r) assert(a); - else if (0 !== r || n || a) - return ( - assert('number' == typeof r), - assert(Number.isInteger(r)), - s || !e[1].hasOwnProperty(r) - ? r - : e[2] - ? e[2] + e[1][r] - : e[1][r] - ); - } - message(e, r, t, a) { - return void 0 === r - ? a.emitDefaultValues - ? null - : void 0 - : e.internalJsonWrite(r, a); - } - scalar(e, r, t, a, n) { - if (void 0 === r) assert(a); - else { - var s = n || a; - switch (e) { - case ScalarType.INT32: - case ScalarType.SFIXED32: - case ScalarType.SINT32: - return 0 === r ? (s ? 0 : void 0) : (assertInt32(r), r); - case ScalarType.FIXED32: - case ScalarType.UINT32: - return 0 === r ? (s ? 0 : void 0) : (assertUInt32(r), r); - case ScalarType.FLOAT: - assertFloat32(r); - case ScalarType.DOUBLE: - return 0 === r - ? s - ? 0 - : void 0 - : (assert('number' == typeof r), - Number.isNaN(r) - ? 'NaN' - : r === Number.POSITIVE_INFINITY - ? 'Infinity' - : r === Number.NEGATIVE_INFINITY - ? '-Infinity' - : r); - case ScalarType.STRING: - return '' === r - ? s - ? '' - : void 0 - : (assert('string' == typeof r), r); - case ScalarType.BOOL: - return !1 === r - ? !s && void 0 - : (assert('boolean' == typeof r), r); - case ScalarType.UINT64: - case ScalarType.FIXED64: - assert( - 'number' == typeof r || - 'string' == typeof r || - 'bigint' == typeof r - ); - var i = PbULong.from(r); - return i.isZero() && !s ? void 0 : i.toString(); - case ScalarType.INT64: - case ScalarType.SFIXED64: - case ScalarType.SINT64: - assert( - 'number' == typeof r || - 'string' == typeof r || - 'bigint' == typeof r - ); - i = PbLong.from(r); - return i.isZero() && !s ? void 0 : i.toString(); - case ScalarType.BYTES: - return (assert(r instanceof Uint8Array), r.byteLength) - ? base64encode(r) - : s - ? '' - : void 0; - } - } - } - } - function reflectionScalarDefault(e, r = LongType.STRING) { - switch (e) { - case ScalarType.BOOL: - return !1; - case ScalarType.UINT64: - case ScalarType.FIXED64: - return reflectionLongConvert(PbULong.ZERO, r); - case ScalarType.INT64: - case ScalarType.SFIXED64: - case ScalarType.SINT64: - return reflectionLongConvert(PbLong.ZERO, r); - case ScalarType.DOUBLE: - case ScalarType.FLOAT: - return 0; - case ScalarType.BYTES: - return new Uint8Array(0); - case ScalarType.STRING: - return ''; - default: - return 0; - } - } - class ReflectionBinaryReader { - constructor(e) { - this.info = e; - } - prepare() { - var e; - this.fieldNoToField || - ((e = null != (e = this.info.fields) ? e : []), - (this.fieldNoToField = new Map(e.map((e) => [e.no, e])))); - } - read(a, n, s, e) { - this.prepare(); - for (var r = void 0 === e ? a.len : a.pos + e; a.pos < r; ) { - var [t, i] = a.tag(), - o = this.fieldNoToField.get(t); - if (o) { - let e = n, - r = o.repeat, - t = o.localName; - switch ( - (o.oneof && - (e = e[o.oneof]).oneofKind !== t && - (e = n[o.oneof] = { oneofKind: t }), - o.kind) - ) { - case 'scalar': - case 'enum': - var l = 'enum' == o.kind ? ScalarType.INT32 : o.T, - c = 'scalar' == o.kind ? o.L : void 0; - if (r) { - var u = e[t]; - if ( - i == WireType.LengthDelimited && - l != ScalarType.STRING && - l != ScalarType.BYTES - ) - for (var f = a.uint32() + a.pos; a.pos < f; ) - u.push(this.scalar(a, l, c)); - else u.push(this.scalar(a, l, c)); - } else e[t] = this.scalar(a, l, c); - break; - case 'message': - r - ? ((h = e[t]), - (p = o.T().internalBinaryRead(a, a.uint32(), s)), - h.push(p)) - : (e[t] = o - .T() - .internalBinaryRead(a, a.uint32(), s, e[t])); - break; - case 'map': - var [h, p] = this.mapEntry(o, a, s); - e[t][h] = p; - } - } else { - var d = s.readUnknownField; - if ('throw' == d) - throw new Error( - `Unknown field ${t} (wire type ${i}) for ` + - this.info.typeName - ); - var y = a.skip(i); - !1 !== d && - (!0 === d ? UnknownFieldHandler.onRead : d)( - this.info.typeName, - n, - t, - i, - y - ); - } - } - } - mapEntry(e, r, t) { - var a = r.uint32(), - n = r.pos + a; - let s = void 0, - i = void 0; - for (; r.pos < n; ) { - var [o, l] = r.tag(); - switch (o) { - case 1: - s = - e.K == ScalarType.BOOL - ? r.bool().toString() - : this.scalar(r, e.K, LongType.STRING); - break; - case 2: - switch (e.V.kind) { - case 'scalar': - i = this.scalar(r, e.V.T, e.V.L); - break; - case 'enum': - i = r.int32(); - break; - case 'message': - i = e.V.T().internalBinaryRead(r, r.uint32(), t); - } - break; - default: - throw new Error( - `Unknown field ${o} (wire type ${l}) in map entry for ${this.info.typeName}#` + - e.name - ); - } - } - if ( - (void 0 === s && - ((a = reflectionScalarDefault(e.K)), - (s = e.K == ScalarType.BOOL ? a.toString() : a)), - void 0 === i) - ) - switch (e.V.kind) { - case 'scalar': - i = reflectionScalarDefault(e.V.T, e.V.L); - break; - case 'enum': - i = 0; - break; - case 'message': - i = e.V.T().create(); - } - return [s, i]; - } - scalar(e, r, t) { - switch (r) { - case ScalarType.INT32: - return e.int32(); - case ScalarType.STRING: - return e.string(); - case ScalarType.BOOL: - return e.bool(); - case ScalarType.DOUBLE: - return e.double(); - case ScalarType.FLOAT: - return e.float(); - case ScalarType.INT64: - return reflectionLongConvert(e.int64(), t); - case ScalarType.UINT64: - return reflectionLongConvert(e.uint64(), t); - case ScalarType.FIXED64: - return reflectionLongConvert(e.fixed64(), t); - case ScalarType.FIXED32: - return e.fixed32(); - case ScalarType.BYTES: - return e.bytes(); - case ScalarType.UINT32: - return e.uint32(); - case ScalarType.SFIXED32: - return e.sfixed32(); - case ScalarType.SFIXED64: - return reflectionLongConvert(e.sfixed64(), t); - case ScalarType.SINT32: - return e.sint32(); - case ScalarType.SINT64: - return reflectionLongConvert(e.sint64(), t); - } - } - } - class ReflectionBinaryWriter { - constructor(e) { - this.info = e; - } - prepare() { - var e; - this.fields || - ((e = this.info.fields ? this.info.fields.concat() : []), - (this.fields = e.sort((e, r) => e.no - r.no))); - } - write(n, s, i) { - this.prepare(); - for (const f of this.fields) { - let e, - r, - t = f.repeat, - a = f.localName; - if (f.oneof) { - var o = n[f.oneof]; - if (o.oneofKind !== a) continue; - (e = o[a]), (r = !0); - } else (e = n[a]), (r = !1); - switch (f.kind) { - case 'scalar': - case 'enum': - var l = 'enum' == f.kind ? ScalarType.INT32 : f.T; - if (t) - if ((assert(Array.isArray(e)), t == RepeatType.PACKED)) - this.packed(s, l, f.no, e); - else for (const h of e) this.scalar(s, l, f.no, h, !0); - else - void 0 === e - ? assert(f.opt) - : this.scalar(s, l, f.no, e, r || f.opt); - break; - case 'message': - if (t) { - assert(Array.isArray(e)); - for (const p of e) this.message(s, i, f.T(), f.no, p); - } else this.message(s, i, f.T(), f.no, e); - break; - case 'map': - assert('object' == typeof e && null !== e); - for (var [c, u] of Object.entries(e)) - this.mapEntry(s, i, f, c, u); - } - } - var e = i.writeUnknownFields; - !1 !== e && - (!0 === e ? UnknownFieldHandler.onWrite : e)( - this.info.typeName, - n, - s - ); - } - mapEntry(e, r, t, a, n) { - e.tag(t.no, WireType.LengthDelimited), e.fork(); - let s = a; - switch (t.K) { - case ScalarType.INT32: - case ScalarType.FIXED32: - case ScalarType.UINT32: - case ScalarType.SFIXED32: - case ScalarType.SINT32: - s = Number.parseInt(a); - break; - case ScalarType.BOOL: - assert('true' == a || 'false' == a), (s = 'true' == a); - } - switch ((this.scalar(e, t.K, 1, s, !0), t.V.kind)) { - case 'scalar': - this.scalar(e, t.V.T, 2, n, !0); - break; - case 'enum': - this.scalar(e, ScalarType.INT32, 2, n, !0); - break; - case 'message': - this.message(e, r, t.V.T(), 2, n); - } - e.join(); - } - message(e, r, t, a, n) { - void 0 !== n && - (t.internalBinaryWrite( - n, - e.tag(a, WireType.LengthDelimited).fork(), - r - ), - e.join()); - } - scalar(e, r, t, a, n) { - var [r, s, i] = this.scalarInfo(r, a); - (i && !n) || (e.tag(t, r), e[s](a)); - } - packed(r, e, t, a) { - if (a.length) { - assert(e !== ScalarType.BYTES && e !== ScalarType.STRING), - r.tag(t, WireType.LengthDelimited), - r.fork(); - var [, n] = this.scalarInfo(e); - for (let e = 0; e < a.length; e++) r[n](a[e]); - r.join(); - } - } - scalarInfo(e, r) { - let t = WireType.Varint, - a; - var n = void 0 === r; - let s = 0 === r; - switch (e) { - case ScalarType.INT32: - a = 'int32'; - break; - case ScalarType.STRING: - (s = n || !r.length), - (t = WireType.LengthDelimited), - (a = 'string'); - break; - case ScalarType.BOOL: - (s = !1 === r), (a = 'bool'); - break; - case ScalarType.UINT32: - a = 'uint32'; - break; - case ScalarType.DOUBLE: - (t = WireType.Bit64), (a = 'double'); - break; - case ScalarType.FLOAT: - (t = WireType.Bit32), (a = 'float'); - break; - case ScalarType.INT64: - (s = n || PbLong.from(r).isZero()), (a = 'int64'); - break; - case ScalarType.UINT64: - (s = n || PbULong.from(r).isZero()), (a = 'uint64'); - break; - case ScalarType.FIXED64: - (s = n || PbULong.from(r).isZero()), - (t = WireType.Bit64), - (a = 'fixed64'); - break; - case ScalarType.BYTES: - (s = n || !r.byteLength), - (t = WireType.LengthDelimited), - (a = 'bytes'); - break; - case ScalarType.FIXED32: - (t = WireType.Bit32), (a = 'fixed32'); - break; - case ScalarType.SFIXED32: - (t = WireType.Bit32), (a = 'sfixed32'); - break; - case ScalarType.SFIXED64: - (s = n || PbLong.from(r).isZero()), - (t = WireType.Bit64), - (a = 'sfixed64'); - break; - case ScalarType.SINT32: - a = 'sint32'; - break; - case ScalarType.SINT64: - (s = n || PbLong.from(r).isZero()), (a = 'sint64'); - } - return [t, a, n || s]; - } - } - function reflectionCreate(e) { - var r, - t = {}; - Object.defineProperty(t, MESSAGE_TYPE, { - enumerable: !1, - value: e, - }); - for (r of e.fields) { - var a = r.localName; - if (!r.opt) - if (r.oneof) t[r.oneof] = { oneofKind: void 0 }; - else if (r.repeat) t[a] = []; - else - switch (r.kind) { - case 'scalar': - t[a] = reflectionScalarDefault(r.T, r.L); - break; - case 'enum': - t[a] = 0; - break; - case 'map': - t[a] = {}; - } - } - return t; - } - function reflectionMergePartial(e, r, t) { - let a, - n = t, - s; - for (var i of e.fields) { - var o = i.localName; - if (i.oneof) { - var l = n[i.oneof]; - if (void 0 === l) continue; - if ( - ((a = l[o]), - ((s = r[i.oneof]).oneofKind = l.oneofKind), - void 0 === a) - ) { - delete s[o]; - continue; - } - } else if (((a = n[o]), (s = r), void 0 === a)) continue; - switch (i.kind) { - case 'scalar': - case 'enum': - i.repeat ? (s[o] = a.concat()) : (s[o] = a); - break; - case 'message': - var c = i.T(); - if (i.repeat) - for (let e = 0; e < a.length; e++) s[o][e] = c.create(a[e]); - else - void 0 === s[o] - ? (s[o] = c.create(a)) - : c.mergePartial(s[o], a); - break; - case 'map': - switch (i.V.kind) { - case 'scalar': - case 'enum': - Object.assign(s[o], a); - break; - case 'message': - var u, - f = i.V.T(); - for (u of Object.keys(a)) s[o][u] = f.create(a[u]); - } - } - } - } - const defaultsWrite = { - emitDefaultValues: !1, - enumAsInteger: !1, - useProtoFieldName: !1, - prettySpaces: 0, - }, - defaultsRead = { ignoreUnknownFields: !1 }; - function jsonReadOptions(e) { - return e - ? __spreadValues(__spreadValues({}, defaultsRead), e) - : defaultsRead; - } - function jsonWriteOptions(e) { - return e - ? __spreadValues(__spreadValues({}, defaultsWrite), e) - : defaultsWrite; - } - function reflectionEquals(e, r, t) { - if (r !== t) { - if (!r || !t) return !1; - for (var a of e.fields) { - var n = a.localName, - s = (a.oneof ? r[a.oneof] : r)[n], - i = (a.oneof ? t[a.oneof] : t)[n]; - switch (a.kind) { - case 'enum': - case 'scalar': - var o = 'enum' == a.kind ? ScalarType.INT32 : a.T; - if ((a.repeat ? repeatedPrimitiveEq : primitiveEq)(o, s, i)) - break; - return !1; - case 'map': - if ( - 'message' == a.V.kind - ? repeatedMsgEq( - a.V.T(), - objectValues(s), - objectValues(i) - ) - : repeatedPrimitiveEq( - 'enum' == a.V.kind ? ScalarType.INT32 : a.V.T, - objectValues(s), - objectValues(i) - ) - ) - break; - return !1; - case 'message': - o = a.T(); - if (a.repeat ? repeatedMsgEq(o, s, i) : o.equals(s, i)) - break; - return !1; - } - } - } - return !0; - } - const objectValues = Object.values; - function primitiveEq(e, r, t) { - if (r !== t) { - if (e !== ScalarType.BYTES) return !1; - var a = r, - n = t; - if (a.length !== n.length) return !1; - for (let e = 0; e < a.length; e++) if (a[e] != n[e]) return !1; - } - return !0; - } - function repeatedPrimitiveEq(r, t, a) { - if (t.length !== a.length) return !1; - for (let e = 0; e < t.length; e++) - if (!primitiveEq(r, t[e], a[e])) return !1; - return !0; - } - function repeatedMsgEq(r, t, a) { - if (t.length !== a.length) return !1; - for (let e = 0; e < t.length; e++) - if (!r.equals(t[e], a[e])) return !1; - return !0; - } - class MessageType { - constructor(e, r, t) { - (this.defaultCheckDepth = 16), - (this.typeName = e), - (this.fields = r.map(normalizeFieldInfo)), - (this.options = null != t ? t : {}), - (this.refTypeCheck = new ReflectionTypeCheck(this)), - (this.refJsonReader = new ReflectionJsonReader(this)), - (this.refJsonWriter = new ReflectionJsonWriter(this)), - (this.refBinReader = new ReflectionBinaryReader(this)), - (this.refBinWriter = new ReflectionBinaryWriter(this)); - } - create(e) { - var r = reflectionCreate(this); - return void 0 !== e && reflectionMergePartial(this, r, e), r; - } - clone(e) { - var r = this.create(); - return reflectionMergePartial(this, r, e), r; - } - equals(e, r) { - return reflectionEquals(this, e, r); - } - is(e, r = this.defaultCheckDepth) { - return this.refTypeCheck.is(e, r, !1); - } - isAssignable(e, r = this.defaultCheckDepth) { - return this.refTypeCheck.is(e, r, !0); - } - mergePartial(e, r) { - reflectionMergePartial(this, e, r); - } - fromBinary(e, r) { - r = binaryReadOptions(r); - return this.internalBinaryRead( - r.readerFactory(e), - e.byteLength, - r - ); - } - fromJson(e, r) { - return this.internalJsonRead(e, jsonReadOptions(r)); - } - fromJsonString(e, r) { - e = JSON.parse(e); - return this.fromJson(e, r); - } - toJson(e, r) { - return this.internalJsonWrite(e, jsonWriteOptions(r)); - } - toJsonString(e, r) { - var e = this.toJson(e, r); - return JSON.stringify( - e, - null, - null != (e = null == r ? void 0 : r.prettySpaces) ? e : 0 - ); - } - toBinary(e, r) { - r = binaryWriteOptions(r); - return this.internalBinaryWrite(e, r.writerFactory(), r).finish(); - } - internalJsonRead(e, r, t) { - if (null === e || 'object' != typeof e || Array.isArray(e)) - throw new Error( - `Unable to parse message ${ - this.typeName - } from JSON ${typeofJsonValue(e)}.` - ); - return ( - (t = null != t ? t : this.create()), - this.refJsonReader.read(e, t, r), - t - ); - } - internalJsonWrite(e, r) { - return this.refJsonWriter.write(e, r); - } - internalBinaryWrite(e, r, t) { - return this.refBinWriter.write(e, r, t), r; - } - internalBinaryRead(e, r, t, a) { - a = null != a ? a : this.create(); - return this.refBinReader.read(e, a, t, r), a; - } - } - /****************** initialization finish ******************/ - switch (FORMAT) { - case 'application/x-protobuf': - break; - case 'application/grpc': - case 'application/grpc+proto': - /****************** initialization start *******************/ - // pako 2.0.4 - !(function (t, e) { - 'object' == typeof exports && 'undefined' != typeof module - ? e(exports) - : 'function' == typeof define && define.amd - ? define(['exports'], e) - : e( - ((t = - 'undefined' != typeof globalThis - ? globalThis - : t || self).pako = {}) - ); - })(this, function (t) { - 'use strict'; - function e(t) { - let e = t.length; - for (; --e >= 0; ) t[e] = 0; - } - const a = 256, - i = 286, - n = 30, - s = 15, - r = new Uint8Array([ - 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, - 4, 4, 4, 4, 5, 5, 5, 5, 0, - ]), - l = new Uint8Array([ - 0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, - 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, - ]), - o = new Uint8Array([ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 3, 7, - ]), - h = new Uint8Array([ - 16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, - 1, 15, - ]), - d = new Array(576); - e(d); - const _ = new Array(60); - e(_); - const f = new Array(512); - e(f); - const c = new Array(256); - e(c); - const u = new Array(29); - e(u); - const w = new Array(n); - function b(t, e, a, i, n) { - (this.static_tree = t), - (this.extra_bits = e), - (this.extra_base = a), - (this.elems = i), - (this.max_length = n), - (this.has_stree = t && t.length); - } - let g, p, m; - function k(t, e) { - (this.dyn_tree = t), - (this.max_code = 0), - (this.stat_desc = e); - } - e(w); - const v = (t) => (t < 256 ? f[t] : f[256 + (t >>> 7)]), - y = (t, e) => { - (t.pending_buf[t.pending++] = 255 & e), - (t.pending_buf[t.pending++] = (e >>> 8) & 255); - }, - x = (t, e, a) => { - t.bi_valid > 16 - a - ? ((t.bi_buf |= (e << t.bi_valid) & 65535), - y(t, t.bi_buf), - (t.bi_buf = e >> (16 - t.bi_valid)), - (t.bi_valid += a - 16)) - : ((t.bi_buf |= (e << t.bi_valid) & 65535), - (t.bi_valid += a)); - }, - z = (t, e, a) => { - x(t, a[2 * e], a[2 * e + 1]); - }, - A = (t, e) => { - let a = 0; - do { - (a |= 1 & t), (t >>>= 1), (a <<= 1); - } while (--e > 0); - return a >>> 1; - }, - E = (t, e, a) => { - const i = new Array(16); - let n, - r, - l = 0; - for (n = 1; n <= s; n++) i[n] = l = (l + a[n - 1]) << 1; - for (r = 0; r <= e; r++) { - let e = t[2 * r + 1]; - 0 !== e && (t[2 * r] = A(i[e]++, e)); - } - }, - R = (t) => { - let e; - for (e = 0; e < i; e++) t.dyn_ltree[2 * e] = 0; - for (e = 0; e < n; e++) t.dyn_dtree[2 * e] = 0; - for (e = 0; e < 19; e++) t.bl_tree[2 * e] = 0; - (t.dyn_ltree[512] = 1), - (t.opt_len = t.static_len = 0), - (t.last_lit = t.matches = 0); - }, - Z = (t) => { - t.bi_valid > 8 - ? y(t, t.bi_buf) - : t.bi_valid > 0 && - (t.pending_buf[t.pending++] = t.bi_buf), - (t.bi_buf = 0), - (t.bi_valid = 0); - }, - U = (t, e, a, i) => { - const n = 2 * e, - s = 2 * a; - return t[n] < t[s] || (t[n] === t[s] && i[e] <= i[a]); - }, - S = (t, e, a) => { - const i = t.heap[a]; - let n = a << 1; - for ( - ; - n <= t.heap_len && - (n < t.heap_len && - U(e, t.heap[n + 1], t.heap[n], t.depth) && - n++, - !U(e, i, t.heap[n], t.depth)); - - ) - (t.heap[a] = t.heap[n]), (a = n), (n <<= 1); - t.heap[a] = i; - }, - D = (t, e, i) => { - let n, - s, - o, - h, - d = 0; - if (0 !== t.last_lit) - do { - (n = - (t.pending_buf[t.d_buf + 2 * d] << 8) | - t.pending_buf[t.d_buf + 2 * d + 1]), - (s = t.pending_buf[t.l_buf + d]), - d++, - 0 === n - ? z(t, s, e) - : ((o = c[s]), - z(t, o + a + 1, e), - (h = r[o]), - 0 !== h && ((s -= u[o]), x(t, s, h)), - n--, - (o = v(n)), - z(t, o, i), - (h = l[o]), - 0 !== h && ((n -= w[o]), x(t, n, h))); - } while (d < t.last_lit); - z(t, 256, e); - }, - T = (t, e) => { - const a = e.dyn_tree, - i = e.stat_desc.static_tree, - n = e.stat_desc.has_stree, - r = e.stat_desc.elems; - let l, - o, - h, - d = -1; - for (t.heap_len = 0, t.heap_max = 573, l = 0; l < r; l++) - 0 !== a[2 * l] - ? ((t.heap[++t.heap_len] = d = l), (t.depth[l] = 0)) - : (a[2 * l + 1] = 0); - for (; t.heap_len < 2; ) - (h = t.heap[++t.heap_len] = d < 2 ? ++d : 0), - (a[2 * h] = 1), - (t.depth[h] = 0), - t.opt_len--, - n && (t.static_len -= i[2 * h + 1]); - for (e.max_code = d, l = t.heap_len >> 1; l >= 1; l--) - S(t, a, l); - h = r; - do { - (l = t.heap[1]), - (t.heap[1] = t.heap[t.heap_len--]), - S(t, a, 1), - (o = t.heap[1]), - (t.heap[--t.heap_max] = l), - (t.heap[--t.heap_max] = o), - (a[2 * h] = a[2 * l] + a[2 * o]), - (t.depth[h] = - (t.depth[l] >= t.depth[o] ? t.depth[l] : t.depth[o]) + - 1), - (a[2 * l + 1] = a[2 * o + 1] = h), - (t.heap[1] = h++), - S(t, a, 1); - } while (t.heap_len >= 2); - (t.heap[--t.heap_max] = t.heap[1]), - ((t, e) => { - const a = e.dyn_tree, - i = e.max_code, - n = e.stat_desc.static_tree, - r = e.stat_desc.has_stree, - l = e.stat_desc.extra_bits, - o = e.stat_desc.extra_base, - h = e.stat_desc.max_length; - let d, - _, - f, - c, - u, - w, - b = 0; - for (c = 0; c <= s; c++) t.bl_count[c] = 0; - for ( - a[2 * t.heap[t.heap_max] + 1] = 0, d = t.heap_max + 1; - d < 573; - d++ - ) - (_ = t.heap[d]), - (c = a[2 * a[2 * _ + 1] + 1] + 1), - c > h && ((c = h), b++), - (a[2 * _ + 1] = c), - _ > i || - (t.bl_count[c]++, - (u = 0), - _ >= o && (u = l[_ - o]), - (w = a[2 * _]), - (t.opt_len += w * (c + u)), - r && (t.static_len += w * (n[2 * _ + 1] + u))); - if (0 !== b) { - do { - for (c = h - 1; 0 === t.bl_count[c]; ) c--; - t.bl_count[c]--, - (t.bl_count[c + 1] += 2), - t.bl_count[h]--, - (b -= 2); - } while (b > 0); - for (c = h; 0 !== c; c--) - for (_ = t.bl_count[c]; 0 !== _; ) - (f = t.heap[--d]), - f > i || - (a[2 * f + 1] !== c && - ((t.opt_len += - (c - a[2 * f + 1]) * a[2 * f]), - (a[2 * f + 1] = c)), - _--); - } - })(t, e), - E(a, d, t.bl_count); - }, - O = (t, e, a) => { - let i, - n, - s = -1, - r = e[1], - l = 0, - o = 7, - h = 4; - for ( - 0 === r && ((o = 138), (h = 3)), - e[2 * (a + 1) + 1] = 65535, - i = 0; - i <= a; - i++ - ) - (n = r), - (r = e[2 * (i + 1) + 1]), - (++l < o && n === r) || - (l < h - ? (t.bl_tree[2 * n] += l) - : 0 !== n - ? (n !== s && t.bl_tree[2 * n]++, t.bl_tree[32]++) - : l <= 10 - ? t.bl_tree[34]++ - : t.bl_tree[36]++, - (l = 0), - (s = n), - 0 === r - ? ((o = 138), (h = 3)) - : n === r - ? ((o = 6), (h = 3)) - : ((o = 7), (h = 4))); - }, - I = (t, e, a) => { - let i, - n, - s = -1, - r = e[1], - l = 0, - o = 7, - h = 4; - for (0 === r && ((o = 138), (h = 3)), i = 0; i <= a; i++) - if ( - ((n = r), - (r = e[2 * (i + 1) + 1]), - !(++l < o && n === r)) - ) { - if (l < h) - do { - z(t, n, t.bl_tree); - } while (0 != --l); - else - 0 !== n - ? (n !== s && (z(t, n, t.bl_tree), l--), - z(t, 16, t.bl_tree), - x(t, l - 3, 2)) - : l <= 10 - ? (z(t, 17, t.bl_tree), x(t, l - 3, 3)) - : (z(t, 18, t.bl_tree), x(t, l - 11, 7)); - (l = 0), - (s = n), - 0 === r - ? ((o = 138), (h = 3)) - : n === r - ? ((o = 6), (h = 3)) - : ((o = 7), (h = 4)); - } - }; - let F = !1; - const L = (t, e, a, i) => { - x(t, 0 + (i ? 1 : 0), 3), - ((t, e, a, i) => { - Z(t), - i && (y(t, a), y(t, ~a)), - t.pending_buf.set( - t.window.subarray(e, e + a), - t.pending - ), - (t.pending += a); - })(t, e, a, !0); - }; - var N = { - _tr_init: (t) => { - F || - ((() => { - let t, e, a, h, k; - const v = new Array(16); - for (a = 0, h = 0; h < 28; h++) - for (u[h] = a, t = 0; t < 1 << r[h]; t++) c[a++] = h; - for (c[a - 1] = h, k = 0, h = 0; h < 16; h++) - for (w[h] = k, t = 0; t < 1 << l[h]; t++) f[k++] = h; - for (k >>= 7; h < n; h++) - for (w[h] = k << 7, t = 0; t < 1 << (l[h] - 7); t++) - f[256 + k++] = h; - for (e = 0; e <= s; e++) v[e] = 0; - for (t = 0; t <= 143; ) (d[2 * t + 1] = 8), t++, v[8]++; - for (; t <= 255; ) (d[2 * t + 1] = 9), t++, v[9]++; - for (; t <= 279; ) (d[2 * t + 1] = 7), t++, v[7]++; - for (; t <= 287; ) (d[2 * t + 1] = 8), t++, v[8]++; - for (E(d, 287, v), t = 0; t < n; t++) - (_[2 * t + 1] = 5), (_[2 * t] = A(t, 5)); - (g = new b(d, r, 257, i, s)), - (p = new b(_, l, 0, n, s)), - (m = new b(new Array(0), o, 0, 19, 7)); - })(), - (F = !0)), - (t.l_desc = new k(t.dyn_ltree, g)), - (t.d_desc = new k(t.dyn_dtree, p)), - (t.bl_desc = new k(t.bl_tree, m)), - (t.bi_buf = 0), - (t.bi_valid = 0), - R(t); - }, - _tr_stored_block: L, - _tr_flush_block: (t, e, i, n) => { - let s, - r, - l = 0; - t.level > 0 - ? (2 === t.strm.data_type && - (t.strm.data_type = ((t) => { - let e, - i = 4093624447; - for (e = 0; e <= 31; e++, i >>>= 1) - if (1 & i && 0 !== t.dyn_ltree[2 * e]) return 0; - if ( - 0 !== t.dyn_ltree[18] || - 0 !== t.dyn_ltree[20] || - 0 !== t.dyn_ltree[26] - ) - return 1; - for (e = 32; e < a; e++) - if (0 !== t.dyn_ltree[2 * e]) return 1; - return 0; - })(t)), - T(t, t.l_desc), - T(t, t.d_desc), - (l = ((t) => { - let e; - for ( - O(t, t.dyn_ltree, t.l_desc.max_code), - O(t, t.dyn_dtree, t.d_desc.max_code), - T(t, t.bl_desc), - e = 18; - e >= 3 && 0 === t.bl_tree[2 * h[e] + 1]; - e-- - ); - return (t.opt_len += 3 * (e + 1) + 5 + 5 + 4), e; - })(t)), - (s = (t.opt_len + 3 + 7) >>> 3), - (r = (t.static_len + 3 + 7) >>> 3), - r <= s && (s = r)) - : (s = r = i + 5), - i + 4 <= s && -1 !== e - ? L(t, e, i, n) - : 4 === t.strategy || r === s - ? (x(t, 2 + (n ? 1 : 0), 3), D(t, d, _)) - : (x(t, 4 + (n ? 1 : 0), 3), - ((t, e, a, i) => { - let n; - for ( - x(t, e - 257, 5), - x(t, a - 1, 5), - x(t, i - 4, 4), - n = 0; - n < i; - n++ - ) - x(t, t.bl_tree[2 * h[n] + 1], 3); - I(t, t.dyn_ltree, e - 1), I(t, t.dyn_dtree, a - 1); - })( - t, - t.l_desc.max_code + 1, - t.d_desc.max_code + 1, - l + 1 - ), - D(t, t.dyn_ltree, t.dyn_dtree)), - R(t), - n && Z(t); - }, - _tr_tally: (t, e, i) => ( - (t.pending_buf[t.d_buf + 2 * t.last_lit] = (e >>> 8) & 255), - (t.pending_buf[t.d_buf + 2 * t.last_lit + 1] = 255 & e), - (t.pending_buf[t.l_buf + t.last_lit] = 255 & i), - t.last_lit++, - 0 === e - ? t.dyn_ltree[2 * i]++ - : (t.matches++, - e--, - t.dyn_ltree[2 * (c[i] + a + 1)]++, - t.dyn_dtree[2 * v(e)]++), - t.last_lit === t.lit_bufsize - 1 - ), - _tr_align: (t) => { - x(t, 2, 3), - z(t, 256, d), - ((t) => { - 16 === t.bi_valid - ? (y(t, t.bi_buf), (t.bi_buf = 0), (t.bi_valid = 0)) - : t.bi_valid >= 8 && - ((t.pending_buf[t.pending++] = 255 & t.bi_buf), - (t.bi_buf >>= 8), - (t.bi_valid -= 8)); - })(t); - }, - }; - var B = (t, e, a, i) => { - let n = (65535 & t) | 0, - s = ((t >>> 16) & 65535) | 0, - r = 0; - for (; 0 !== a; ) { - (r = a > 2e3 ? 2e3 : a), (a -= r); - do { - (n = (n + e[i++]) | 0), (s = (s + n) | 0); - } while (--r); - (n %= 65521), (s %= 65521); - } - return n | (s << 16) | 0; - }; - const C = new Uint32Array( - (() => { - let t, - e = []; - for (var a = 0; a < 256; a++) { - t = a; - for (var i = 0; i < 8; i++) - t = 1 & t ? 3988292384 ^ (t >>> 1) : t >>> 1; - e[a] = t; - } - return e; - })() - ); - var M = (t, e, a, i) => { - const n = C, - s = i + a; - t ^= -1; - for (let a = i; a < s; a++) - t = (t >>> 8) ^ n[255 & (t ^ e[a])]; - return -1 ^ t; - }, - H = { - 2: 'need dictionary', - 1: 'stream end', - 0: '', - '-1': 'file error', - '-2': 'stream error', - '-3': 'data error', - '-4': 'insufficient memory', - '-5': 'buffer error', - '-6': 'incompatible version', - }, - j = { - Z_NO_FLUSH: 0, - Z_PARTIAL_FLUSH: 1, - Z_SYNC_FLUSH: 2, - Z_FULL_FLUSH: 3, - Z_FINISH: 4, - Z_BLOCK: 5, - Z_TREES: 6, - Z_OK: 0, - Z_STREAM_END: 1, - Z_NEED_DICT: 2, - Z_ERRNO: -1, - Z_STREAM_ERROR: -2, - Z_DATA_ERROR: -3, - Z_MEM_ERROR: -4, - Z_BUF_ERROR: -5, - Z_NO_COMPRESSION: 0, - Z_BEST_SPEED: 1, - Z_BEST_COMPRESSION: 9, - Z_DEFAULT_COMPRESSION: -1, - Z_FILTERED: 1, - Z_HUFFMAN_ONLY: 2, - Z_RLE: 3, - Z_FIXED: 4, - Z_DEFAULT_STRATEGY: 0, - Z_BINARY: 0, - Z_TEXT: 1, - Z_UNKNOWN: 2, - Z_DEFLATED: 8, - }; - const { - _tr_init: K, - _tr_stored_block: P, - _tr_flush_block: Y, - _tr_tally: G, - _tr_align: X, - } = N, - { - Z_NO_FLUSH: W, - Z_PARTIAL_FLUSH: q, - Z_FULL_FLUSH: J, - Z_FINISH: Q, - Z_BLOCK: V, - Z_OK: $, - Z_STREAM_END: tt, - Z_STREAM_ERROR: et, - Z_DATA_ERROR: at, - Z_BUF_ERROR: it, - Z_DEFAULT_COMPRESSION: nt, - Z_FILTERED: st, - Z_HUFFMAN_ONLY: rt, - Z_RLE: lt, - Z_FIXED: ot, - Z_DEFAULT_STRATEGY: ht, - Z_UNKNOWN: dt, - Z_DEFLATED: _t, - } = j, - ft = 258, - ct = 262, - ut = 103, - wt = 113, - bt = 666, - gt = (t, e) => ((t.msg = H[e]), e), - pt = (t) => (t << 1) - (t > 4 ? 9 : 0), - mt = (t) => { - let e = t.length; - for (; --e >= 0; ) t[e] = 0; - }; - let kt = (t, e, a) => ((e << t.hash_shift) ^ a) & t.hash_mask; - const vt = (t) => { - const e = t.state; - let a = e.pending; - a > t.avail_out && (a = t.avail_out), - 0 !== a && - (t.output.set( - e.pending_buf.subarray( - e.pending_out, - e.pending_out + a - ), - t.next_out - ), - (t.next_out += a), - (e.pending_out += a), - (t.total_out += a), - (t.avail_out -= a), - (e.pending -= a), - 0 === e.pending && (e.pending_out = 0)); - }, - yt = (t, e) => { - Y( - t, - t.block_start >= 0 ? t.block_start : -1, - t.strstart - t.block_start, - e - ), - (t.block_start = t.strstart), - vt(t.strm); - }, - xt = (t, e) => { - t.pending_buf[t.pending++] = e; - }, - zt = (t, e) => { - (t.pending_buf[t.pending++] = (e >>> 8) & 255), - (t.pending_buf[t.pending++] = 255 & e); - }, - At = (t, e, a, i) => { - let n = t.avail_in; - return ( - n > i && (n = i), - 0 === n - ? 0 - : ((t.avail_in -= n), - e.set(t.input.subarray(t.next_in, t.next_in + n), a), - 1 === t.state.wrap - ? (t.adler = B(t.adler, e, n, a)) - : 2 === t.state.wrap && - (t.adler = M(t.adler, e, n, a)), - (t.next_in += n), - (t.total_in += n), - n) - ); - }, - Et = (t, e) => { - let a, - i, - n = t.max_chain_length, - s = t.strstart, - r = t.prev_length, - l = t.nice_match; - const o = - t.strstart > t.w_size - ct - ? t.strstart - (t.w_size - ct) - : 0, - h = t.window, - d = t.w_mask, - _ = t.prev, - f = t.strstart + ft; - let c = h[s + r - 1], - u = h[s + r]; - t.prev_length >= t.good_match && (n >>= 2), - l > t.lookahead && (l = t.lookahead); - do { - if ( - ((a = e), - h[a + r] === u && - h[a + r - 1] === c && - h[a] === h[s] && - h[++a] === h[s + 1]) - ) { - (s += 2), a++; - do {} while ( - h[++s] === h[++a] && - h[++s] === h[++a] && - h[++s] === h[++a] && - h[++s] === h[++a] && - h[++s] === h[++a] && - h[++s] === h[++a] && - h[++s] === h[++a] && - h[++s] === h[++a] && - s < f - ); - if (((i = ft - (f - s)), (s = f - ft), i > r)) { - if (((t.match_start = e), (r = i), i >= l)) break; - (c = h[s + r - 1]), (u = h[s + r]); - } - } - } while ((e = _[e & d]) > o && 0 != --n); - return r <= t.lookahead ? r : t.lookahead; - }, - Rt = (t) => { - const e = t.w_size; - let a, i, n, s, r; - do { - if ( - ((s = t.window_size - t.lookahead - t.strstart), - t.strstart >= e + (e - ct)) - ) { - t.window.set(t.window.subarray(e, e + e), 0), - (t.match_start -= e), - (t.strstart -= e), - (t.block_start -= e), - (i = t.hash_size), - (a = i); - do { - (n = t.head[--a]), (t.head[a] = n >= e ? n - e : 0); - } while (--i); - (i = e), (a = i); - do { - (n = t.prev[--a]), (t.prev[a] = n >= e ? n - e : 0); - } while (--i); - s += e; - } - if (0 === t.strm.avail_in) break; - if ( - ((i = At( - t.strm, - t.window, - t.strstart + t.lookahead, - s - )), - (t.lookahead += i), - t.lookahead + t.insert >= 3) - ) - for ( - r = t.strstart - t.insert, - t.ins_h = t.window[r], - t.ins_h = kt(t, t.ins_h, t.window[r + 1]); - t.insert && - ((t.ins_h = kt(t, t.ins_h, t.window[r + 3 - 1])), - (t.prev[r & t.w_mask] = t.head[t.ins_h]), - (t.head[t.ins_h] = r), - r++, - t.insert--, - !(t.lookahead + t.insert < 3)); - - ); - } while (t.lookahead < ct && 0 !== t.strm.avail_in); - }, - Zt = (t, e) => { - let a, i; - for (;;) { - if (t.lookahead < ct) { - if ((Rt(t), t.lookahead < ct && e === W)) return 1; - if (0 === t.lookahead) break; - } - if ( - ((a = 0), - t.lookahead >= 3 && - ((t.ins_h = kt( - t, - t.ins_h, - t.window[t.strstart + 3 - 1] - )), - (a = t.prev[t.strstart & t.w_mask] = t.head[t.ins_h]), - (t.head[t.ins_h] = t.strstart)), - 0 !== a && - t.strstart - a <= t.w_size - ct && - (t.match_length = Et(t, a)), - t.match_length >= 3) - ) - if ( - ((i = G( - t, - t.strstart - t.match_start, - t.match_length - 3 - )), - (t.lookahead -= t.match_length), - t.match_length <= t.max_lazy_match && - t.lookahead >= 3) - ) { - t.match_length--; - do { - t.strstart++, - (t.ins_h = kt( - t, - t.ins_h, - t.window[t.strstart + 3 - 1] - )), - (a = t.prev[t.strstart & t.w_mask] = - t.head[t.ins_h]), - (t.head[t.ins_h] = t.strstart); - } while (0 != --t.match_length); - t.strstart++; - } else - (t.strstart += t.match_length), - (t.match_length = 0), - (t.ins_h = t.window[t.strstart]), - (t.ins_h = kt( - t, - t.ins_h, - t.window[t.strstart + 1] - )); - else - (i = G(t, 0, t.window[t.strstart])), - t.lookahead--, - t.strstart++; - if (i && (yt(t, !1), 0 === t.strm.avail_out)) return 1; - } - return ( - (t.insert = t.strstart < 2 ? t.strstart : 2), - e === Q - ? (yt(t, !0), 0 === t.strm.avail_out ? 3 : 4) - : t.last_lit && (yt(t, !1), 0 === t.strm.avail_out) - ? 1 - : 2 - ); - }, - Ut = (t, e) => { - let a, i, n; - for (;;) { - if (t.lookahead < ct) { - if ((Rt(t), t.lookahead < ct && e === W)) return 1; - if (0 === t.lookahead) break; - } - if ( - ((a = 0), - t.lookahead >= 3 && - ((t.ins_h = kt( - t, - t.ins_h, - t.window[t.strstart + 3 - 1] - )), - (a = t.prev[t.strstart & t.w_mask] = t.head[t.ins_h]), - (t.head[t.ins_h] = t.strstart)), - (t.prev_length = t.match_length), - (t.prev_match = t.match_start), - (t.match_length = 2), - 0 !== a && - t.prev_length < t.max_lazy_match && - t.strstart - a <= t.w_size - ct && - ((t.match_length = Et(t, a)), - t.match_length <= 5 && - (t.strategy === st || - (3 === t.match_length && - t.strstart - t.match_start > 4096)) && - (t.match_length = 2)), - t.prev_length >= 3 && t.match_length <= t.prev_length) - ) { - (n = t.strstart + t.lookahead - 3), - (i = G( - t, - t.strstart - 1 - t.prev_match, - t.prev_length - 3 - )), - (t.lookahead -= t.prev_length - 1), - (t.prev_length -= 2); - do { - ++t.strstart <= n && - ((t.ins_h = kt( - t, - t.ins_h, - t.window[t.strstart + 3 - 1] - )), - (a = t.prev[t.strstart & t.w_mask] = - t.head[t.ins_h]), - (t.head[t.ins_h] = t.strstart)); - } while (0 != --t.prev_length); - if ( - ((t.match_available = 0), - (t.match_length = 2), - t.strstart++, - i && (yt(t, !1), 0 === t.strm.avail_out)) - ) - return 1; - } else if (t.match_available) { - if ( - ((i = G(t, 0, t.window[t.strstart - 1])), - i && yt(t, !1), - t.strstart++, - t.lookahead--, - 0 === t.strm.avail_out) - ) - return 1; - } else - (t.match_available = 1), t.strstart++, t.lookahead--; - } - return ( - t.match_available && - ((i = G(t, 0, t.window[t.strstart - 1])), - (t.match_available = 0)), - (t.insert = t.strstart < 2 ? t.strstart : 2), - e === Q - ? (yt(t, !0), 0 === t.strm.avail_out ? 3 : 4) - : t.last_lit && (yt(t, !1), 0 === t.strm.avail_out) - ? 1 - : 2 - ); - }; - function St(t, e, a, i, n) { - (this.good_length = t), - (this.max_lazy = e), - (this.nice_length = a), - (this.max_chain = i), - (this.func = n); - } - const Dt = [ - new St(0, 0, 0, 0, (t, e) => { - let a = 65535; - for ( - a > t.pending_buf_size - 5 && - (a = t.pending_buf_size - 5); - ; - - ) { - if (t.lookahead <= 1) { - if ((Rt(t), 0 === t.lookahead && e === W)) return 1; - if (0 === t.lookahead) break; - } - (t.strstart += t.lookahead), (t.lookahead = 0); - const i = t.block_start + a; - if ( - (0 === t.strstart || t.strstart >= i) && - ((t.lookahead = t.strstart - i), - (t.strstart = i), - yt(t, !1), - 0 === t.strm.avail_out) - ) - return 1; - if ( - t.strstart - t.block_start >= t.w_size - ct && - (yt(t, !1), 0 === t.strm.avail_out) - ) - return 1; - } - return ( - (t.insert = 0), - e === Q - ? (yt(t, !0), 0 === t.strm.avail_out ? 3 : 4) - : (t.strstart > t.block_start && - (yt(t, !1), t.strm.avail_out), - 1) - ); - }), - new St(4, 4, 8, 4, Zt), - new St(4, 5, 16, 8, Zt), - new St(4, 6, 32, 32, Zt), - new St(4, 4, 16, 16, Ut), - new St(8, 16, 32, 32, Ut), - new St(8, 16, 128, 128, Ut), - new St(8, 32, 128, 256, Ut), - new St(32, 128, 258, 1024, Ut), - new St(32, 258, 258, 4096, Ut), - ]; - function Tt() { - (this.strm = null), - (this.status = 0), - (this.pending_buf = null), - (this.pending_buf_size = 0), - (this.pending_out = 0), - (this.pending = 0), - (this.wrap = 0), - (this.gzhead = null), - (this.gzindex = 0), - (this.method = _t), - (this.last_flush = -1), - (this.w_size = 0), - (this.w_bits = 0), - (this.w_mask = 0), - (this.window = null), - (this.window_size = 0), - (this.prev = null), - (this.head = null), - (this.ins_h = 0), - (this.hash_size = 0), - (this.hash_bits = 0), - (this.hash_mask = 0), - (this.hash_shift = 0), - (this.block_start = 0), - (this.match_length = 0), - (this.prev_match = 0), - (this.match_available = 0), - (this.strstart = 0), - (this.match_start = 0), - (this.lookahead = 0), - (this.prev_length = 0), - (this.max_chain_length = 0), - (this.max_lazy_match = 0), - (this.level = 0), - (this.strategy = 0), - (this.good_match = 0), - (this.nice_match = 0), - (this.dyn_ltree = new Uint16Array(1146)), - (this.dyn_dtree = new Uint16Array(122)), - (this.bl_tree = new Uint16Array(78)), - mt(this.dyn_ltree), - mt(this.dyn_dtree), - mt(this.bl_tree), - (this.l_desc = null), - (this.d_desc = null), - (this.bl_desc = null), - (this.bl_count = new Uint16Array(16)), - (this.heap = new Uint16Array(573)), - mt(this.heap), - (this.heap_len = 0), - (this.heap_max = 0), - (this.depth = new Uint16Array(573)), - mt(this.depth), - (this.l_buf = 0), - (this.lit_bufsize = 0), - (this.last_lit = 0), - (this.d_buf = 0), - (this.opt_len = 0), - (this.static_len = 0), - (this.matches = 0), - (this.insert = 0), - (this.bi_buf = 0), - (this.bi_valid = 0); - } - const Ot = (t) => { - if (!t || !t.state) return gt(t, et); - (t.total_in = t.total_out = 0), (t.data_type = dt); - const e = t.state; - return ( - (e.pending = 0), - (e.pending_out = 0), - e.wrap < 0 && (e.wrap = -e.wrap), - (e.status = e.wrap ? 42 : wt), - (t.adler = 2 === e.wrap ? 0 : 1), - (e.last_flush = W), - K(e), - $ - ); - }, - It = (t) => { - const e = Ot(t); - var a; - return ( - e === $ && - (((a = t.state).window_size = 2 * a.w_size), - mt(a.head), - (a.max_lazy_match = Dt[a.level].max_lazy), - (a.good_match = Dt[a.level].good_length), - (a.nice_match = Dt[a.level].nice_length), - (a.max_chain_length = Dt[a.level].max_chain), - (a.strstart = 0), - (a.block_start = 0), - (a.lookahead = 0), - (a.insert = 0), - (a.match_length = a.prev_length = 2), - (a.match_available = 0), - (a.ins_h = 0)), - e - ); - }, - Ft = (t, e, a, i, n, s) => { - if (!t) return et; - let r = 1; - if ( - (e === nt && (e = 6), - i < 0 - ? ((r = 0), (i = -i)) - : i > 15 && ((r = 2), (i -= 16)), - n < 1 || - n > 9 || - a !== _t || - i < 8 || - i > 15 || - e < 0 || - e > 9 || - s < 0 || - s > ot) - ) - return gt(t, et); - 8 === i && (i = 9); - const l = new Tt(); - return ( - (t.state = l), - (l.strm = t), - (l.wrap = r), - (l.gzhead = null), - (l.w_bits = i), - (l.w_size = 1 << l.w_bits), - (l.w_mask = l.w_size - 1), - (l.hash_bits = n + 7), - (l.hash_size = 1 << l.hash_bits), - (l.hash_mask = l.hash_size - 1), - (l.hash_shift = ~~((l.hash_bits + 3 - 1) / 3)), - (l.window = new Uint8Array(2 * l.w_size)), - (l.head = new Uint16Array(l.hash_size)), - (l.prev = new Uint16Array(l.w_size)), - (l.lit_bufsize = 1 << (n + 6)), - (l.pending_buf_size = 4 * l.lit_bufsize), - (l.pending_buf = new Uint8Array(l.pending_buf_size)), - (l.d_buf = 1 * l.lit_bufsize), - (l.l_buf = 3 * l.lit_bufsize), - (l.level = e), - (l.strategy = s), - (l.method = a), - It(t) - ); - }; - var Lt = { - deflateInit: (t, e) => Ft(t, e, _t, 15, 8, ht), - deflateInit2: Ft, - deflateReset: It, - deflateResetKeep: Ot, - deflateSetHeader: (t, e) => - t && t.state - ? 2 !== t.state.wrap - ? et - : ((t.state.gzhead = e), $) - : et, - deflate: (t, e) => { - let a, i; - if (!t || !t.state || e > V || e < 0) - return t ? gt(t, et) : et; - const n = t.state; - if ( - !t.output || - (!t.input && 0 !== t.avail_in) || - (n.status === bt && e !== Q) - ) - return gt(t, 0 === t.avail_out ? it : et); - n.strm = t; - const s = n.last_flush; - if (((n.last_flush = e), 42 === n.status)) - if (2 === n.wrap) - (t.adler = 0), - xt(n, 31), - xt(n, 139), - xt(n, 8), - n.gzhead - ? (xt( - n, - (n.gzhead.text ? 1 : 0) + - (n.gzhead.hcrc ? 2 : 0) + - (n.gzhead.extra ? 4 : 0) + - (n.gzhead.name ? 8 : 0) + - (n.gzhead.comment ? 16 : 0) - ), - xt(n, 255 & n.gzhead.time), - xt(n, (n.gzhead.time >> 8) & 255), - xt(n, (n.gzhead.time >> 16) & 255), - xt(n, (n.gzhead.time >> 24) & 255), - xt( - n, - 9 === n.level - ? 2 - : n.strategy >= rt || n.level < 2 - ? 4 - : 0 - ), - xt(n, 255 & n.gzhead.os), - n.gzhead.extra && - n.gzhead.extra.length && - (xt(n, 255 & n.gzhead.extra.length), - xt(n, (n.gzhead.extra.length >> 8) & 255)), - n.gzhead.hcrc && - (t.adler = M( - t.adler, - n.pending_buf, - n.pending, - 0 - )), - (n.gzindex = 0), - (n.status = 69)) - : (xt(n, 0), - xt(n, 0), - xt(n, 0), - xt(n, 0), - xt(n, 0), - xt( - n, - 9 === n.level - ? 2 - : n.strategy >= rt || n.level < 2 - ? 4 - : 0 - ), - xt(n, 3), - (n.status = wt)); - else { - let e = (_t + ((n.w_bits - 8) << 4)) << 8, - a = -1; - (a = - n.strategy >= rt || n.level < 2 - ? 0 - : n.level < 6 - ? 1 - : 6 === n.level - ? 2 - : 3), - (e |= a << 6), - 0 !== n.strstart && (e |= 32), - (e += 31 - (e % 31)), - (n.status = wt), - zt(n, e), - 0 !== n.strstart && - (zt(n, t.adler >>> 16), zt(n, 65535 & t.adler)), - (t.adler = 1); - } - if (69 === n.status) - if (n.gzhead.extra) { - for ( - a = n.pending; - n.gzindex < (65535 & n.gzhead.extra.length) && - (n.pending !== n.pending_buf_size || - (n.gzhead.hcrc && - n.pending > a && - (t.adler = M( - t.adler, - n.pending_buf, - n.pending - a, - a - )), - vt(t), - (a = n.pending), - n.pending !== n.pending_buf_size)); - - ) - xt(n, 255 & n.gzhead.extra[n.gzindex]), n.gzindex++; - n.gzhead.hcrc && - n.pending > a && - (t.adler = M( - t.adler, - n.pending_buf, - n.pending - a, - a - )), - n.gzindex === n.gzhead.extra.length && - ((n.gzindex = 0), (n.status = 73)); - } else n.status = 73; - if (73 === n.status) - if (n.gzhead.name) { - a = n.pending; - do { - if ( - n.pending === n.pending_buf_size && - (n.gzhead.hcrc && - n.pending > a && - (t.adler = M( - t.adler, - n.pending_buf, - n.pending - a, - a - )), - vt(t), - (a = n.pending), - n.pending === n.pending_buf_size) - ) { - i = 1; - break; - } - (i = - n.gzindex < n.gzhead.name.length - ? 255 & n.gzhead.name.charCodeAt(n.gzindex++) - : 0), - xt(n, i); - } while (0 !== i); - n.gzhead.hcrc && - n.pending > a && - (t.adler = M( - t.adler, - n.pending_buf, - n.pending - a, - a - )), - 0 === i && ((n.gzindex = 0), (n.status = 91)); - } else n.status = 91; - if (91 === n.status) - if (n.gzhead.comment) { - a = n.pending; - do { - if ( - n.pending === n.pending_buf_size && - (n.gzhead.hcrc && - n.pending > a && - (t.adler = M( - t.adler, - n.pending_buf, - n.pending - a, - a - )), - vt(t), - (a = n.pending), - n.pending === n.pending_buf_size) - ) { - i = 1; - break; - } - (i = - n.gzindex < n.gzhead.comment.length - ? 255 & n.gzhead.comment.charCodeAt(n.gzindex++) - : 0), - xt(n, i); - } while (0 !== i); - n.gzhead.hcrc && - n.pending > a && - (t.adler = M( - t.adler, - n.pending_buf, - n.pending - a, - a - )), - 0 === i && (n.status = ut); - } else n.status = ut; - if ( - (n.status === ut && - (n.gzhead.hcrc - ? (n.pending + 2 > n.pending_buf_size && vt(t), - n.pending + 2 <= n.pending_buf_size && - (xt(n, 255 & t.adler), - xt(n, (t.adler >> 8) & 255), - (t.adler = 0), - (n.status = wt))) - : (n.status = wt)), - 0 !== n.pending) - ) { - if ((vt(t), 0 === t.avail_out)) - return (n.last_flush = -1), $; - } else if (0 === t.avail_in && pt(e) <= pt(s) && e !== Q) - return gt(t, it); - if (n.status === bt && 0 !== t.avail_in) return gt(t, it); - if ( - 0 !== t.avail_in || - 0 !== n.lookahead || - (e !== W && n.status !== bt) - ) { - let a = - n.strategy === rt - ? ((t, e) => { - let a; - for (;;) { - if ( - 0 === t.lookahead && - (Rt(t), 0 === t.lookahead) - ) { - if (e === W) return 1; - break; - } - if ( - ((t.match_length = 0), - (a = G(t, 0, t.window[t.strstart])), - t.lookahead--, - t.strstart++, - a && (yt(t, !1), 0 === t.strm.avail_out)) - ) - return 1; - } - return ( - (t.insert = 0), - e === Q - ? (yt(t, !0), 0 === t.strm.avail_out ? 3 : 4) - : t.last_lit && - (yt(t, !1), 0 === t.strm.avail_out) - ? 1 - : 2 - ); - })(n, e) - : n.strategy === lt - ? ((t, e) => { - let a, i, n, s; - const r = t.window; - for (;;) { - if (t.lookahead <= ft) { - if ((Rt(t), t.lookahead <= ft && e === W)) - return 1; - if (0 === t.lookahead) break; - } - if ( - ((t.match_length = 0), - t.lookahead >= 3 && - t.strstart > 0 && - ((n = t.strstart - 1), - (i = r[n]), - i === r[++n] && - i === r[++n] && - i === r[++n])) - ) { - s = t.strstart + ft; - do {} while ( - i === r[++n] && - i === r[++n] && - i === r[++n] && - i === r[++n] && - i === r[++n] && - i === r[++n] && - i === r[++n] && - i === r[++n] && - n < s - ); - (t.match_length = ft - (s - n)), - t.match_length > t.lookahead && - (t.match_length = t.lookahead); - } - if ( - (t.match_length >= 3 - ? ((a = G(t, 1, t.match_length - 3)), - (t.lookahead -= t.match_length), - (t.strstart += t.match_length), - (t.match_length = 0)) - : ((a = G(t, 0, t.window[t.strstart])), - t.lookahead--, - t.strstart++), - a && (yt(t, !1), 0 === t.strm.avail_out)) - ) - return 1; - } - return ( - (t.insert = 0), - e === Q - ? (yt(t, !0), 0 === t.strm.avail_out ? 3 : 4) - : t.last_lit && - (yt(t, !1), 0 === t.strm.avail_out) - ? 1 - : 2 - ); - })(n, e) - : Dt[n.level].func(n, e); - if ( - ((3 !== a && 4 !== a) || (n.status = bt), - 1 === a || 3 === a) - ) - return 0 === t.avail_out && (n.last_flush = -1), $; - if ( - 2 === a && - (e === q - ? X(n) - : e !== V && - (P(n, 0, 0, !1), - e === J && - (mt(n.head), - 0 === n.lookahead && - ((n.strstart = 0), - (n.block_start = 0), - (n.insert = 0)))), - vt(t), - 0 === t.avail_out) - ) - return (n.last_flush = -1), $; - } - return e !== Q - ? $ - : n.wrap <= 0 - ? tt - : (2 === n.wrap - ? (xt(n, 255 & t.adler), - xt(n, (t.adler >> 8) & 255), - xt(n, (t.adler >> 16) & 255), - xt(n, (t.adler >> 24) & 255), - xt(n, 255 & t.total_in), - xt(n, (t.total_in >> 8) & 255), - xt(n, (t.total_in >> 16) & 255), - xt(n, (t.total_in >> 24) & 255)) - : (zt(n, t.adler >>> 16), zt(n, 65535 & t.adler)), - vt(t), - n.wrap > 0 && (n.wrap = -n.wrap), - 0 !== n.pending ? $ : tt); - }, - deflateEnd: (t) => { - if (!t || !t.state) return et; - const e = t.state.status; - return 42 !== e && - 69 !== e && - 73 !== e && - 91 !== e && - e !== ut && - e !== wt && - e !== bt - ? gt(t, et) - : ((t.state = null), e === wt ? gt(t, at) : $); - }, - deflateSetDictionary: (t, e) => { - let a = e.length; - if (!t || !t.state) return et; - const i = t.state, - n = i.wrap; - if (2 === n || (1 === n && 42 !== i.status) || i.lookahead) - return et; - if ( - (1 === n && (t.adler = B(t.adler, e, a, 0)), - (i.wrap = 0), - a >= i.w_size) - ) { - 0 === n && - (mt(i.head), - (i.strstart = 0), - (i.block_start = 0), - (i.insert = 0)); - let t = new Uint8Array(i.w_size); - t.set(e.subarray(a - i.w_size, a), 0), - (e = t), - (a = i.w_size); - } - const s = t.avail_in, - r = t.next_in, - l = t.input; - for ( - t.avail_in = a, t.next_in = 0, t.input = e, Rt(i); - i.lookahead >= 3; - - ) { - let t = i.strstart, - e = i.lookahead - 2; - do { - (i.ins_h = kt(i, i.ins_h, i.window[t + 3 - 1])), - (i.prev[t & i.w_mask] = i.head[i.ins_h]), - (i.head[i.ins_h] = t), - t++; - } while (--e); - (i.strstart = t), (i.lookahead = 2), Rt(i); - } - return ( - (i.strstart += i.lookahead), - (i.block_start = i.strstart), - (i.insert = i.lookahead), - (i.lookahead = 0), - (i.match_length = i.prev_length = 2), - (i.match_available = 0), - (t.next_in = r), - (t.input = l), - (t.avail_in = s), - (i.wrap = n), - $ - ); - }, - deflateInfo: 'pako deflate (from Nodeca project)', - }; - const Nt = (t, e) => Object.prototype.hasOwnProperty.call(t, e); - var Bt = function (t) { - const e = Array.prototype.slice.call(arguments, 1); - for (; e.length; ) { - const a = e.shift(); - if (a) { - if ('object' != typeof a) - throw new TypeError(a + 'must be non-object'); - for (const e in a) Nt(a, e) && (t[e] = a[e]); - } - } - return t; - }, - Ct = (t) => { - let e = 0; - for (let a = 0, i = t.length; a < i; a++) e += t[a].length; - const a = new Uint8Array(e); - for (let e = 0, i = 0, n = t.length; e < n; e++) { - let n = t[e]; - a.set(n, i), (i += n.length); - } - return a; - }; - let Mt = !0; - try { - String.fromCharCode.apply(null, new Uint8Array(1)); - } catch (t) { - Mt = !1; - } - const Ht = new Uint8Array(256); - for (let t = 0; t < 256; t++) - Ht[t] = - t >= 252 - ? 6 - : t >= 248 - ? 5 - : t >= 240 - ? 4 - : t >= 224 - ? 3 - : t >= 192 - ? 2 - : 1; - Ht[254] = Ht[254] = 1; - var jt = (t) => { - if ( - 'function' == typeof TextEncoder && - TextEncoder.prototype.encode - ) - return new TextEncoder().encode(t); - let e, - a, - i, - n, - s, - r = t.length, - l = 0; - for (n = 0; n < r; n++) - (a = t.charCodeAt(n)), - 55296 == (64512 & a) && - n + 1 < r && - ((i = t.charCodeAt(n + 1)), - 56320 == (64512 & i) && - ((a = 65536 + ((a - 55296) << 10) + (i - 56320)), - n++)), - (l += a < 128 ? 1 : a < 2048 ? 2 : a < 65536 ? 3 : 4); - for (e = new Uint8Array(l), s = 0, n = 0; s < l; n++) - (a = t.charCodeAt(n)), - 55296 == (64512 & a) && - n + 1 < r && - ((i = t.charCodeAt(n + 1)), - 56320 == (64512 & i) && - ((a = 65536 + ((a - 55296) << 10) + (i - 56320)), - n++)), - a < 128 - ? (e[s++] = a) - : a < 2048 - ? ((e[s++] = 192 | (a >>> 6)), - (e[s++] = 128 | (63 & a))) - : a < 65536 - ? ((e[s++] = 224 | (a >>> 12)), - (e[s++] = 128 | ((a >>> 6) & 63)), - (e[s++] = 128 | (63 & a))) - : ((e[s++] = 240 | (a >>> 18)), - (e[s++] = 128 | ((a >>> 12) & 63)), - (e[s++] = 128 | ((a >>> 6) & 63)), - (e[s++] = 128 | (63 & a))); - return e; - }, - Kt = (t, e) => { - const a = e || t.length; - if ( - 'function' == typeof TextDecoder && - TextDecoder.prototype.decode - ) - return new TextDecoder().decode(t.subarray(0, e)); - let i, n; - const s = new Array(2 * a); - for (n = 0, i = 0; i < a; ) { - let e = t[i++]; - if (e < 128) { - s[n++] = e; - continue; - } - let r = Ht[e]; - if (r > 4) (s[n++] = 65533), (i += r - 1); - else { - for ( - e &= 2 === r ? 31 : 3 === r ? 15 : 7; - r > 1 && i < a; - - ) - (e = (e << 6) | (63 & t[i++])), r--; - r > 1 - ? (s[n++] = 65533) - : e < 65536 - ? (s[n++] = e) - : ((e -= 65536), - (s[n++] = 55296 | ((e >> 10) & 1023)), - (s[n++] = 56320 | (1023 & e))); - } - } - return ((t, e) => { - if (e < 65534 && t.subarray && Mt) - return String.fromCharCode.apply( - null, - t.length === e ? t : t.subarray(0, e) - ); - let a = ''; - for (let i = 0; i < e; i++) - a += String.fromCharCode(t[i]); - return a; - })(s, n); - }, - Pt = (t, e) => { - (e = e || t.length) > t.length && (e = t.length); - let a = e - 1; - for (; a >= 0 && 128 == (192 & t[a]); ) a--; - return a < 0 || 0 === a ? e : a + Ht[t[a]] > e ? a : e; - }; - var Yt = function () { - (this.input = null), - (this.next_in = 0), - (this.avail_in = 0), - (this.total_in = 0), - (this.output = null), - (this.next_out = 0), - (this.avail_out = 0), - (this.total_out = 0), - (this.msg = ''), - (this.state = null), - (this.data_type = 2), - (this.adler = 0); - }; - const Gt = Object.prototype.toString, - { - Z_NO_FLUSH: Xt, - Z_SYNC_FLUSH: Wt, - Z_FULL_FLUSH: qt, - Z_FINISH: Jt, - Z_OK: Qt, - Z_STREAM_END: Vt, - Z_DEFAULT_COMPRESSION: $t, - Z_DEFAULT_STRATEGY: te, - Z_DEFLATED: ee, - } = j; - function ae(t) { - this.options = Bt( - { - level: $t, - method: ee, - chunkSize: 16384, - windowBits: 15, - memLevel: 8, - strategy: te, - }, - t || {} - ); - let e = this.options; - e.raw && e.windowBits > 0 - ? (e.windowBits = -e.windowBits) - : e.gzip && - e.windowBits > 0 && - e.windowBits < 16 && - (e.windowBits += 16), - (this.err = 0), - (this.msg = ''), - (this.ended = !1), - (this.chunks = []), - (this.strm = new Yt()), - (this.strm.avail_out = 0); - let a = Lt.deflateInit2( - this.strm, - e.level, - e.method, - e.windowBits, - e.memLevel, - e.strategy - ); - if (a !== Qt) throw new Error(H[a]); - if ( - (e.header && Lt.deflateSetHeader(this.strm, e.header), - e.dictionary) - ) { - let t; - if ( - ((t = - 'string' == typeof e.dictionary - ? jt(e.dictionary) - : '[object ArrayBuffer]' === Gt.call(e.dictionary) - ? new Uint8Array(e.dictionary) - : e.dictionary), - (a = Lt.deflateSetDictionary(this.strm, t)), - a !== Qt) - ) - throw new Error(H[a]); - this._dict_set = !0; - } - } - function ie(t, e) { - const a = new ae(e); - if ((a.push(t, !0), a.err)) throw a.msg || H[a.err]; - return a.result; - } - (ae.prototype.push = function (t, e) { - const a = this.strm, - i = this.options.chunkSize; - let n, s; - if (this.ended) return !1; - for ( - s = e === ~~e ? e : !0 === e ? Jt : Xt, - 'string' == typeof t - ? (a.input = jt(t)) - : '[object ArrayBuffer]' === Gt.call(t) - ? (a.input = new Uint8Array(t)) - : (a.input = t), - a.next_in = 0, - a.avail_in = a.input.length; - ; - - ) - if ( - (0 === a.avail_out && - ((a.output = new Uint8Array(i)), - (a.next_out = 0), - (a.avail_out = i)), - (s === Wt || s === qt) && a.avail_out <= 6) - ) - this.onData(a.output.subarray(0, a.next_out)), - (a.avail_out = 0); - else { - if (((n = Lt.deflate(a, s)), n === Vt)) - return ( - a.next_out > 0 && - this.onData(a.output.subarray(0, a.next_out)), - (n = Lt.deflateEnd(this.strm)), - this.onEnd(n), - (this.ended = !0), - n === Qt - ); - if (0 !== a.avail_out) { - if (s > 0 && a.next_out > 0) - this.onData(a.output.subarray(0, a.next_out)), - (a.avail_out = 0); - else if (0 === a.avail_in) break; - } else this.onData(a.output); - } - return !0; - }), - (ae.prototype.onData = function (t) { - this.chunks.push(t); - }), - (ae.prototype.onEnd = function (t) { - t === Qt && (this.result = Ct(this.chunks)), - (this.chunks = []), - (this.err = t), - (this.msg = this.strm.msg); - }); - var ne = { - Deflate: ae, - deflate: ie, - deflateRaw: function (t, e) { - return ((e = e || {}).raw = !0), ie(t, e); - }, - gzip: function (t, e) { - return ((e = e || {}).gzip = !0), ie(t, e); - }, - constants: j, - }; - var se = function (t, e) { - let a, - i, - n, - s, - r, - l, - o, - h, - d, - _, - f, - c, - u, - w, - b, - g, - p, - m, - k, - v, - y, - x, - z, - A; - const E = t.state; - (a = t.next_in), - (z = t.input), - (i = a + (t.avail_in - 5)), - (n = t.next_out), - (A = t.output), - (s = n - (e - t.avail_out)), - (r = n + (t.avail_out - 257)), - (l = E.dmax), - (o = E.wsize), - (h = E.whave), - (d = E.wnext), - (_ = E.window), - (f = E.hold), - (c = E.bits), - (u = E.lencode), - (w = E.distcode), - (b = (1 << E.lenbits) - 1), - (g = (1 << E.distbits) - 1); - t: do { - c < 15 && - ((f += z[a++] << c), - (c += 8), - (f += z[a++] << c), - (c += 8)), - (p = u[f & b]); - e: for (;;) { - if ( - ((m = p >>> 24), - (f >>>= m), - (c -= m), - (m = (p >>> 16) & 255), - 0 === m) - ) - A[n++] = 65535 & p; - else { - if (!(16 & m)) { - if (0 == (64 & m)) { - p = u[(65535 & p) + (f & ((1 << m) - 1))]; - continue e; - } - if (32 & m) { - E.mode = 12; - break t; - } - (t.msg = 'invalid literal/length code'), - (E.mode = 30); - break t; - } - (k = 65535 & p), - (m &= 15), - m && - (c < m && ((f += z[a++] << c), (c += 8)), - (k += f & ((1 << m) - 1)), - (f >>>= m), - (c -= m)), - c < 15 && - ((f += z[a++] << c), - (c += 8), - (f += z[a++] << c), - (c += 8)), - (p = w[f & g]); - a: for (;;) { - if ( - ((m = p >>> 24), - (f >>>= m), - (c -= m), - (m = (p >>> 16) & 255), - !(16 & m)) - ) { - if (0 == (64 & m)) { - p = w[(65535 & p) + (f & ((1 << m) - 1))]; - continue a; - } - (t.msg = 'invalid distance code'), (E.mode = 30); - break t; - } - if ( - ((v = 65535 & p), - (m &= 15), - c < m && - ((f += z[a++] << c), - (c += 8), - c < m && ((f += z[a++] << c), (c += 8))), - (v += f & ((1 << m) - 1)), - v > l) - ) { - (t.msg = 'invalid distance too far back'), - (E.mode = 30); - break t; - } - if (((f >>>= m), (c -= m), (m = n - s), v > m)) { - if (((m = v - m), m > h && E.sane)) { - (t.msg = 'invalid distance too far back'), - (E.mode = 30); - break t; - } - if (((y = 0), (x = _), 0 === d)) { - if (((y += o - m), m < k)) { - k -= m; - do { - A[n++] = _[y++]; - } while (--m); - (y = n - v), (x = A); - } - } else if (d < m) { - if (((y += o + d - m), (m -= d), m < k)) { - k -= m; - do { - A[n++] = _[y++]; - } while (--m); - if (((y = 0), d < k)) { - (m = d), (k -= m); - do { - A[n++] = _[y++]; - } while (--m); - (y = n - v), (x = A); - } - } - } else if (((y += d - m), m < k)) { - k -= m; - do { - A[n++] = _[y++]; - } while (--m); - (y = n - v), (x = A); - } - for (; k > 2; ) - (A[n++] = x[y++]), - (A[n++] = x[y++]), - (A[n++] = x[y++]), - (k -= 3); - k && - ((A[n++] = x[y++]), k > 1 && (A[n++] = x[y++])); - } else { - y = n - v; - do { - (A[n++] = A[y++]), - (A[n++] = A[y++]), - (A[n++] = A[y++]), - (k -= 3); - } while (k > 2); - k && - ((A[n++] = A[y++]), k > 1 && (A[n++] = A[y++])); - } - break; - } - } - break; - } - } while (a < i && n < r); - (k = c >> 3), - (a -= k), - (c -= k << 3), - (f &= (1 << c) - 1), - (t.next_in = a), - (t.next_out = n), - (t.avail_in = a < i ? i - a + 5 : 5 - (a - i)), - (t.avail_out = n < r ? r - n + 257 : 257 - (n - r)), - (E.hold = f), - (E.bits = c); - }; - const re = 15, - le = new Uint16Array([ - 3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31, 35, - 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0, - ]), - oe = new Uint8Array([ - 16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 18, 18, 18, - 18, 19, 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 16, 72, - 78, - ]), - he = new Uint16Array([ - 1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193, - 257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145, - 8193, 12289, 16385, 24577, 0, 0, - ]), - de = new Uint8Array([ - 16, 16, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, - 22, 23, 23, 24, 24, 25, 25, 26, 26, 27, 27, 28, 28, 29, 29, - 64, 64, - ]); - var _e = (t, e, a, i, n, s, r, l) => { - const o = l.bits; - let h, - d, - _, - f, - c, - u, - w = 0, - b = 0, - g = 0, - p = 0, - m = 0, - k = 0, - v = 0, - y = 0, - x = 0, - z = 0, - A = null, - E = 0; - const R = new Uint16Array(16), - Z = new Uint16Array(16); - let U, - S, - D, - T = null, - O = 0; - for (w = 0; w <= re; w++) R[w] = 0; - for (b = 0; b < i; b++) R[e[a + b]]++; - for (m = o, p = re; p >= 1 && 0 === R[p]; p--); - if ((m > p && (m = p), 0 === p)) - return ( - (n[s++] = 20971520), (n[s++] = 20971520), (l.bits = 1), 0 - ); - for (g = 1; g < p && 0 === R[g]; g++); - for (m < g && (m = g), y = 1, w = 1; w <= re; w++) - if (((y <<= 1), (y -= R[w]), y < 0)) return -1; - if (y > 0 && (0 === t || 1 !== p)) return -1; - for (Z[1] = 0, w = 1; w < re; w++) Z[w + 1] = Z[w] + R[w]; - for (b = 0; b < i; b++) - 0 !== e[a + b] && (r[Z[e[a + b]]++] = b); - if ( - (0 === t - ? ((A = T = r), (u = 19)) - : 1 === t - ? ((A = le), (E -= 257), (T = oe), (O -= 257), (u = 256)) - : ((A = he), (T = de), (u = -1)), - (z = 0), - (b = 0), - (w = g), - (c = s), - (k = m), - (v = 0), - (_ = -1), - (x = 1 << m), - (f = x - 1), - (1 === t && x > 852) || (2 === t && x > 592)) - ) - return 1; - for (;;) { - (U = w - v), - r[b] < u - ? ((S = 0), (D = r[b])) - : r[b] > u - ? ((S = T[O + r[b]]), (D = A[E + r[b]])) - : ((S = 96), (D = 0)), - (h = 1 << (w - v)), - (d = 1 << k), - (g = d); - do { - (d -= h), - (n[c + (z >> v) + d] = (U << 24) | (S << 16) | D | 0); - } while (0 !== d); - for (h = 1 << (w - 1); z & h; ) h >>= 1; - if ( - (0 !== h ? ((z &= h - 1), (z += h)) : (z = 0), - b++, - 0 == --R[w]) - ) { - if (w === p) break; - w = e[a + r[b]]; - } - if (w > m && (z & f) !== _) { - for ( - 0 === v && (v = m), c += g, k = w - v, y = 1 << k; - k + v < p && ((y -= R[k + v]), !(y <= 0)); - - ) - k++, (y <<= 1); - if ( - ((x += 1 << k), - (1 === t && x > 852) || (2 === t && x > 592)) - ) - return 1; - (_ = z & f), (n[_] = (m << 24) | (k << 16) | (c - s) | 0); - } - } - return ( - 0 !== z && (n[c + z] = ((w - v) << 24) | (64 << 16) | 0), - (l.bits = m), - 0 - ); - }; - const { - Z_FINISH: fe, - Z_BLOCK: ce, - Z_TREES: ue, - Z_OK: we, - Z_STREAM_END: be, - Z_NEED_DICT: ge, - Z_STREAM_ERROR: pe, - Z_DATA_ERROR: me, - Z_MEM_ERROR: ke, - Z_BUF_ERROR: ve, - Z_DEFLATED: ye, - } = j, - xe = 12, - ze = 30, - Ae = (t) => - ((t >>> 24) & 255) + - ((t >>> 8) & 65280) + - ((65280 & t) << 8) + - ((255 & t) << 24); - function Ee() { - (this.mode = 0), - (this.last = !1), - (this.wrap = 0), - (this.havedict = !1), - (this.flags = 0), - (this.dmax = 0), - (this.check = 0), - (this.total = 0), - (this.head = null), - (this.wbits = 0), - (this.wsize = 0), - (this.whave = 0), - (this.wnext = 0), - (this.window = null), - (this.hold = 0), - (this.bits = 0), - (this.length = 0), - (this.offset = 0), - (this.extra = 0), - (this.lencode = null), - (this.distcode = null), - (this.lenbits = 0), - (this.distbits = 0), - (this.ncode = 0), - (this.nlen = 0), - (this.ndist = 0), - (this.have = 0), - (this.next = null), - (this.lens = new Uint16Array(320)), - (this.work = new Uint16Array(288)), - (this.lendyn = null), - (this.distdyn = null), - (this.sane = 0), - (this.back = 0), - (this.was = 0); - } - const Re = (t) => { - if (!t || !t.state) return pe; - const e = t.state; - return ( - (t.total_in = t.total_out = e.total = 0), - (t.msg = ''), - e.wrap && (t.adler = 1 & e.wrap), - (e.mode = 1), - (e.last = 0), - (e.havedict = 0), - (e.dmax = 32768), - (e.head = null), - (e.hold = 0), - (e.bits = 0), - (e.lencode = e.lendyn = new Int32Array(852)), - (e.distcode = e.distdyn = new Int32Array(592)), - (e.sane = 1), - (e.back = -1), - we - ); - }, - Ze = (t) => { - if (!t || !t.state) return pe; - const e = t.state; - return (e.wsize = 0), (e.whave = 0), (e.wnext = 0), Re(t); - }, - Ue = (t, e) => { - let a; - if (!t || !t.state) return pe; - const i = t.state; - return ( - e < 0 - ? ((a = 0), (e = -e)) - : ((a = 1 + (e >> 4)), e < 48 && (e &= 15)), - e && (e < 8 || e > 15) - ? pe - : (null !== i.window && - i.wbits !== e && - (i.window = null), - (i.wrap = a), - (i.wbits = e), - Ze(t)) - ); - }, - Se = (t, e) => { - if (!t) return pe; - const a = new Ee(); - (t.state = a), (a.window = null); - const i = Ue(t, e); - return i !== we && (t.state = null), i; - }; - let De, - Te, - Oe = !0; - const Ie = (t) => { - if (Oe) { - (De = new Int32Array(512)), (Te = new Int32Array(32)); - let e = 0; - for (; e < 144; ) t.lens[e++] = 8; - for (; e < 256; ) t.lens[e++] = 9; - for (; e < 280; ) t.lens[e++] = 7; - for (; e < 288; ) t.lens[e++] = 8; - for ( - _e(1, t.lens, 0, 288, De, 0, t.work, { bits: 9 }), - e = 0; - e < 32; - - ) - t.lens[e++] = 5; - _e(2, t.lens, 0, 32, Te, 0, t.work, { bits: 5 }), - (Oe = !1); - } - (t.lencode = De), - (t.lenbits = 9), - (t.distcode = Te), - (t.distbits = 5); - }, - Fe = (t, e, a, i) => { - let n; - const s = t.state; - return ( - null === s.window && - ((s.wsize = 1 << s.wbits), - (s.wnext = 0), - (s.whave = 0), - (s.window = new Uint8Array(s.wsize))), - i >= s.wsize - ? (s.window.set(e.subarray(a - s.wsize, a), 0), - (s.wnext = 0), - (s.whave = s.wsize)) - : ((n = s.wsize - s.wnext), - n > i && (n = i), - s.window.set(e.subarray(a - i, a - i + n), s.wnext), - (i -= n) - ? (s.window.set(e.subarray(a - i, a), 0), - (s.wnext = i), - (s.whave = s.wsize)) - : ((s.wnext += n), - s.wnext === s.wsize && (s.wnext = 0), - s.whave < s.wsize && (s.whave += n))), - 0 - ); - }; - var Le = { - inflateReset: Ze, - inflateReset2: Ue, - inflateResetKeep: Re, - inflateInit: (t) => Se(t, 15), - inflateInit2: Se, - inflate: (t, e) => { - let a, - i, - n, - s, - r, - l, - o, - h, - d, - _, - f, - c, - u, - w, - b, - g, - p, - m, - k, - v, - y, - x, - z = 0; - const A = new Uint8Array(4); - let E, R; - const Z = new Uint8Array([ - 16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, - 1, 15, - ]); - if ( - !t || - !t.state || - !t.output || - (!t.input && 0 !== t.avail_in) - ) - return pe; - (a = t.state), - a.mode === xe && (a.mode = 13), - (r = t.next_out), - (n = t.output), - (o = t.avail_out), - (s = t.next_in), - (i = t.input), - (l = t.avail_in), - (h = a.hold), - (d = a.bits), - (_ = l), - (f = o), - (x = we); - t: for (;;) - switch (a.mode) { - case 1: - if (0 === a.wrap) { - a.mode = 13; - break; - } - for (; d < 16; ) { - if (0 === l) break t; - l--, (h += i[s++] << d), (d += 8); - } - if (2 & a.wrap && 35615 === h) { - (a.check = 0), - (A[0] = 255 & h), - (A[1] = (h >>> 8) & 255), - (a.check = M(a.check, A, 2, 0)), - (h = 0), - (d = 0), - (a.mode = 2); - break; - } - if ( - ((a.flags = 0), - a.head && (a.head.done = !1), - !(1 & a.wrap) || (((255 & h) << 8) + (h >> 8)) % 31) - ) { - (t.msg = 'incorrect header check'), (a.mode = ze); - break; - } - if ((15 & h) !== ye) { - (t.msg = 'unknown compression method'), - (a.mode = ze); - break; - } - if ( - ((h >>>= 4), - (d -= 4), - (y = 8 + (15 & h)), - 0 === a.wbits) - ) - a.wbits = y; - else if (y > a.wbits) { - (t.msg = 'invalid window size'), (a.mode = ze); - break; - } - (a.dmax = 1 << a.wbits), - (t.adler = a.check = 1), - (a.mode = 512 & h ? 10 : xe), - (h = 0), - (d = 0); - break; - case 2: - for (; d < 16; ) { - if (0 === l) break t; - l--, (h += i[s++] << d), (d += 8); - } - if (((a.flags = h), (255 & a.flags) !== ye)) { - (t.msg = 'unknown compression method'), - (a.mode = ze); - break; - } - if (57344 & a.flags) { - (t.msg = 'unknown header flags set'), (a.mode = ze); - break; - } - a.head && (a.head.text = (h >> 8) & 1), - 512 & a.flags && - ((A[0] = 255 & h), - (A[1] = (h >>> 8) & 255), - (a.check = M(a.check, A, 2, 0))), - (h = 0), - (d = 0), - (a.mode = 3); - case 3: - for (; d < 32; ) { - if (0 === l) break t; - l--, (h += i[s++] << d), (d += 8); - } - a.head && (a.head.time = h), - 512 & a.flags && - ((A[0] = 255 & h), - (A[1] = (h >>> 8) & 255), - (A[2] = (h >>> 16) & 255), - (A[3] = (h >>> 24) & 255), - (a.check = M(a.check, A, 4, 0))), - (h = 0), - (d = 0), - (a.mode = 4); - case 4: - for (; d < 16; ) { - if (0 === l) break t; - l--, (h += i[s++] << d), (d += 8); - } - a.head && - ((a.head.xflags = 255 & h), (a.head.os = h >> 8)), - 512 & a.flags && - ((A[0] = 255 & h), - (A[1] = (h >>> 8) & 255), - (a.check = M(a.check, A, 2, 0))), - (h = 0), - (d = 0), - (a.mode = 5); - case 5: - if (1024 & a.flags) { - for (; d < 16; ) { - if (0 === l) break t; - l--, (h += i[s++] << d), (d += 8); - } - (a.length = h), - a.head && (a.head.extra_len = h), - 512 & a.flags && - ((A[0] = 255 & h), - (A[1] = (h >>> 8) & 255), - (a.check = M(a.check, A, 2, 0))), - (h = 0), - (d = 0); - } else a.head && (a.head.extra = null); - a.mode = 6; - case 6: - if ( - 1024 & a.flags && - ((c = a.length), - c > l && (c = l), - c && - (a.head && - ((y = a.head.extra_len - a.length), - a.head.extra || - (a.head.extra = new Uint8Array( - a.head.extra_len - )), - a.head.extra.set(i.subarray(s, s + c), y)), - 512 & a.flags && (a.check = M(a.check, i, c, s)), - (l -= c), - (s += c), - (a.length -= c)), - a.length) - ) - break t; - (a.length = 0), (a.mode = 7); - case 7: - if (2048 & a.flags) { - if (0 === l) break t; - c = 0; - do { - (y = i[s + c++]), - a.head && - y && - a.length < 65536 && - (a.head.name += String.fromCharCode(y)); - } while (y && c < l); - if ( - (512 & a.flags && (a.check = M(a.check, i, c, s)), - (l -= c), - (s += c), - y) - ) - break t; - } else a.head && (a.head.name = null); - (a.length = 0), (a.mode = 8); - case 8: - if (4096 & a.flags) { - if (0 === l) break t; - c = 0; - do { - (y = i[s + c++]), - a.head && - y && - a.length < 65536 && - (a.head.comment += String.fromCharCode(y)); - } while (y && c < l); - if ( - (512 & a.flags && (a.check = M(a.check, i, c, s)), - (l -= c), - (s += c), - y) - ) - break t; - } else a.head && (a.head.comment = null); - a.mode = 9; - case 9: - if (512 & a.flags) { - for (; d < 16; ) { - if (0 === l) break t; - l--, (h += i[s++] << d), (d += 8); - } - if (h !== (65535 & a.check)) { - (t.msg = 'header crc mismatch'), (a.mode = ze); - break; - } - (h = 0), (d = 0); - } - a.head && - ((a.head.hcrc = (a.flags >> 9) & 1), - (a.head.done = !0)), - (t.adler = a.check = 0), - (a.mode = xe); - break; - case 10: - for (; d < 32; ) { - if (0 === l) break t; - l--, (h += i[s++] << d), (d += 8); - } - (t.adler = a.check = Ae(h)), - (h = 0), - (d = 0), - (a.mode = 11); - case 11: - if (0 === a.havedict) - return ( - (t.next_out = r), - (t.avail_out = o), - (t.next_in = s), - (t.avail_in = l), - (a.hold = h), - (a.bits = d), - ge - ); - (t.adler = a.check = 1), (a.mode = xe); - case xe: - if (e === ce || e === ue) break t; - case 13: - if (a.last) { - (h >>>= 7 & d), (d -= 7 & d), (a.mode = 27); - break; - } - for (; d < 3; ) { - if (0 === l) break t; - l--, (h += i[s++] << d), (d += 8); - } - switch ( - ((a.last = 1 & h), (h >>>= 1), (d -= 1), 3 & h) - ) { - case 0: - a.mode = 14; - break; - case 1: - if ((Ie(a), (a.mode = 20), e === ue)) { - (h >>>= 2), (d -= 2); - break t; - } - break; - case 2: - a.mode = 17; - break; - case 3: - (t.msg = 'invalid block type'), (a.mode = ze); - } - (h >>>= 2), (d -= 2); - break; - case 14: - for (h >>>= 7 & d, d -= 7 & d; d < 32; ) { - if (0 === l) break t; - l--, (h += i[s++] << d), (d += 8); - } - if ((65535 & h) != ((h >>> 16) ^ 65535)) { - (t.msg = 'invalid stored block lengths'), - (a.mode = ze); - break; - } - if ( - ((a.length = 65535 & h), - (h = 0), - (d = 0), - (a.mode = 15), - e === ue) - ) - break t; - case 15: - a.mode = 16; - case 16: - if (((c = a.length), c)) { - if ((c > l && (c = l), c > o && (c = o), 0 === c)) - break t; - n.set(i.subarray(s, s + c), r), - (l -= c), - (s += c), - (o -= c), - (r += c), - (a.length -= c); - break; - } - a.mode = xe; - break; - case 17: - for (; d < 14; ) { - if (0 === l) break t; - l--, (h += i[s++] << d), (d += 8); - } - if ( - ((a.nlen = 257 + (31 & h)), - (h >>>= 5), - (d -= 5), - (a.ndist = 1 + (31 & h)), - (h >>>= 5), - (d -= 5), - (a.ncode = 4 + (15 & h)), - (h >>>= 4), - (d -= 4), - a.nlen > 286 || a.ndist > 30) - ) { - (t.msg = 'too many length or distance symbols'), - (a.mode = ze); - break; - } - (a.have = 0), (a.mode = 18); - case 18: - for (; a.have < a.ncode; ) { - for (; d < 3; ) { - if (0 === l) break t; - l--, (h += i[s++] << d), (d += 8); - } - (a.lens[Z[a.have++]] = 7 & h), (h >>>= 3), (d -= 3); - } - for (; a.have < 19; ) a.lens[Z[a.have++]] = 0; - if ( - ((a.lencode = a.lendyn), - (a.lenbits = 7), - (E = { bits: a.lenbits }), - (x = _e(0, a.lens, 0, 19, a.lencode, 0, a.work, E)), - (a.lenbits = E.bits), - x) - ) { - (t.msg = 'invalid code lengths set'), (a.mode = ze); - break; - } - (a.have = 0), (a.mode = 19); - case 19: - for (; a.have < a.nlen + a.ndist; ) { - for ( - ; - (z = a.lencode[h & ((1 << a.lenbits) - 1)]), - (b = z >>> 24), - (g = (z >>> 16) & 255), - (p = 65535 & z), - !(b <= d); - - ) { - if (0 === l) break t; - l--, (h += i[s++] << d), (d += 8); - } - if (p < 16) - (h >>>= b), (d -= b), (a.lens[a.have++] = p); - else { - if (16 === p) { - for (R = b + 2; d < R; ) { - if (0 === l) break t; - l--, (h += i[s++] << d), (d += 8); - } - if (((h >>>= b), (d -= b), 0 === a.have)) { - (t.msg = 'invalid bit length repeat'), - (a.mode = ze); - break; - } - (y = a.lens[a.have - 1]), - (c = 3 + (3 & h)), - (h >>>= 2), - (d -= 2); - } else if (17 === p) { - for (R = b + 3; d < R; ) { - if (0 === l) break t; - l--, (h += i[s++] << d), (d += 8); - } - (h >>>= b), - (d -= b), - (y = 0), - (c = 3 + (7 & h)), - (h >>>= 3), - (d -= 3); - } else { - for (R = b + 7; d < R; ) { - if (0 === l) break t; - l--, (h += i[s++] << d), (d += 8); - } - (h >>>= b), - (d -= b), - (y = 0), - (c = 11 + (127 & h)), - (h >>>= 7), - (d -= 7); - } - if (a.have + c > a.nlen + a.ndist) { - (t.msg = 'invalid bit length repeat'), - (a.mode = ze); - break; - } - for (; c--; ) a.lens[a.have++] = y; - } - } - if (a.mode === ze) break; - if (0 === a.lens[256]) { - (t.msg = 'invalid code -- missing end-of-block'), - (a.mode = ze); - break; - } - if ( - ((a.lenbits = 9), - (E = { bits: a.lenbits }), - (x = _e( - 1, - a.lens, - 0, - a.nlen, - a.lencode, - 0, - a.work, - E - )), - (a.lenbits = E.bits), - x) - ) { - (t.msg = 'invalid literal/lengths set'), - (a.mode = ze); - break; - } - if ( - ((a.distbits = 6), - (a.distcode = a.distdyn), - (E = { bits: a.distbits }), - (x = _e( - 2, - a.lens, - a.nlen, - a.ndist, - a.distcode, - 0, - a.work, - E - )), - (a.distbits = E.bits), - x) - ) { - (t.msg = 'invalid distances set'), (a.mode = ze); - break; - } - if (((a.mode = 20), e === ue)) break t; - case 20: - a.mode = 21; - case 21: - if (l >= 6 && o >= 258) { - (t.next_out = r), - (t.avail_out = o), - (t.next_in = s), - (t.avail_in = l), - (a.hold = h), - (a.bits = d), - se(t, f), - (r = t.next_out), - (n = t.output), - (o = t.avail_out), - (s = t.next_in), - (i = t.input), - (l = t.avail_in), - (h = a.hold), - (d = a.bits), - a.mode === xe && (a.back = -1); - break; - } - for ( - a.back = 0; - (z = a.lencode[h & ((1 << a.lenbits) - 1)]), - (b = z >>> 24), - (g = (z >>> 16) & 255), - (p = 65535 & z), - !(b <= d); - - ) { - if (0 === l) break t; - l--, (h += i[s++] << d), (d += 8); - } - if (g && 0 == (240 & g)) { - for ( - m = b, k = g, v = p; - (z = - a.lencode[ - v + ((h & ((1 << (m + k)) - 1)) >> m) - ]), - (b = z >>> 24), - (g = (z >>> 16) & 255), - (p = 65535 & z), - !(m + b <= d); - - ) { - if (0 === l) break t; - l--, (h += i[s++] << d), (d += 8); - } - (h >>>= m), (d -= m), (a.back += m); - } - if ( - ((h >>>= b), - (d -= b), - (a.back += b), - (a.length = p), - 0 === g) - ) { - a.mode = 26; - break; - } - if (32 & g) { - (a.back = -1), (a.mode = xe); - break; - } - if (64 & g) { - (t.msg = 'invalid literal/length code'), - (a.mode = ze); - break; - } - (a.extra = 15 & g), (a.mode = 22); - case 22: - if (a.extra) { - for (R = a.extra; d < R; ) { - if (0 === l) break t; - l--, (h += i[s++] << d), (d += 8); - } - (a.length += h & ((1 << a.extra) - 1)), - (h >>>= a.extra), - (d -= a.extra), - (a.back += a.extra); - } - (a.was = a.length), (a.mode = 23); - case 23: - for ( ; - (z = a.distcode[h & ((1 << a.distbits) - 1)]), - (b = z >>> 24), - (g = (z >>> 16) & 255), - (p = 65535 & z), - !(b <= d); - - ) { - if (0 === l) break t; - l--, (h += i[s++] << d), (d += 8); - } - if (0 == (240 & g)) { - for ( - m = b, k = g, v = p; - (z = - a.distcode[ - v + ((h & ((1 << (m + k)) - 1)) >> m) - ]), - (b = z >>> 24), - (g = (z >>> 16) & 255), - (p = 65535 & z), - !(m + b <= d); - - ) { - if (0 === l) break t; - l--, (h += i[s++] << d), (d += 8); - } - (h >>>= m), (d -= m), (a.back += m); - } - if (((h >>>= b), (d -= b), (a.back += b), 64 & g)) { - (t.msg = 'invalid distance code'), (a.mode = ze); break; - } - (a.offset = p), (a.extra = 15 & g), (a.mode = 24); - case 24: - if (a.extra) { - for (R = a.extra; d < R; ) { - if (0 === l) break t; - l--, (h += i[s++] << d), (d += 8); - } - (a.offset += h & ((1 << a.extra) - 1)), - (h >>>= a.extra), - (d -= a.extra), - (a.back += a.extra); - } - if (a.offset > a.dmax) { - (t.msg = 'invalid distance too far back'), - (a.mode = ze); - break; - } - a.mode = 25; - case 25: - if (0 === o) break t; - if (((c = f - o), a.offset > c)) { - if (((c = a.offset - c), c > a.whave && a.sane)) { - (t.msg = 'invalid distance too far back'), - (a.mode = ze); - break; - } - c > a.wnext - ? ((c -= a.wnext), (u = a.wsize - c)) - : (u = a.wnext - c), - c > a.length && (c = a.length), - (w = a.window); - } else (w = n), (u = r - a.offset), (c = a.length); - c > o && (c = o), (o -= c), (a.length -= c); - do { - n[r++] = w[u++]; - } while (--c); - 0 === a.length && (a.mode = 21); - break; - case 26: - if (0 === o) break t; - (n[r++] = a.length), o--, (a.mode = 21); - break; - case 27: - if (a.wrap) { - for (; d < 32; ) { - if (0 === l) break t; - l--, (h |= i[s++] << d), (d += 8); - } - if ( - ((f -= o), - (t.total_out += f), - (a.total += f), - f && - (t.adler = a.check = - a.flags - ? M(a.check, n, f, r - f) - : B(a.check, n, f, r - f)), - (f = o), - (a.flags ? h : Ae(h)) !== a.check) - ) { - (t.msg = 'incorrect data check'), (a.mode = ze); - break; - } - (h = 0), (d = 0); - } - a.mode = 28; - case 28: - if (a.wrap && a.flags) { - for (; d < 32; ) { - if (0 === l) break t; - l--, (h += i[s++] << d), (d += 8); - } - if (h !== (4294967295 & a.total)) { - (t.msg = 'incorrect length check'), (a.mode = ze); - break; - } - (h = 0), (d = 0); - } - a.mode = 29; - case 29: - x = be; - break t; - case ze: - x = me; - break t; - case 31: - return ke; - case 32: - default: - return pe; - } - return ( - (t.next_out = r), - (t.avail_out = o), - (t.next_in = s), - (t.avail_in = l), - (a.hold = h), - (a.bits = d), - (a.wsize || - (f !== t.avail_out && - a.mode < ze && - (a.mode < 27 || e !== fe))) && - Fe(t, t.output, t.next_out, f - t.avail_out), - (_ -= t.avail_in), - (f -= t.avail_out), - (t.total_in += _), - (t.total_out += f), - (a.total += f), - a.wrap && - f && - (t.adler = a.check = - a.flags - ? M(a.check, n, f, t.next_out - f) - : B(a.check, n, f, t.next_out - f)), - (t.data_type = - a.bits + - (a.last ? 64 : 0) + - (a.mode === xe ? 128 : 0) + - (20 === a.mode || 15 === a.mode ? 256 : 0)), - ((0 === _ && 0 === f) || e === fe) && - x === we && - (x = ve), - x - ); - }, - inflateEnd: (t) => { - if (!t || !t.state) return pe; - let e = t.state; - return e.window && (e.window = null), (t.state = null), we; - }, - inflateGetHeader: (t, e) => { - if (!t || !t.state) return pe; - const a = t.state; - return 0 == (2 & a.wrap) - ? pe - : ((a.head = e), (e.done = !1), we); - }, - inflateSetDictionary: (t, e) => { - const a = e.length; - let i, n, s; - return t && t.state - ? ((i = t.state), - 0 !== i.wrap && 11 !== i.mode - ? pe - : 11 === i.mode && - ((n = 1), (n = B(n, e, a, 0)), n !== i.check) - ? me - : ((s = Fe(t, e, a, a)), - s ? ((i.mode = 31), ke) : ((i.havedict = 1), we))) - : pe; - }, - inflateInfo: 'pako inflate (from Nodeca project)', - }; - var Ne = function () { - (this.text = 0), - (this.time = 0), - (this.xflags = 0), - (this.os = 0), - (this.extra = null), - (this.extra_len = 0), - (this.name = ''), - (this.comment = ''), - (this.hcrc = 0), - (this.done = !1); - }; - const Be = Object.prototype.toString, - { - Z_NO_FLUSH: Ce, - Z_FINISH: Me, - Z_OK: He, - Z_STREAM_END: je, - Z_NEED_DICT: Ke, - Z_STREAM_ERROR: Pe, - Z_DATA_ERROR: Ye, - Z_MEM_ERROR: Ge, - } = j; - function Xe(t) { - this.options = Bt( - { chunkSize: 65536, windowBits: 15, to: '' }, - t || {} - ); - const e = this.options; - e.raw && - e.windowBits >= 0 && - e.windowBits < 16 && - ((e.windowBits = -e.windowBits), - 0 === e.windowBits && (e.windowBits = -15)), - !(e.windowBits >= 0 && e.windowBits < 16) || - (t && t.windowBits) || - (e.windowBits += 32), - e.windowBits > 15 && - e.windowBits < 48 && - 0 == (15 & e.windowBits) && - (e.windowBits |= 15), - (this.err = 0), - (this.msg = ''), - (this.ended = !1), - (this.chunks = []), - (this.strm = new Yt()), - (this.strm.avail_out = 0); - let a = Le.inflateInit2(this.strm, e.windowBits); - if (a !== He) throw new Error(H[a]); - if ( - ((this.header = new Ne()), - Le.inflateGetHeader(this.strm, this.header), - e.dictionary && - ('string' == typeof e.dictionary - ? (e.dictionary = jt(e.dictionary)) - : '[object ArrayBuffer]' === Be.call(e.dictionary) && - (e.dictionary = new Uint8Array(e.dictionary)), - e.raw && - ((a = Le.inflateSetDictionary(this.strm, e.dictionary)), - a !== He))) - ) - throw new Error(H[a]); - } - function We(t, e) { - const a = new Xe(e); - if ((a.push(t), a.err)) throw a.msg || H[a.err]; - return a.result; - } - (Xe.prototype.push = function (t, e) { - const a = this.strm, - i = this.options.chunkSize, - n = this.options.dictionary; - let s, r, l; - if (this.ended) return !1; - for ( - r = e === ~~e ? e : !0 === e ? Me : Ce, - '[object ArrayBuffer]' === Be.call(t) - ? (a.input = new Uint8Array(t)) - : (a.input = t), - a.next_in = 0, - a.avail_in = a.input.length; - ; - - ) { - for ( - 0 === a.avail_out && - ((a.output = new Uint8Array(i)), - (a.next_out = 0), - (a.avail_out = i)), - s = Le.inflate(a, r), - s === Ke && - n && - ((s = Le.inflateSetDictionary(a, n)), - s === He - ? (s = Le.inflate(a, r)) - : s === Ye && (s = Ke)); - a.avail_in > 0 && - s === je && - a.state.wrap > 0 && - 0 !== t[a.next_in]; - - ) - Le.inflateReset(a), (s = Le.inflate(a, r)); - switch (s) { - case Pe: - case Ye: - case Ke: - case Ge: - return this.onEnd(s), (this.ended = !0), !1; - } - if ( - ((l = a.avail_out), - a.next_out && (0 === a.avail_out || s === je)) - ) - if ('string' === this.options.to) { - let t = Pt(a.output, a.next_out), - e = a.next_out - t, - n = Kt(a.output, t); - (a.next_out = e), - (a.avail_out = i - e), - e && a.output.set(a.output.subarray(t, t + e), 0), - this.onData(n); - } else - this.onData( - a.output.length === a.next_out - ? a.output - : a.output.subarray(0, a.next_out) - ); - if (s !== He || 0 !== l) { - if (s === je) - return ( - (s = Le.inflateEnd(this.strm)), - this.onEnd(s), - (this.ended = !0), - !0 - ); - if (0 === a.avail_in) break; - } - } - return !0; - }), - (Xe.prototype.onData = function (t) { - this.chunks.push(t); - }), - (Xe.prototype.onEnd = function (t) { - t === He && - ('string' === this.options.to - ? (this.result = this.chunks.join('')) - : (this.result = Ct(this.chunks))), - (this.chunks = []), - (this.err = t), - (this.msg = this.strm.msg); - }); - var qe = { - Inflate: Xe, - inflate: We, - inflateRaw: function (t, e) { - return ((e = e || {}).raw = !0), We(t, e); - }, - ungzip: We, - constants: j, - }; - const { - Deflate: Je, - deflate: Qe, - deflateRaw: Ve, - gzip: $e, - } = ne, - { Inflate: ta, inflate: ea, inflateRaw: aa, ungzip: ia } = qe; - var na = Je, - sa = Qe, - ra = Ve, - la = $e, - oa = ta, - ha = ea, - da = aa, - _a = ia, - fa = j, - ca = { - Deflate: na, - deflate: sa, - deflateRaw: ra, - gzip: la, - Inflate: oa, - inflate: ha, - inflateRaw: da, - ungzip: _a, - constants: fa, - }; - (t.Deflate = na), - (t.Inflate = oa), - (t.constants = fa), - (t.default = ca), - (t.deflate = sa), - (t.deflateRaw = ra), - (t.gzip = la), - (t.inflate = ha), - (t.inflateRaw = da), - (t.ungzip = _a), - Object.defineProperty(t, '__esModule', { value: !0 }); - }); - /****************** initialization finish ******************/ - // 先拆分B站gRPC校验头和protobuf数据体 - let header = rawBody.slice(0, 5); - body = rawBody.slice(5); - // 处理response压缩protobuf数据体 - switch (header?.[0]) { - case 0: // unGzip - break; - case 1: // Gzip - body = pako.ungzip(body); - header[0] = 0; // unGzip - break; - } - // 解析链接并处理protobuf数据 - switch (HOST) { - case 'grpc.biliapi.net': // HTTP/2 - case 'app.bilibili.com': // HTTP/1.1 - /****************** initialization start *******************/ - // google.protobuf.Any - class Any$Type extends MessageType { - constructor() { - super('google.protobuf.Any', [ - { no: 1, name: 'type_url', kind: 'scalar', T: 9 }, - { no: 2, name: 'value', kind: 'scalar', T: 12 }, - ]); - } - pack(message, type) { - return { - typeUrl: this.typeNameToUrl(type.typeName), - value: type.toBinary(message), - }; - } - unpack(any, type, options) { - if (!this.contains(any, type)) - throw new Error( - "Cannot unpack google.protobuf.Any with typeUrl '" + - any.typeUrl + - "' as " + - type.typeName + - '.' - ); - return type.fromBinary(any.value, options); - } - contains(any, type) { - if (!any.typeUrl.length) return false; - let wants = - typeof type == 'string' ? type : type.typeName; - let has = this.typeUrlToName(any.typeUrl); - return wants === has; - } - internalJsonWrite(any, options) { - if (any.typeUrl === '') return {}; - let typeName = this.typeUrlToName(any.typeUrl); - let opt = jsonWriteOptions(options); - let type = opt.typeRegistry?.find( - (t) => t.typeName === typeName - ); - if (!type) - throw new globalThis.Error( - "Unable to convert google.protobuf.Any with typeUrl '" + - any.typeUrl + - "' to JSON. The specified type " + - typeName + - ' is not available in the type registry.' - ); - let value = type.fromBinary(any.value, { - readUnknownField: false, - }); - let json = type.internalJsonWrite(value, opt); - if ( - typeName.startsWith('google.protobuf.') || - !isJsonObject(json) - ) - json = { value: json }; - json['@type'] = any.typeUrl; - return json; - } - internalJsonRead(json, options, target) { - if (!isJsonObject(json)) - throw new globalThis.Error( - 'Unable to parse google.protobuf.Any from JSON ' + - typeofJsonValue(json) + - '.' - ); - if ( - typeof json['@type'] != 'string' || - json['@type'] == '' - ) - return this.create(); - let typeName = this.typeUrlToName(json['@type']); - let type = options?.typeRegistry?.find( - (t) => t.typeName == typeName - ); - if (!type) - throw new globalThis.Error( - 'Unable to parse google.protobuf.Any from JSON. The specified type ' + - typeName + - ' is not available in the type registry.' - ); - let value; - if ( - typeName.startsWith('google.protobuf.') && - json.hasOwnProperty('value') - ) - value = type.fromJson(json['value'], options); - else { - let copy = Object.assign({}, json); - delete copy['@type']; - value = type.fromJson(copy, options); - } - if (target === undefined) target = this.create(); - target.typeUrl = json['@type']; - target.value = type.toBinary(value); - return target; - } - typeNameToUrl(name) { - if (!name.length) - throw new Error('invalid type name: ' + name); - return 'type.googleapis.com/' + name; - } - typeUrlToName(url) { - if (!url.length) - throw new Error('invalid type url: ' + url); - let slash = url.lastIndexOf('/'); - let name = slash > 0 ? url.substring(slash + 1) : url; - if (!name.length) - throw new Error('invalid type url: ' + url); - return name; - } - create(value) { - const message = { typeUrl: '', value: new Uint8Array(0) }; - globalThis.Object.defineProperty(message, MESSAGE_TYPE, { - enumerable: false, - value: this, - }); - if (value !== undefined) - reflectionMergePartial(this, message, value); - return message; - } - internalBinaryRead(reader, length, options, target) { - let message = target ?? this.create(), - end = reader.pos + length; - while (reader.pos < end) { - let [fieldNo, wireType] = reader.tag(); - switch (fieldNo) { - case 1: - message.typeUrl = reader.string(); - break; - case 2: - message.value = reader.bytes(); - break; - default: - let u = options.readUnknownField; - if (u === 'throw') - throw new globalThis.Error( - `Unknown field ${fieldNo}(wire type ${wireType})for ${this.typeName}` - ); - let d = reader.skip(wireType); - if (u !== false) - (u === true ? UnknownFieldHandler.onRead : u)( - this.typeName, - message, - fieldNo, - wireType, - d - ); - } - } - return message; - } - internalBinaryWrite(message, writer, options) { - if (message.typeUrl !== '') - writer - .tag(1, WireType.LengthDelimited) - .string(message.typeUrl); - if (message.value.length) - writer - .tag(2, WireType.LengthDelimited) - .bytes(message.value); - let u = options.writeUnknownFields; - if (u !== false) - (u == true ? UnknownFieldHandler.onWrite : u)( - this.typeName, - message, - writer - ); - return writer; - } - } - const Any = new Any$Type(); - // CM 广告 - class CM$Type extends MessageType { - constructor() { - super('CM', [ - { - no: 1, - name: 'source_content', - kind: 'message', - T: () => Any, - }, - ]); - } - create(value) { - const message = {}; - globalThis.Object.defineProperty(message, MESSAGE_TYPE, { - enumerable: false, - value: this, - }); - if (value !== undefined) - reflectionMergePartial(this, message, value); - return message; - } - internalBinaryRead(reader, length, options, target) { - let message = target ?? this.create(), - end = reader.pos + length; - while (reader.pos < end) { - let [fieldNo, wireType] = reader.tag(); - switch (fieldNo) { - case 1: - message.sourceContent = Any.internalBinaryRead( - reader, - reader.uint32(), - options, - message.sourceContent - ); - break; - default: - let u = options.readUnknownField; - if (u === 'throw') - throw new globalThis.Error( - `Unknown field ${fieldNo}(wire type ${wireType})for ${this.typeName}` - ); - let d = reader.skip(wireType); - if (u !== false) - (u === true ? UnknownFieldHandler.onRead : u)( - this.typeName, - message, - fieldNo, - wireType, - d - ); - } - } - return message; - } - internalBinaryWrite(message, writer, options) { - if (message.sourceContent) - Any.internalBinaryWrite( - message.sourceContent, - writer.tag(1, WireType.LengthDelimited).fork(), - options - ).join(); - let u = options.writeUnknownFields; - if (u !== false) - (u == true ? UnknownFieldHandler.onWrite : u)( - this.typeName, - message, - writer - ); - return writer; - } - } - const CM = new CM$Type(); - /****************** initialization finish ******************/ - switch (PATHs?.[0]) { - case 'bilibili.app.playurl.v1.PlayURL': // 投稿视频 - switch (PATHs?.[1]) { - case 'PlayView': // 播放地址 - /****************** initialization start *******************/ - // protobuf/bilibili/app/playurl/playurl.proto - class PlayViewReply$Type extends MessageType { - constructor() { - super('PlayViewReply', [ - { - no: 5, - name: 'play_arc', - kind: 'message', - T: () => PlayArcConf, - }, - ]); - } - create(value) { - const message = {}; - globalThis.Object.defineProperty( - message, - MESSAGE_TYPE, - { enumerable: false, value: this } - ); - if (value !== undefined) - reflectionMergePartial(this, message, value); - return message; - } - internalBinaryRead( - reader, - length, - options, - target - ) { - let message = target ?? this.create(), - end = reader.pos + length; - while (reader.pos < end) { - let [fieldNo, wireType] = reader.tag(); - switch (fieldNo) { - case 5: - message.playArc = - PlayArcConf.internalBinaryRead( - reader, - reader.uint32(), - options, - message.playArc - ); + case "api.bilibili.com": + case "api.biliapi.net": + switch (PATH) { + case "pgc/player/api/playurl": // 番剧-播放地址-api + case "pgc/player/web/playurl": // 番剧-播放地址-web + case "pgc/player/web/playurl/html5": // 番剧-播放地址-web-HTML5 break; - default: - let u = options.readUnknownField; - if (u === 'throw') - throw new globalThis.Error( - `Unknown field ${fieldNo}(wire type ${wireType})for ${this.typeName}` - ); - let d = reader.skip(wireType); - if (u !== false) - (u === true - ? UnknownFieldHandler.onRead - : u)( - this.typeName, - message, - fieldNo, - wireType, - d - ); - } - } - return message; - } - internalBinaryWrite(message, writer, options) { - if (message.playArc) - PlayArcConf.internalBinaryWrite( - message.playArc, - writer - .tag(5, WireType.LengthDelimited) - .fork(), - options - ).join(); - let u = options.writeUnknownFields; - if (u !== false) - (u == true ? UnknownFieldHandler.onWrite : u)( - this.typeName, - message, - writer - ); - return writer; - } - } - const PlayViewReply = new PlayViewReply$Type(); - class PlayArcConf$Type extends MessageType { - constructor() { - super('PlayArcConf', [ - { - no: 1, - name: 'background_play_conf', - kind: 'message', - T: () => ArcConf, - }, - ]); - } - create(value) { - const message = {}; - globalThis.Object.defineProperty( - message, - MESSAGE_TYPE, - { enumerable: false, value: this } - ); - if (value !== undefined) - reflectionMergePartial(this, message, value); - return message; - } - internalBinaryRead( - reader, - length, - options, - target - ) { - let message = target ?? this.create(), - end = reader.pos + length; - while (reader.pos < end) { - let [fieldNo, wireType] = reader.tag(); - switch (fieldNo) { - case 1: - message.backgroundPlayConf = - ArcConf.internalBinaryRead( - reader, - reader.uint32(), - options, - message.backgroundPlayConf - ); + case "pgc/view/v2/app/season": // 番剧页面-内容-app break; - default: - let u = options.readUnknownField; - if (u === 'throw') - throw new globalThis.Error( - `Unknown field ${fieldNo}(wire type ${wireType})for ${this.typeName}` - ); - let d = reader.skip(wireType); - if (u !== false) - (u === true - ? UnknownFieldHandler.onRead - : u)( - this.typeName, - message, - fieldNo, - wireType, - d - ); - } - } - return message; - } - internalBinaryWrite(message, writer, options) { - if (message.backgroundPlayConf) - ArcConf.internalBinaryWrite( - message.backgroundPlayConf, - writer - .tag(1, WireType.LengthDelimited) - .fork(), - options - ).join(); - let u = options.writeUnknownFields; - if (u !== false) - (u == true ? UnknownFieldHandler.onWrite : u)( - this.typeName, - message, - writer - ); - return writer; - } - } - const PlayArcConf = new PlayArcConf$Type(); - class ArcConf$Type extends MessageType { - constructor() { - super('ArcConf', [ - { - no: 1, - name: 'is_support', - kind: 'scalar', - T: 8, - }, - { - no: 2, - name: 'disabled', - kind: 'scalar', - T: 8, - }, - { - no: 3, - name: 'extra_content', - kind: 'message', - T: () => ExtraContent, - }, - ]); - } - create(value) { - const message = { - isSupport: false, - disabled: false, - }; - globalThis.Object.defineProperty( - message, - MESSAGE_TYPE, - { enumerable: false, value: this } - ); - if (value !== undefined) - reflectionMergePartial(this, message, value); - return message; - } - internalBinaryRead( - reader, - length, - options, - target - ) { - let message = target ?? this.create(), - end = reader.pos + length; - while (reader.pos < end) { - let [fieldNo, wireType] = reader.tag(); - switch (fieldNo) { - case 1: - message.isSupport = reader.bool(); + case "pgc/view/web/season": // 番剧-内容-web + case "pgc/view/pc/season": // 番剧-内容-pc break; - case 2: - message.disabled = reader.bool(); - break; - case 3: - message.extraContent = - ExtraContent.internalBinaryRead( - reader, - reader.uint32(), - options, - message.extraContent - ); - break; - default: - let u = options.readUnknownField; - if (u === 'throw') - throw new globalThis.Error( - `Unknown field ${fieldNo}(wire type ${wireType})for ${this.typeName}` - ); - let d = reader.skip(wireType); - if (u !== false) - (u === true - ? UnknownFieldHandler.onRead - : u)( - this.typeName, - message, - fieldNo, - wireType, - d - ); - } - } - return message; - } - internalBinaryWrite(message, writer, options) { - if (message.isSupport !== false) - writer - .tag(1, WireType.Varint) - .bool(message.isSupport); - if (message.disabled !== false) - writer - .tag(2, WireType.Varint) - .bool(message.disabled); - if (message.extraContent) - ExtraContent.internalBinaryWrite( - message.extraContent, - writer - .tag(3, WireType.LengthDelimited) - .fork(), - options - ).join(); - let u = options.writeUnknownFields; - if (u !== false) - (u == true ? UnknownFieldHandler.onWrite : u)( - this.typeName, - message, - writer - ); - return writer; - } - } - const ArcConf = new ArcConf$Type(); - class ExtraContent$Type extends MessageType { - constructor() { - super('ExtraContent', [ - { - no: 1, - name: 'disabled_reason', - kind: 'scalar', - T: 9, - }, - { - no: 2, - name: 'disabled_code', - kind: 'scalar', - T: 3, - L: 0, - }, - ]); - } - create(value) { - const message = { - disabledReason: '', - disabledCode: 0n, - }; - globalThis.Object.defineProperty( - message, - MESSAGE_TYPE, - { enumerable: false, value: this } - ); - if (value !== undefined) - reflectionMergePartial(this, message, value); - return message; - } - internalBinaryRead( - reader, - length, - options, - target - ) { - let message = target ?? this.create(), - end = reader.pos + length; - while (reader.pos < end) { - let [fieldNo, wireType] = reader.tag(); - switch (fieldNo) { - case 1: - message.disabledReason = reader.string(); - break; - case 2: - message.disabledCode = reader - .int64() - .toBigInt(); - break; - default: - let u = options.readUnknownField; - if (u === 'throw') - throw new globalThis.Error( - `Unknown field ${fieldNo}(wire type ${wireType})for ${this.typeName}` - ); - let d = reader.skip(wireType); - if (u !== false) - (u === true - ? UnknownFieldHandler.onRead - : u)( - this.typeName, - message, - fieldNo, - wireType, - d - ); - } - } - return message; - } - internalBinaryWrite(message, writer, options) { - if (message.disabledReason !== '') - writer - .tag(1, WireType.LengthDelimited) - .string(message.disabledReason); - if (message.disabledCode !== 0n) - writer - .tag(2, WireType.Varint) - .int64(message.disabledCode); - let u = options.writeUnknownFields; - if (u !== false) - (u == true ? UnknownFieldHandler.onWrite : u)( - this.typeName, - message, - writer - ); - return writer; - } - } - const ExtraContent = new ExtraContent$Type(); - /****************** initialization finish ******************/ - let data = PlayViewReply.fromBinary(body); - const oldBackgroundConf = - data.playArc?.backgroundPlayConf; - if ( - oldBackgroundConf && - (!oldBackgroundConf.isSupport || - oldBackgroundConf.disabled) - ) { - $.log(`🎉 ${$.name}`, '后台播放限制去除'); - data.playArc.backgroundPlayConf.isSupport = true; - data.playArc.backgroundPlayConf.disabled = false; - data.playArc.backgroundPlayConf.extraContent = null; - } else { - $.log(`🚧 ${$.name}`, '无后台播放限制'); - } - body = PlayViewReply.toBinary(data); - break; - case 'PlayConf': // 播放配置 - break; - } - break; - case 'bilibili.app.dynamic.v2.Dynamic': // 动态 - /****************** initialization start *******************/ - // protobuf/bilibili/app/dynamic/dynamic.proto - var DynamicType; - (function (DynamicType) { - DynamicType[(DynamicType['dyn_none'] = 0)] = 'dyn_none'; - DynamicType[(DynamicType['ad'] = 15)] = 'ad'; - })(DynamicType || (DynamicType = {})); - class DynAllReply$Type extends MessageType { - constructor() { - super('DynAllReply', [ - { - no: 1, - name: 'dynamic_list', - kind: 'message', - T: () => DynamicList, - }, - { - no: 2, - name: 'up_list', - kind: 'message', - T: () => CardVideoUpList, - }, - { - no: 3, - name: 'topic_list', - kind: 'message', - T: () => TopicList, - }, - ]); - } - create(value) { - const message = {}; - globalThis.Object.defineProperty( - message, - MESSAGE_TYPE, - { enumerable: false, value: this } - ); - if (value !== undefined) - reflectionMergePartial(this, message, value); - return message; - } - internalBinaryRead(reader, length, options, target) { - let message = target ?? this.create(), - end = reader.pos + length; - while (reader.pos < end) { - let [fieldNo, wireType] = reader.tag(); - switch (fieldNo) { - case 1: - message.dynamicList = - DynamicList.internalBinaryRead( - reader, - reader.uint32(), - options, - message.dynamicList - ); - break; - case 2: - message.upList = - CardVideoUpList.internalBinaryRead( - reader, - reader.uint32(), - options, - message.upList - ); - break; - case 3: - message.topicList = - TopicList.internalBinaryRead( - reader, - reader.uint32(), - options, - message.topicList - ); - break; - default: - let u = options.readUnknownField; - if (u === 'throw') - throw new globalThis.Error( - `Unknown field ${fieldNo}(wire type ${wireType})for ${this.typeName}` - ); - let d = reader.skip(wireType); - if (u !== false) - (u === true ? UnknownFieldHandler.onRead : u)( - this.typeName, - message, - fieldNo, - wireType, - d - ); - } - } - return message; - } - internalBinaryWrite(message, writer, options) { - if (message.dynamicList) - DynamicList.internalBinaryWrite( - message.dynamicList, - writer.tag(1, WireType.LengthDelimited).fork(), - options - ).join(); - if (message.upList) - CardVideoUpList.internalBinaryWrite( - message.upList, - writer.tag(2, WireType.LengthDelimited).fork(), - options - ).join(); - if (message.topicList) - TopicList.internalBinaryWrite( - message.topicList, - writer.tag(3, WireType.LengthDelimited).fork(), - options - ).join(); - let u = options.writeUnknownFields; - if (u !== false) - (u == true ? UnknownFieldHandler.onWrite : u)( - this.typeName, - message, - writer - ); - return writer; - } - } - const DynAllReply = new DynAllReply$Type(); - class DynVideoReply$Type extends MessageType { - constructor() { - super('DynVideoReply', [ - { - no: 2, - name: 'video_up_list', - kind: 'message', - T: () => CardVideoUpList, - }, - ]); - } - create(value) { - const message = {}; - globalThis.Object.defineProperty( - message, - MESSAGE_TYPE, - { enumerable: false, value: this } - ); - if (value !== undefined) - reflectionMergePartial(this, message, value); - return message; - } - internalBinaryRead(reader, length, options, target) { - let message = target ?? this.create(), - end = reader.pos + length; - while (reader.pos < end) { - let [fieldNo, wireType] = reader.tag(); - switch (fieldNo) { - case 2: - message.videoUpList = - CardVideoUpList.internalBinaryRead( - reader, - reader.uint32(), - options, - message.videoUpList - ); - break; - default: - let u = options.readUnknownField; - if (u === 'throw') - throw new globalThis.Error( - `Unknown field ${fieldNo}(wire type ${wireType})for ${this.typeName}` - ); - let d = reader.skip(wireType); - if (u !== false) - (u === true ? UnknownFieldHandler.onRead : u)( - this.typeName, - message, - fieldNo, - wireType, - d - ); - } - } - return message; - } - internalBinaryWrite(message, writer, options) { - if (message.videoUpList) - CardVideoUpList.internalBinaryWrite( - message.videoUpList, - writer.tag(2, WireType.LengthDelimited).fork(), - options - ).join(); - let u = options.writeUnknownFields; - if (u !== false) - (u == true ? UnknownFieldHandler.onWrite : u)( - this.typeName, - message, - writer - ); - return writer; - } - } - const DynVideoReply = new DynVideoReply$Type(); - class DynamicList$Type extends MessageType { - constructor() { - super('DynamicList', [ - { - no: 1, - name: 'list', - kind: 'message', - repeat: 1, - T: () => DynamicItem, - }, - ]); - } - create(value) { - const message = { list: [] }; - globalThis.Object.defineProperty( - message, - MESSAGE_TYPE, - { enumerable: false, value: this } - ); - if (value !== undefined) - reflectionMergePartial(this, message, value); - return message; - } - internalBinaryRead(reader, length, options, target) { - let message = target ?? this.create(), - end = reader.pos + length; - while (reader.pos < end) { - let [fieldNo, wireType] = reader.tag(); - switch (fieldNo) { - case 1: - message.list.push( - DynamicItem.internalBinaryRead( - reader, - reader.uint32(), - options - ) - ); - break; - default: - let u = options.readUnknownField; - if (u === 'throw') - throw new globalThis.Error( - `Unknown field ${fieldNo}(wire type ${wireType})for ${this.typeName}` - ); - let d = reader.skip(wireType); - if (u !== false) - (u === true ? UnknownFieldHandler.onRead : u)( - this.typeName, - message, - fieldNo, - wireType, - d - ); - } - } - return message; - } - internalBinaryWrite(message, writer, options) { - for (let i = 0; i < message.list.length; i++) - DynamicItem.internalBinaryWrite( - message.list[i], - writer.tag(1, WireType.LengthDelimited).fork(), - options - ).join(); - let u = options.writeUnknownFields; - if (u !== false) - (u == true ? UnknownFieldHandler.onWrite : u)( - this.typeName, - message, - writer - ); - return writer; - } - } - const DynamicList = new DynamicList$Type(); - class CardVideoUpList$Type extends MessageType { - constructor() { - super('CardVideoUpList', [ - { no: 1, name: 'title', kind: 'scalar', T: 9 }, - ]); - } - create(value) { - const message = { title: '' }; - globalThis.Object.defineProperty( - message, - MESSAGE_TYPE, - { enumerable: false, value: this } - ); - if (value !== undefined) - reflectionMergePartial(this, message, value); - return message; - } - internalBinaryRead(reader, length, options, target) { - let message = target ?? this.create(), - end = reader.pos + length; - while (reader.pos < end) { - let [fieldNo, wireType] = reader.tag(); - switch (fieldNo) { - case 1: - message.title = reader.string(); - break; - default: - let u = options.readUnknownField; - if (u === 'throw') - throw new globalThis.Error( - `Unknown field ${fieldNo}(wire type ${wireType})for ${this.typeName}` - ); - let d = reader.skip(wireType); - if (u !== false) - (u === true ? UnknownFieldHandler.onRead : u)( - this.typeName, - message, - fieldNo, - wireType, - d - ); - } - } - return message; - } - internalBinaryWrite(message, writer, options) { - if (message.title !== '') - writer - .tag(1, WireType.LengthDelimited) - .string(message.title); - let u = options.writeUnknownFields; - if (u !== false) - (u == true ? UnknownFieldHandler.onWrite : u)( - this.typeName, - message, - writer - ); - return writer; - } - } - const CardVideoUpList = new CardVideoUpList$Type(); - class TopicList$Type extends MessageType { - constructor() { - super('TopicList', [ - { no: 1, name: 'title', kind: 'scalar', T: 9 }, - ]); - } - create(value) { - const message = { title: '' }; - globalThis.Object.defineProperty( - message, - MESSAGE_TYPE, - { enumerable: false, value: this } - ); - if (value !== undefined) - reflectionMergePartial(this, message, value); - return message; - } - internalBinaryRead(reader, length, options, target) { - let message = target ?? this.create(), - end = reader.pos + length; - while (reader.pos < end) { - let [fieldNo, wireType] = reader.tag(); - switch (fieldNo) { - case 1: - message.title = reader.string(); - break; - default: - let u = options.readUnknownField; - if (u === 'throw') - throw new globalThis.Error( - `Unknown field ${fieldNo}(wire type ${wireType})for ${this.typeName}` - ); - let d = reader.skip(wireType); - if (u !== false) - (u === true ? UnknownFieldHandler.onRead : u)( - this.typeName, - message, - fieldNo, - wireType, - d - ); - } - } - return message; - } - internalBinaryWrite(message, writer, options) { - if (message.title !== '') - writer - .tag(1, WireType.LengthDelimited) - .string(message.title); - let u = options.writeUnknownFields; - if (u !== false) - (u == true ? UnknownFieldHandler.onWrite : u)( - this.typeName, - message, - writer - ); - return writer; - } - } - const TopicList = new TopicList$Type(); - class DynamicItem$Type extends MessageType { - constructor() { - super('DynamicItem', [ - { - no: 1, - name: 'card_type', - kind: 'enum', - T: () => ['DynamicType', DynamicType], - }, - ]); - } - create(value) { - const message = { cardType: 0 }; - globalThis.Object.defineProperty( - message, - MESSAGE_TYPE, - { enumerable: false, value: this } - ); - if (value !== undefined) - reflectionMergePartial(this, message, value); - return message; - } - internalBinaryRead(reader, length, options, target) { - let message = target ?? this.create(), - end = reader.pos + length; - while (reader.pos < end) { - let [fieldNo, wireType] = reader.tag(); - switch (fieldNo) { - case 1: - message.cardType = reader.int32(); - break; - default: - let u = options.readUnknownField; - if (u === 'throw') - throw new globalThis.Error( - `Unknown field ${fieldNo}(wire type ${wireType})for ${this.typeName}` - ); - let d = reader.skip(wireType); - if (u !== false) - (u === true ? UnknownFieldHandler.onRead : u)( - this.typeName, - message, - fieldNo, - wireType, - d - ); - } - } - return message; - } - internalBinaryWrite(message, writer, options) { - if (message.cardType !== 0) - writer - .tag(1, WireType.Varint) - .int32(message.cardType); - let u = options.writeUnknownFields; - if (u !== false) - (u == true ? UnknownFieldHandler.onWrite : u)( - this.typeName, - message, - writer - ); - return writer; - } - } - const DynamicItem = new DynamicItem$Type(); - /****************** initialization finish ******************/ - switch (PATHs?.[1]) { - case 'DynAll': // 动态综合页 - data = DynAllReply.fromBinary(body); - switch (Settings?.Detail?.Hot_topics) { - case true: - default: - if (data.topicList) { - data.topicList = null; - $.log(`🎉 ${$.name}`, '动态综合页热门话题去除'); - } - break; - case false: - $.log( - `🚧 ${$.name}`, - '用户设置动态综合页热门话题不去除' - ); - break; - } - switch (Settings?.Detail?.Most_visited) { - case true: - default: - if (data.upList) { - data.upList = null; - $.log(`🎉 ${$.name}`, '动态综合页最常访问去除'); - } - break; - case false: - $.log( - `🚧 ${$.name}`, - '用户设置动态综合页最常访问不去除' - ); - break; - } - switch (Settings?.Detail?.Dynamic_adcard) { - case true: - default: - if (data.dynamicList?.list?.length) { - data.dynamicList.list = - data.dynamicList.list.filter((item) => { - if (item.cardType !== 15) { - return true; + case "pgc/page/bangumi": // 追番页 + case "pgc/page/cinema/tab": // 观影页 + switch (Settings?.Detail?.cinema) { + case true: + default: + if (body.result?.modules) { + body.result.modules.forEach((i) => { + if (i.style.startsWith("banner")) { + i.items = i.items.filter((j) => j.link.includes("play")); + } else if (i.style.startsWith("function")) { + i.items = i.items.filter((j) => j.blink.startsWith("bilibili")); + } else if ([241, 1283, 1284, 1441].includes(i.module_id)) { + i.items = []; + } else if (i.style.startsWith("tip")) { + i.items = []; + } + }); + $.log(`🎉 ${$.name}`, "观影页广告去除"); + } + break; + case false: + $.log(`🚧 ${$.name}`, "用户设置观影页广告不去除"); + break; } - $.log( - `🎉 ${$.name}`, - '动态综合页广告动态去除' - ); - return false; - }); - } - break; - case false: - $.log( - `🚧 ${$.name}`, - '用户设置动态综合页广告动态不去除' - ); - break; - } - body = DynAllReply.toBinary(data); - break; - case 'DynVideo': // 动态视频页 - data = DynVideoReply.fromBinary(body); - switch (Settings?.Detail?.Most_visited) { - case true: + ; + break; + case "x/player/wbi/playurl": // UGC-用户生产内容-播放地址 + break; + case "x/web-interface/wbi/index/top/feed/rcmd": // web首页 + switch (Settings?.Detail?.feed) { + case true: + default: + body.data.item = body.data.item.filter((i) => !(i.goto === "ad")); + $.log(`🎉 ${$.name}`, "首页广告内容去除"); + break; + case false: + $.log(`🚧 ${$.name}`, "用户设置首页广告不去除"); + break; + } + ; + break; + case "x/space/acc/info": // 用户空间-账号信息-pc + case "x/space/wbi/acc/info": // 用户空间-账号信息-wbi + switch (url.query?.vmid || url.query?.mid) { + case "11783021": // 哔哩哔哩番剧出差 + case "1988098633": // b站_戲劇咖 + case "2042149112": // b站_綜藝咖 + break; + default: + break; + } + ; + break; + } + ; + break; + case "api.live.bilibili.com": + switch (PATH) { + case "xlive/app-room/v1/index/getInfoByRoom": // 直播 + switch (Settings?.Detail?.xlive) { + case true: + default: + if (body.data?.activity_banner_info) { + body.data.activity_banner_info = null; + $.log(`🎉 ${$.name}`, "直播banner广告去除"); + } + if (body.data?.shopping_info) { + body.data.shopping_info = { + is_show: 0 + }; + $.log(`🎉 ${$.name}`, "直播购物广告去除"); + } + if (body.data?.new_tab_info?.outer_list?.length > 0) { + body.data.new_tab_info.outer_list = + body.data.new_tab_info.outer_list.filter((i) => i.biz_id !== 33); + } + break; + case false: + $.log(`🚧 ${$.name}`, "用户设置直播页广告不去除"); + break; + } + ; + break; + } + ; + break; + } + ; + $response.body = JSON.stringify(body); + break; + case "application/x-protobuf": + case "application/grpc": + case "application/grpc+proto": + case "applecation/octet-stream": + let rawBody = $.isQuanX() ? new Uint8Array($response.bodyBytes) : $response.body; + //$.log(`🚧 ${$.name}`, `isBuffer? ${ArrayBuffer.isView(rawBody)}: ${JSON.stringify(rawBody)}`, ""); + /****************** initialization start *******************/ + // timostamm/protobuf-ts + !function (i) { + "use strict"; + + function _(n, e, i) { + return e <= n && n <= i + } + + "undefined" != typeof module && module.exports && !i["encoding-indexes"] && (i["encoding-indexes"] = require("./encoding-indexes.js")["encoding-indexes"]); + var l = Math.floor; + + function s(n) { + if (void 0 === n) return {}; + if (n === Object(n)) return n; + throw TypeError("Could not convert argument to dictionary") + } + + function u(n) { + return 0 <= n && n <= 127 + } + + var a = u, b = -1; + + function c(n) { + this.tokens = [].slice.call(n), this.tokens.reverse() + } + + c.prototype = { + endOfStream: function () { + return !this.tokens.length + }, read: function () { + return this.tokens.length ? this.tokens.pop() : b + }, prepend: function (n) { + if (Array.isArray(n)) for (var e = n; e.length;) this.tokens.push(e.pop()); else this.tokens.push(n) + }, push: function (n) { + if (Array.isArray(n)) for (var e = n; e.length;) this.tokens.unshift(e.shift()); else this.tokens.unshift(n) + } + }; + var w = -1; + + function m(n, e) { + if (n) throw TypeError("Decoder error"); + return e || 65533 + } + + function f(n) { + throw TypeError("The code point " + n + " could not be encoded.") + } + + function r(n) { + return n = String(n).trim().toLowerCase(), Object.prototype.hasOwnProperty.call(d, n) ? d[n] : null + } + + var t, o, n = [{ + encodings: [{labels: ["unicode-1-1-utf-8", "utf-8", "utf8"], name: "UTF-8"}], + heading: "The Encoding" + }, { + encodings: [{ + labels: ["866", "cp866", "csibm866", "ibm866"], + name: "IBM866" + }, { + labels: ["csisolatin2", "iso-8859-2", "iso-ir-101", "iso8859-2", "iso88592", "iso_8859-2", "iso_8859-2:1987", "l2", "latin2"], + name: "ISO-8859-2" + }, { + labels: ["csisolatin3", "iso-8859-3", "iso-ir-109", "iso8859-3", "iso88593", "iso_8859-3", "iso_8859-3:1988", "l3", "latin3"], + name: "ISO-8859-3" + }, { + labels: ["csisolatin4", "iso-8859-4", "iso-ir-110", "iso8859-4", "iso88594", "iso_8859-4", "iso_8859-4:1988", "l4", "latin4"], + name: "ISO-8859-4" + }, { + labels: ["csisolatincyrillic", "cyrillic", "iso-8859-5", "iso-ir-144", "iso8859-5", "iso88595", "iso_8859-5", "iso_8859-5:1988"], + name: "ISO-8859-5" + }, { + labels: ["arabic", "asmo-708", "csiso88596e", "csiso88596i", "csisolatinarabic", "ecma-114", "iso-8859-6", "iso-8859-6-e", "iso-8859-6-i", "iso-ir-127", "iso8859-6", "iso88596", "iso_8859-6", "iso_8859-6:1987"], + name: "ISO-8859-6" + }, { + labels: ["csisolatingreek", "ecma-118", "elot_928", "greek", "greek8", "iso-8859-7", "iso-ir-126", "iso8859-7", "iso88597", "iso_8859-7", "iso_8859-7:1987", "sun_eu_greek"], + name: "ISO-8859-7" + }, { + labels: ["csiso88598e", "csisolatinhebrew", "hebrew", "iso-8859-8", "iso-8859-8-e", "iso-ir-138", "iso8859-8", "iso88598", "iso_8859-8", "iso_8859-8:1988", "visual"], + name: "ISO-8859-8" + }, { + labels: ["csiso88598i", "iso-8859-8-i", "logical"], + name: "ISO-8859-8-I" + }, { + labels: ["csisolatin6", "iso-8859-10", "iso-ir-157", "iso8859-10", "iso885910", "l6", "latin6"], + name: "ISO-8859-10" + }, { + labels: ["iso-8859-13", "iso8859-13", "iso885913"], + name: "ISO-8859-13" + }, { + labels: ["iso-8859-14", "iso8859-14", "iso885914"], + name: "ISO-8859-14" + }, { + labels: ["csisolatin9", "iso-8859-15", "iso8859-15", "iso885915", "iso_8859-15", "l9"], + name: "ISO-8859-15" + }, { + labels: ["iso-8859-16"], + name: "ISO-8859-16" + }, { + labels: ["cskoi8r", "koi", "koi8", "koi8-r", "koi8_r"], + name: "KOI8-R" + }, { + labels: ["koi8-ru", "koi8-u"], + name: "KOI8-U" + }, { + labels: ["csmacintosh", "mac", "macintosh", "x-mac-roman"], + name: "macintosh" + }, { + labels: ["dos-874", "iso-8859-11", "iso8859-11", "iso885911", "tis-620", "windows-874"], + name: "windows-874" + }, { + labels: ["cp1250", "windows-1250", "x-cp1250"], + name: "windows-1250" + }, { + labels: ["cp1251", "windows-1251", "x-cp1251"], + name: "windows-1251" + }, { + labels: ["ansi_x3.4-1968", "ascii", "cp1252", "cp819", "csisolatin1", "ibm819", "iso-8859-1", "iso-ir-100", "iso8859-1", "iso88591", "iso_8859-1", "iso_8859-1:1987", "l1", "latin1", "us-ascii", "windows-1252", "x-cp1252"], + name: "windows-1252" + }, { + labels: ["cp1253", "windows-1253", "x-cp1253"], + name: "windows-1253" + }, { + labels: ["cp1254", "csisolatin5", "iso-8859-9", "iso-ir-148", "iso8859-9", "iso88599", "iso_8859-9", "iso_8859-9:1989", "l5", "latin5", "windows-1254", "x-cp1254"], + name: "windows-1254" + }, { + labels: ["cp1255", "windows-1255", "x-cp1255"], + name: "windows-1255" + }, { + labels: ["cp1256", "windows-1256", "x-cp1256"], + name: "windows-1256" + }, { + labels: ["cp1257", "windows-1257", "x-cp1257"], + name: "windows-1257" + }, { + labels: ["cp1258", "windows-1258", "x-cp1258"], + name: "windows-1258" + }, {labels: ["x-mac-cyrillic", "x-mac-ukrainian"], name: "x-mac-cyrillic"}], + heading: "Legacy single-byte encodings" + }, { + encodings: [{ + labels: ["chinese", "csgb2312", "csiso58gb231280", "gb2312", "gb_2312", "gb_2312-80", "gbk", "iso-ir-58", "x-gbk"], + name: "GBK" + }, {labels: ["gb18030"], name: "gb18030"}], + heading: "Legacy multi-byte Chinese (simplified) encodings" + }, { + encodings: [{ + labels: ["big5", "big5-hkscs", "cn-big5", "csbig5", "x-x-big5"], + name: "Big5" + }], heading: "Legacy multi-byte Chinese (traditional) encodings" + }, { + encodings: [{ + labels: ["cseucpkdfmtjapanese", "euc-jp", "x-euc-jp"], + name: "EUC-JP" + }, { + labels: ["csiso2022jp", "iso-2022-jp"], + name: "ISO-2022-JP" + }, { + labels: ["csshiftjis", "ms932", "ms_kanji", "shift-jis", "shift_jis", "sjis", "windows-31j", "x-sjis"], + name: "Shift_JIS" + }], heading: "Legacy multi-byte Japanese encodings" + }, { + encodings: [{ + labels: ["cseuckr", "csksc56011987", "euc-kr", "iso-ir-149", "korean", "ks_c_5601-1987", "ks_c_5601-1989", "ksc5601", "ksc_5601", "windows-949"], + name: "EUC-KR" + }], heading: "Legacy multi-byte Korean encodings" + }, { + encodings: [{ + labels: ["csiso2022kr", "hz-gb-2312", "iso-2022-cn", "iso-2022-cn-ext", "iso-2022-kr"], + name: "replacement" + }, {labels: ["utf-16be"], name: "UTF-16BE"}, { + labels: ["utf-16", "utf-16le"], + name: "UTF-16LE" + }, {labels: ["x-user-defined"], name: "x-user-defined"}], + heading: "Legacy miscellaneous encodings" + }], d = {}, h = (n.forEach(function (n) { + n.encodings.forEach(function (e) { + e.labels.forEach(function (n) { + d[n] = e + }) + }) + }), {}), g = {}; + + function y(n, e) { + return e && e[n] || null + } + + function p(n, e) { + e = e.indexOf(n); + return -1 === e ? null : e + } + + function v(n) { + if ("encoding-indexes" in i) return i["encoding-indexes"][n]; + throw Error("Indexes missing. Did you forget to include encoding-indexes.js first?") + } + + var x = "utf-8"; + + function O(n, e) { + if (!(this instanceof O)) throw TypeError("Called as a function. Did you forget 'new'?"); + n = void 0 !== n ? String(n) : x, e = s(e), this._encoding = null, this._decoder = null, this._ignoreBOM = !1, this._BOMseen = !1, this._error_mode = "replacement", this._do_not_flush = !1; + var i = r(n); + if (null === i || "replacement" === i.name) throw RangeError("Unknown encoding: " + n); + if (g[i.name]) return (n = this)._encoding = i, Boolean(e.fatal) && (n._error_mode = "fatal"), Boolean(e.ignoreBOM) && (n._ignoreBOM = !0), Object.defineProperty || (this.encoding = n._encoding.name.toLowerCase(), this.fatal = "fatal" === n._error_mode, this.ignoreBOM = n._ignoreBOM), n; + throw Error("Decoder not present. Did you forget to include encoding-indexes.js first?") + } + + function k(n, e) { + if (!(this instanceof k)) throw TypeError("Called as a function. Did you forget 'new'?"); + e = s(e), this._encoding = null, this._encoder = null, this._do_not_flush = !1, this._fatal = Boolean(e.fatal) ? "fatal" : "replacement"; + if (Boolean(e.NONSTANDARD_allowLegacyEncoding)) { + e = r(n = void 0 !== n ? String(n) : x); + if (null === e || "replacement" === e.name) throw RangeError("Unknown encoding: " + n); + if (!h[e.name]) throw Error("Encoder not present. Did you forget to include encoding-indexes.js first?"); + this._encoding = e + } else this._encoding = r("utf-8"), void 0 !== n && "console" in i && console.warn("TextEncoder constructor called with encoding label, which is ignored."); + return Object.defineProperty || (this.encoding = this._encoding.name.toLowerCase()), this + } + + function e(n) { + var r = n.fatal, t = 0, o = 0, s = 0, l = 128, a = 191; + this.handler = function (n, e) { + if (e === b && 0 !== s) return s = 0, m(r); + if (e === b) return w; + if (0 === s) { + if (_(e, 0, 127)) return e; + if (_(e, 194, 223)) s = 1, t = 31 & e; else if (_(e, 224, 239)) 224 === e && (l = 160), 237 === e && (a = 159), s = 2, t = 15 & e; else { + if (!_(e, 240, 244)) return m(r); + 240 === e && (l = 144), 244 === e && (a = 143), s = 3, t = 7 & e + } + return null + } + var i; + return _(e, l, a) ? (l = 128, a = 191, t = t << 6 | 63 & e, (o += 1) !== s ? null : (i = t, t = s = o = 0, i)) : (t = s = o = 0, l = 128, a = 191, n.prepend(e), m(r)) + } + } + + function E(n) { + n.fatal; + this.handler = function (n, e) { + if (e === b) return w; + if (a(e)) return e; + _(e, 128, 2047) ? (i = 1, r = 192) : _(e, 2048, 65535) ? (i = 2, r = 224) : _(e, 65536, 1114111) && (i = 3, r = 240); + for (var i, r, t = [(e >> 6 * i) + r]; 0 < i;) t.push(128 | 63 & e >> 6 * (i - 1)), --i; + return t + } + } + + function j(i, n) { + var r = n.fatal; + this.handler = function (n, e) { + return e === b ? w : u(e) ? e : null === (e = i[e - 128]) ? m(r) : e + } + } + + function B(r, n) { + n.fatal; + this.handler = function (n, e) { + var i; + return e === b ? w : a(e) ? e : (null === (i = p(e, r)) && f(e), i + 128) + } + } + + function S(n) { + var o = n.fatal, s = 0, l = 0, a = 0; + this.handler = function (n, e) { + var i, r, t; + return e === b && 0 === s && 0 === l && 0 === a ? w : (e !== b || 0 === s && 0 === l && 0 === a || (a = l = s = 0, m(o)), 0 !== a ? (i = null, _(e, 48, 57) && (i = function (n) { + if (39419 < n && n < 189e3 || 1237575 < n) return null; + if (7457 === n) return 59335; + for (var e = 0, i = 0, r = v("gb18030-ranges"), t = 0; t < r.length; ++t) { + var o = r[t]; + if (!(o[0] <= n)) break; + e = o[0], i = o[1] + } + return i + n - e + }(10 * (126 * (10 * (s - 129) + l - 48) + a - 129) + e - 48)), r = [l, a, e], a = l = s = 0, null === i ? (n.prepend(r), m(o)) : i) : 0 !== l ? _(e, 129, 254) ? (a = e, null) : (n.prepend([l, e]), l = s = 0, m(o)) : 0 !== s ? _(e, 48, 57) ? (l = e, null) : (r = s, s = 0, (t = null) === (i = null === (t = _(e, 64, 126) || _(e, 128, 254) ? 190 * (r - 129) + (e - (e < 127 ? 64 : 65)) : t) ? null : y(t, v("gb18030"))) && u(e) && n.prepend(e), null === i ? m(o) : i) : u(e) ? e : 128 === e ? 8364 : _(e, 129, 254) ? (s = e, null) : m(o)) + } + } + + function T(n, t) { + n.fatal; + this.handler = function (n, e) { + var i, r; + return e === b ? w : a(e) ? e : 58853 === e ? f(e) : t && 8364 === e ? 128 : null !== (i = p(e, v("gb18030"))) ? (r = i % 190, [l(i / 190) + 129, r + (r < 63 ? 64 : 65)]) : t ? f(e) : (i = function (n) { + if (59335 === n) return 7457; + for (var e = 0, i = 0, r = v("gb18030-ranges"), t = 0; t < r.length; ++t) { + var o = r[t]; + if (!(o[1] <= n)) break; + e = o[1], i = o[0] + } + return i + n - e + }(e), [(r = l(i / 10 / 126 / 10)) + 129, (e = l((i -= 10 * r * 126 * 10) / 10 / 126)) + 48, (r = l((i -= 10 * e * 126) / 10)) + 129, 48 + (i - 10 * r)]) + } + } + + function I(n) { + var t = n.fatal, o = 0; + this.handler = function (n, e) { + if (e === b && 0 !== o) return o = 0, m(t); + if (e === b && 0 === o) return w; + if (0 === o) return u(e) ? e : _(e, 129, 254) ? (o = e, null) : m(t); + var i = o, r = null; + switch (o = 0, r = _(e, 64, 126) || _(e, 161, 254) ? 157 * (i - 129) + (e - (e < 127 ? 64 : 98)) : r) { + case 1133: + return [202, 772]; + case 1135: + return [202, 780]; + case 1164: + return [234, 772]; + case 1166: + return [234, 780] + } + i = null === r ? null : y(r, v("big5")); + return null === i && u(e) && n.prepend(e), null === i ? m(t) : i + } + } + + function U(n) { + n.fatal; + this.handler = function (n, e) { + var i, r; + return e === b ? w : a(e) ? e : (i = e, r = o = o || v("big5").map(function (n, e) { + return e < 5024 ? null : n + }), null === (i = 9552 === i || 9566 === i || 9569 === i || 9578 === i || 21313 === i || 21317 === i ? r.lastIndexOf(i) : p(i, r)) || (r = l(i / 157) + 129) < 161 ? f(e) : [r, (e = i % 157) + (e < 63 ? 64 : 98)]) + } + } + + function C(n) { + var t = n.fatal, o = !1, s = 0; + this.handler = function (n, e) { + var i, r; + return e === b && 0 !== s ? (s = 0, m(t)) : e === b && 0 === s ? w : 142 === s && _(e, 161, 223) ? (s = 0, 65216 + e) : 143 === s && _(e, 161, 254) ? (o = !0, s = e, null) : 0 !== s ? (i = s, s = 0, r = null, _(i, 161, 254) && _(e, 161, 254) && (r = y(94 * (i - 161) + (e - 161), v(o ? "jis0212" : "jis0208"))), o = !1, _(e, 161, 254) || n.prepend(e), null === r ? m(t) : r) : u(e) ? e : 142 === e || 143 === e || _(e, 161, 254) ? (s = e, null) : m(t) + } + } + + function P(n) { + n.fatal; + this.handler = function (n, e) { + var i; + return e === b ? w : a(e) ? e : 165 === e ? 92 : 8254 === e ? 126 : _(e, 65377, 65439) ? [142, e - 65377 + 161] : null === (i = p(e = 8722 === e ? 65293 : e, v("jis0208"))) ? f(e) : [l(i / 94) + 161, i % 94 + 161] + } + } + + function D(n) { + var t = n.fatal, o = 0, s = 1, l = 2, a = 3, u = 4, c = 5, f = 6, d = o, h = o, g = 0, + p = !1; + this.handler = function (n, e) { + switch (d) { + default: + case o: + return 27 === e ? (d = c, null) : _(e, 0, 127) && 14 !== e && 15 !== e && 27 !== e ? (p = !1, e) : e === b ? w : (p = !1, m(t)); + case s: + return 27 === e ? (d = c, null) : 92 === e ? (p = !1, 165) : 126 === e ? (p = !1, 8254) : _(e, 0, 127) && 14 !== e && 15 !== e && 27 !== e && 92 !== e && 126 !== e ? (p = !1, e) : e === b ? w : (p = !1, m(t)); + case l: + return 27 === e ? (d = c, null) : _(e, 33, 95) ? (p = !1, 65344 + e) : e === b ? w : (p = !1, m(t)); + case a: + return 27 === e ? (d = c, null) : _(e, 33, 126) ? (p = !1, g = e, d = u, null) : e === b ? w : (p = !1, m(t)); + case u: + if (27 === e) d = c; else { + if (_(e, 33, 126)) return d = a, null === (i = y(94 * (g - 33) + e - 33, v("jis0208"))) ? m(t) : i; + e === b ? (d = a, n.prepend(e)) : d = a + } + return m(t); + case c: + return 36 === e || 40 === e ? (g = e, d = f, null) : (n.prepend(e), p = !1, d = h, m(t)); + case f: + var i = g, r = (g = 0, null); + return (40 === i && 66 === e && (r = o), 40 === i && 74 === e && (r = s), 40 === i && 73 === e && (r = l), null !== (r = 36 !== i || 64 !== e && 66 !== e ? r : a)) ? (d = r, r = p, p = !0, r ? m(t) : null) : (n.prepend([i, e]), p = !1, d = h, m(t)) + } + } + } + + function F(n) { + n.fatal; + var r = 0, t = 1, o = 2, s = r; + this.handler = function (n, e) { + if (e === b && s !== r) return n.prepend(e), s = r, [27, 40, 66]; + if (e === b && s === r) return w; + if (!(s !== r && s !== t || 14 !== e && 15 !== e && 27 !== e)) return f(65533); + if (s === r && a(e)) return e; + if (s === t && (a(e) && 92 !== e && 126 !== e || 165 == e || 8254 == e)) { + if (a(e)) return e; + if (165 === e) return 92; + if (8254 === e) return 126 + } + var i; + return a(e) && s !== r ? (n.prepend(e), s = r, [27, 40, 66]) : 165 !== e && 8254 !== e || s === t ? null === (i = p(e = 8722 === e ? 65293 : e, v("jis0208"))) ? f(e) : s !== o ? (n.prepend(e), s = o, [27, 36, 66]) : [l(i / 94) + 33, i % 94 + 33] : (n.prepend(e), s = t, [27, 40, 74]) + } + } + + function J(n) { + var t = n.fatal, o = 0; + this.handler = function (n, e) { + var i, r; + return e === b && 0 !== o ? (o = 0, m(t)) : e === b && 0 === o ? w : 0 !== o ? (r = o, i = null, o = 0, (_(e, 64, 126) || _(e, 128, 252)) && (i = 188 * (r - (r < 160 ? 129 : 193)) + e - (e < 127 ? 64 : 65)), _(i, 8836, 10715) ? 48508 + i : (null === (r = null === i ? null : y(i, v("jis0208"))) && u(e) && n.prepend(e), null === r ? m(t) : r)) : u(e) || 128 === e ? e : _(e, 161, 223) ? 65216 + e : _(e, 129, 159) || _(e, 224, 252) ? (o = e, null) : m(t) + } + } + + function K(n) { + n.fatal; + this.handler = function (n, e) { + var i; + return e === b ? w : a(e) || 128 === e ? e : 165 === e ? 92 : 8254 === e ? 126 : _(e, 65377, 65439) ? e - 65377 + 161 : (i = e = 8722 === e ? 65293 : e, null === (i = (t = t || v("jis0208").map(function (n, e) { + return _(e, 8272, 8835) ? null : n + })).indexOf(i)) ? f(e) : [(e = l(i / 188)) + (e < 31 ? 129 : 193), (e = i % 188) + (e < 63 ? 64 : 65)]) + } + } + + function R(n) { + var t = n.fatal, o = 0; + this.handler = function (n, e) { + var i, r; + return e === b && 0 !== o ? (o = 0, m(t)) : e === b && 0 === o ? w : 0 !== o ? (r = o, o = 0, r = (i = null) === (i = _(e, 65, 254) ? 190 * (r - 129) + (e - 65) : i) ? null : y(i, v("euc-kr")), null === i && u(e) && n.prepend(e), null === r ? m(t) : r) : u(e) ? e : _(e, 129, 254) ? (o = e, null) : m(t) + } + } + + function G(n) { + n.fatal; + this.handler = function (n, e) { + var i; + return e === b ? w : a(e) ? e : null === (i = p(e, v("euc-kr"))) ? f(e) : [l(i / 190) + 129, i % 190 + 65] + } + } + + function A(n, e) { + var i = n >> 8, n = 255 & n; + return e ? [i, n] : [n, i] + } + + function L(r, n) { + var t = n.fatal, o = null, s = null; + this.handler = function (n, e) { + var i; + return e !== b || null === o && null === s ? e === b && null === o && null === s ? w : null === o ? (o = e, null) : (e = r ? (o << 8) + e : (e << 8) + o, (o = null) !== s ? (i = s, s = null, _(e, 56320, 57343) ? 65536 + 1024 * (i - 55296) + (e - 56320) : (n.prepend(A(e, r)), m(t))) : _(e, 55296, 56319) ? (s = e, null) : _(e, 56320, 57343) ? m(t) : e) : m(t) + } + } + + function M(r, n) { + n.fatal; + this.handler = function (n, e) { + var i; + return e === b ? w : _(e, 0, 65535) ? A(e, r) : (i = A(55296 + (e - 65536 >> 10), r), e = A(56320 + (e - 65536 & 1023), r), i.concat(e)) + } + } + + function N(n) { + n.fatal; + this.handler = function (n, e) { + return e === b ? w : u(e) ? e : 63360 + e - 128 + } + } + + function q(n) { + n.fatal; + this.handler = function (n, e) { + return e === b ? w : a(e) ? e : _(e, 63360, 63487) ? e - 63360 + 128 : f(e) + } + } + + Object.defineProperty && (Object.defineProperty(O.prototype, "encoding", { + get: function () { + return this._encoding.name.toLowerCase() + } + }), Object.defineProperty(O.prototype, "fatal", { + get: function () { + return "fatal" === this._error_mode + } + }), Object.defineProperty(O.prototype, "ignoreBOM", { + get: function () { + return this._ignoreBOM + } + })), O.prototype.decode = function (n, e) { + n = "object" == typeof n && n instanceof ArrayBuffer ? new Uint8Array(n) : "object" == typeof n && "buffer" in n && n.buffer instanceof ArrayBuffer ? new Uint8Array(n.buffer, n.byteOffset, n.byteLength) : new Uint8Array(0); + e = s(e), this._do_not_flush || (this._decoder = g[this._encoding.name]({fatal: "fatal" === this._error_mode}), this._BOMseen = !1), this._do_not_flush = Boolean(e.stream); + for (var i, r = new c(n), t = []; ;) { + var o = r.read(); + if (o === b) break; + if ((i = this._decoder.handler(r, o)) === w) break; + null !== i && (Array.isArray(i) ? t.push.apply(t, i) : t.push(i)) + } + if (!this._do_not_flush) { + for (; (i = this._decoder.handler(r, r.read())) !== w && (null !== i && (Array.isArray(i) ? t.push.apply(t, i) : t.push(i)), !r.endOfStream());) ; + this._decoder = null + } + return function (n) { + e = ["UTF-8", "UTF-16LE", "UTF-16BE"], i = this._encoding.name, -1 === e.indexOf(i) || this._ignoreBOM || this._BOMseen || (0 < n.length && 65279 === n[0] ? (this._BOMseen = !0, n.shift()) : 0 < n.length && (this._BOMseen = !0)); + for (var e, i, r = n, t = "", o = 0; o < r.length; ++o) { + var s = r[o]; + s <= 65535 ? t += String.fromCharCode(s) : (s -= 65536, t += String.fromCharCode(55296 + (s >> 10), 56320 + (1023 & s))) + } + return t + }.call(this, t) + }, Object.defineProperty && Object.defineProperty(k.prototype, "encoding", { + get: function () { + return this._encoding.name.toLowerCase() + } + }), k.prototype.encode = function (n, e) { + n = void 0 === n ? "" : String(n), e = s(e), this._do_not_flush || (this._encoder = h[this._encoding.name]({fatal: "fatal" === this._fatal})), this._do_not_flush = Boolean(e.stream); + for (var i, r = new c(function (n) { + for (var e = String(n), i = e.length, r = 0, t = []; r < i;) { + var o, s = e.charCodeAt(r); + s < 55296 || 57343 < s ? t.push(s) : 56320 <= s && s <= 57343 ? t.push(65533) : 55296 <= s && s <= 56319 && (r !== i - 1 && 56320 <= (o = e.charCodeAt(r + 1)) && o <= 57343 ? (t.push(65536 + ((1023 & s) << 10) + (1023 & o)), r += 1) : t.push(65533)), r += 1 + } + return t + }(n)), t = []; ;) { + var o = r.read(); + if (o === b) break; + if ((i = this._encoder.handler(r, o)) === w) break; + Array.isArray(i) ? t.push.apply(t, i) : t.push(i) + } + if (!this._do_not_flush) { + for (; ;) { + if ((i = this._encoder.handler(r, r.read())) === w) break; + Array.isArray(i) ? t.push.apply(t, i) : t.push(i) + } + this._encoder = null + } + return new Uint8Array(t) + }, h["UTF-8"] = function (n) { + return new E(n) + }, g["UTF-8"] = function (n) { + return new e(n) + }, "encoding-indexes" in i && n.forEach(function (n) { + "Legacy single-byte encodings" === n.heading && n.encodings.forEach(function (n) { + var n = n.name, e = v(n.toLowerCase()); + g[n] = function (n) { + return new j(e, n) + }, h[n] = function (n) { + return new B(e, n) + } + }) + }), g.GBK = function (n) { + return new S(n) + }, h.GBK = function (n) { + return new T(n, !0) + }, h.gb18030 = function (n) { + return new T(n) + }, g.gb18030 = function (n) { + return new S(n) + }, h.Big5 = function (n) { + return new U(n) + }, g.Big5 = function (n) { + return new I(n) + }, h["EUC-JP"] = function (n) { + return new P(n) + }, g["EUC-JP"] = function (n) { + return new C(n) + }, h["ISO-2022-JP"] = function (n) { + return new F(n) + }, g["ISO-2022-JP"] = function (n) { + return new D(n) + }, h.Shift_JIS = function (n) { + return new K(n) + }, g.Shift_JIS = function (n) { + return new J(n) + }, h["EUC-KR"] = function (n) { + return new G(n) + }, g["EUC-KR"] = function (n) { + return new R(n) + }, h["UTF-16BE"] = function (n) { + return new M(!0, n) + }, g["UTF-16BE"] = function (n) { + return new L(!0, n) + }, h["UTF-16LE"] = function (n) { + return new M(!1, n) + }, g["UTF-16LE"] = function (n) { + return new L(!1, n) + }, h["x-user-defined"] = function (n) { + return new q(n) + }, g["x-user-defined"] = function (n) { + return new N(n) + }, i.TextEncoder || (i.TextEncoder = k), i.TextDecoder || (i.TextDecoder = O), "undefined" != typeof module && module.exports && (module.exports = { + TextEncoder: i.TextEncoder, + TextDecoder: i.TextDecoder, + EncodingIndexes: i["encoding-indexes"] + }) + }(this || {}); + // @protobuf-ts/runtime + var UnknownFieldHandler, WireType, ScalarType, LongType, RepeatType, + __defProp = Object.defineProperty, __defProps = Object.defineProperties, + __getOwnPropDescs = Object.getOwnPropertyDescriptors, + __getOwnPropSymbols = Object.getOwnPropertySymbols, + __hasOwnProp = Object.prototype.hasOwnProperty, + __propIsEnum = Object.prototype.propertyIsEnumerable, + __defNormalProp = (e, r, t) => r in e ? __defProp(e, r, { + enumerable: !0, + configurable: !0, + writable: !0, + value: t + }) : e[r] = t, __spreadValues = (e, r) => { + for (var t in r = r || {}) __hasOwnProp.call(r, t) && __defNormalProp(e, t, r[t]); + if (__getOwnPropSymbols) for (var t of __getOwnPropSymbols(r)) __propIsEnum.call(r, t) && __defNormalProp(e, t, r[t]); + return e + }, __spreadProps = (e, r) => __defProps(e, __getOwnPropDescs(r)); + + function varint64read() { + let r = 0, t = 0; + for (let e = 0; e < 28; e += 7) { + var a = this.buf[this.pos++]; + if (r |= (127 & a) << e, 0 == (128 & a)) return this.assertBounds(), [r, t] + } + var e = this.buf[this.pos++]; + if (r |= (15 & e) << 28, t = (112 & e) >> 4, 0 == (128 & e)) return this.assertBounds(), [r, t]; + for (let e = 3; e <= 31; e += 7) { + var n = this.buf[this.pos++]; + if (t |= (127 & n) << e, 0 == (128 & n)) return this.assertBounds(), [r, t] + } + throw new Error("invalid varint") + } + + function varint64write(r, t, a) { + for (let e = 0; e < 28; e += 7) { + var n = r >>> e, s = !(n >>> 7 == 0 && 0 == t); + if (a.push(255 & (s ? 128 | n : n)), !s) return + } + var e = r >>> 28 & 15 | (7 & t) << 4, i = !(t >> 3 == 0); + if (a.push(255 & (i ? 128 | e : e)), i) { + for (let e = 3; e < 31; e += 7) { + var o = t >>> e, l = !(o >>> 7 == 0); + if (a.push(255 & (l ? 128 | o : o)), !l) return + } + a.push(t >>> 31 & 1) + } + } + + const TWO_PWR_32_DBL$1 = 4294967296; + + function int64fromString(t) { + var e = "-" == t[0]; + e && (t = t.slice(1)); + let a = 0, n = 0; + + function r(e, r) { + e = Number(t.slice(e, r)); + n *= 1e6, (a = 1e6 * a + e) >= TWO_PWR_32_DBL$1 && (n += a / TWO_PWR_32_DBL$1 | 0, a %= TWO_PWR_32_DBL$1) + } + + return r(-24, -18), r(-18, -12), r(-12, -6), r(-6), [e, a, n] + } + + function int64toString(e, r) { + if (r <= 2097151) return "" + (TWO_PWR_32_DBL$1 * r + e); + var t = (e >>> 24 | r << 8) >>> 0 & 16777215, r = r >> 16 & 65535; + let a = (16777215 & e) + 6777216 * t + 6710656 * r, n = t + 8147497 * r, s = 2 * r; + e = 1e7; + + function i(e, r) { + e = e ? String(e) : ""; + return r ? "0000000".slice(e.length) + e : e + } + + return a >= e && (n += Math.floor(a / e), a %= e), n >= e && (s += Math.floor(n / e), n %= e), i(s, 0) + i(n, s) + i(a, 1) + } + + function varint32write(r, t) { + if (0 <= r) { + for (; 127 < r;) t.push(127 & r | 128), r >>>= 7; + t.push(r) + } else { + for (let e = 0; e < 9; e++) t.push(127 & r | 128), r >>= 7; + t.push(1) + } + } + + function varint32read() { + let r = this.buf[this.pos++]; + var e = 127 & r; + if (0 == (128 & r)) return this.assertBounds(), e; + if (e |= (127 & (r = this.buf[this.pos++])) << 7, 0 == (128 & r)) return this.assertBounds(), e; + if (e |= (127 & (r = this.buf[this.pos++])) << 14, 0 == (128 & r)) return this.assertBounds(), e; + if (e |= (127 & (r = this.buf[this.pos++])) << 21, 0 == (128 & r)) return this.assertBounds(), e; + e |= (15 & (r = this.buf[this.pos++])) << 28; + for (let e = 5; 0 != (128 & r) && e < 10; e++) r = this.buf[this.pos++]; + if (0 != (128 & r)) throw new Error("invalid varint"); + return this.assertBounds(), e >>> 0 + } + + function detectBi() { + var e = new DataView(new ArrayBuffer(8)); + return void 0 !== globalThis.BigInt && "function" == typeof e.getBigInt64 && "function" == typeof e.getBigUint64 && "function" == typeof e.setBigInt64 && "function" == typeof e.setBigUint64 ? { + MIN: BigInt("-9223372036854775808"), + MAX: BigInt("9223372036854775807"), + UMIN: BigInt("0"), + UMAX: BigInt("18446744073709551615"), + C: BigInt, + V: e + } : void 0 + } + + const BI = detectBi(); + + function assertBi(e) { + if (!e) throw new Error("BigInt unavailable, see https://github.com/timostamm/protobuf-ts/blob/v1.0.8/MANUAL.md#bigint-support") + } + + const RE_DECIMAL_STR = /^-?[0-9]+$/, TWO_PWR_32_DBL = 4294967296; + + class SharedPbLong { + constructor(e, r) { + this.lo = 0 | e, this.hi = 0 | r + } + + isZero() { + return 0 == this.lo && 0 == this.hi + } + + toNumber() { + var e = this.hi * TWO_PWR_32_DBL + (this.lo >>> 0); + if (Number.isSafeInteger(e)) return e; + throw new Error("cannot convert to safe number") + } + } + + const _PbULong = class extends SharedPbLong { + static from(e) { + if (BI) switch (typeof e) { + case"string": + if ("0" == e) return this.ZERO; + if ("" == e) throw new Error("string is no integer"); + e = BI.C(e); + case"number": + if (0 === e) return this.ZERO; + e = BI.C(e); + case"bigint": + if (!e) return this.ZERO; + if (e < BI.UMIN) throw new Error("signed value for ulong"); + if (e > BI.UMAX) throw new Error("ulong too large"); + return BI.V.setBigUint64(0, e, !0), new _PbULong(BI.V.getInt32(0, !0), BI.V.getInt32(4, !0)) + } else switch (typeof e) { + case"string": + if ("0" == e) return this.ZERO; + if (e = e.trim(), !RE_DECIMAL_STR.test(e)) throw new Error("string is no integer"); + var [r, t, a] = int64fromString(e); + if (r) throw new Error("signed value"); + return new _PbULong(t, a); + case"number": + if (0 == e) return this.ZERO; + if (!Number.isSafeInteger(e)) throw new Error("number is no integer"); + if (e < 0) throw new Error("signed value for ulong"); + return new _PbULong(e, e / TWO_PWR_32_DBL) + } + throw new Error("unknown value " + typeof e) + } + + toString() { + return BI ? this.toBigInt().toString() : int64toString(this.lo, this.hi) + } + + toBigInt() { + return assertBi(BI), BI.V.setInt32(0, this.lo, !0), BI.V.setInt32(4, this.hi, !0), BI.V.getBigUint64(0, !0) + } + }; + let PbULong = _PbULong; + PbULong.ZERO = new _PbULong(0, 0); + const _PbLong = class extends SharedPbLong { + static from(e) { + if (BI) switch (typeof e) { + case"string": + if ("0" == e) return this.ZERO; + if ("" == e) throw new Error("string is no integer"); + e = BI.C(e); + case"number": + if (0 === e) return this.ZERO; + e = BI.C(e); + case"bigint": + if (!e) return this.ZERO; + if (e < BI.MIN) throw new Error("ulong too small"); + if (e > BI.MAX) throw new Error("ulong too large"); + return BI.V.setBigInt64(0, e, !0), new _PbLong(BI.V.getInt32(0, !0), BI.V.getInt32(4, !0)) + } else switch (typeof e) { + case"string": + if ("0" == e) return this.ZERO; + var r, t, a; + if (e = e.trim(), RE_DECIMAL_STR.test(e)) return [r, a, t] = int64fromString(e), a = new _PbLong(a, t), r ? a.negate() : a; + throw new Error("string is no integer"); + case"number": + if (0 == e) return this.ZERO; + if (Number.isSafeInteger(e)) return 0 < e ? new _PbLong(e, e / TWO_PWR_32_DBL) : new _PbLong(-e, -e / TWO_PWR_32_DBL).negate(); + throw new Error("number is no integer") + } + throw new Error("unknown value " + typeof e) + } + + isNegative() { + return 0 != (2147483648 & this.hi) + } + + negate() { + let e = ~this.hi, r = this.lo; + return r ? r = 1 + ~r : e += 1, new _PbLong(r, e) + } + + toString() { + var e; + return BI ? this.toBigInt().toString() : this.isNegative() ? "-" + int64toString((e = this.negate()).lo, e.hi) : int64toString(this.lo, this.hi) + } + + toBigInt() { + return assertBi(BI), BI.V.setInt32(0, this.lo, !0), BI.V.setInt32(4, this.hi, !0), BI.V.getBigInt64(0, !0) + } + }; + let PbLong = _PbLong; + PbLong.ZERO = new _PbLong(0, 0); + + class BinaryReader { + constructor(e, r) { + this.varint64 = varint64read, this.uint32 = varint32read, this.buf = e, this.len = e.length, this.pos = 0, this.view = new DataView(e.buffer, e.byteOffset, e.byteLength), this.textDecoder = null != r ? r : new TextDecoder("utf-8", {fatal: !0}) + } + + tag() { + var e = this.uint32(), r = e >>> 3, e = 7 & e; + if (r <= 0 || e < 0 || 5 < e) throw new Error("illegal tag: field no " + r + " wire type " + e); + return [r, e] + } + + skip(e) { + var r, t = this.pos; + switch (e) { + case WireType.Varint: + for (; 128 & this.buf[this.pos++];) ; + break; + case WireType.Bit64: + this.pos += 4; + case WireType.Bit32: + this.pos += 4; + break; + case WireType.LengthDelimited: + var a = this.uint32(); + this.pos += a; + break; + case WireType.StartGroup: + for (; (r = this.tag()[1]) !== WireType.EndGroup;) this.skip(r); + break; default: - if (data.videoUpList) { - data.videoUpList = null; - $.log(`🎉 ${$.name}`, '动态视频页最常访问去除'); - } - break; - case false: - $.log( - `🚧 ${$.name}`, - '用户设置动态视频页最常访问不去除' - ); - break; - } - body = DynVideoReply.toBinary(data); - break; - } - break; - case 'bilibili.app.view.v1.View': // 视频 - switch (PATHs?.[1]) { - case 'View': // 视频播放页 - /****************** initialization start *******************/ - // protobuf/bilibili/app/view/view.proto - class ViewReply$Type extends MessageType { - constructor() { - super('ViewReply', [ - { - no: 6, - name: 't_icon', - kind: 'map', - K: 9, - V: { kind: 'message', T: () => TIcon }, - }, - { - no: 10, - name: 'relates', - kind: 'message', - repeat: 1, - T: () => Relate, - }, - { - no: 30, - name: 'cms', - kind: 'message', - repeat: 1, - T: () => CM, - }, - { - no: 31, - name: 'cm_config', - kind: 'message', - T: () => CMConfig, - }, - { - no: 41, - name: 'cm_ipad', - kind: 'message', - T: () => CmIpad, - }, - ]); + throw new Error("cant skip wire type " + e) + } + return this.assertBounds(), this.buf.subarray(t, this.pos) + } + + assertBounds() { + if (this.pos > this.len) throw new RangeError("premature EOF") + } + + int32() { + return 0 | this.uint32() + } + + sint32() { + var e = this.uint32(); + return e >>> 1 ^ -(1 & e) + } + + int64() { + return new PbLong(...this.varint64()) + } + + uint64() { + return new PbULong(...this.varint64()) + } + + sint64() { + var [e, r] = this.varint64(), t = -(1 & e), e = (e >>> 1 | (1 & r) << 31) ^ t, r = r >>> 1 ^ t; + return new PbLong(e, r) + } + + bool() { + var [e, r] = this.varint64(); + return 0 !== e || 0 !== r + } + + fixed32() { + return this.view.getUint32((this.pos += 4) - 4, !0) + } + + sfixed32() { + return this.view.getInt32((this.pos += 4) - 4, !0) + } + + fixed64() { + return new PbULong(this.sfixed32(), this.sfixed32()) + } + + sfixed64() { + return new PbLong(this.sfixed32(), this.sfixed32()) + } + + float() { + return this.view.getFloat32((this.pos += 4) - 4, !0) + } + + double() { + return this.view.getFloat64((this.pos += 8) - 8, !0) + } + + bytes() { + var e = this.uint32(), r = this.pos; + return this.pos += e, this.assertBounds(), this.buf.subarray(r, r + e) + } + + string() { + return this.textDecoder.decode(this.bytes()) + } + } + + function assert(e, r) { + if (!e) throw new Error(r) + } + + const FLOAT32_MAX = 34028234663852886e22, FLOAT32_MIN = -34028234663852886e22, + UINT32_MAX = 4294967295, INT32_MAX = 2147483647, INT32_MIN = -2147483648; + + function assertInt32(e) { + if ("number" != typeof e) throw new Error("invalid int 32: " + typeof e); + if (!Number.isInteger(e) || e > INT32_MAX || e < INT32_MIN) throw new Error("invalid int 32: " + e) + } + + function assertUInt32(e) { + if ("number" != typeof e) throw new Error("invalid uint 32: " + typeof e); + if (!Number.isInteger(e) || e > UINT32_MAX || e < 0) throw new Error("invalid uint 32: " + e) + } + + function assertFloat32(e) { + if ("number" != typeof e) throw new Error("invalid float 32: " + typeof e); + if (Number.isFinite(e) && (e > FLOAT32_MAX || e < FLOAT32_MIN)) throw new Error("invalid float 32: " + e) + } + + class BinaryWriter { + constructor(e) { + this.stack = [], this.textEncoder = null != e ? e : new TextEncoder, this.chunks = [], this.buf = [] + } + + finish() { + this.chunks.push(new Uint8Array(this.buf)); + let r = 0; + for (let e = 0; e < this.chunks.length; e++) r += this.chunks[e].length; + var t = new Uint8Array(r); + let a = 0; + for (let e = 0; e < this.chunks.length; e++) t.set(this.chunks[e], a), a += this.chunks[e].length; + return this.chunks = [], t + } + + fork() { + return this.stack.push({ + chunks: this.chunks, + buf: this.buf + }), this.chunks = [], this.buf = [], this + } + + join() { + var e = this.finish(), r = this.stack.pop(); + if (r) return this.chunks = r.chunks, this.buf = r.buf, this.uint32(e.byteLength), this.raw(e); + throw new Error("invalid state, fork stack empty") + } + + tag(e, r) { + return this.uint32((e << 3 | r) >>> 0) + } + + raw(e) { + return this.buf.length && (this.chunks.push(new Uint8Array(this.buf)), this.buf = []), this.chunks.push(e), this + } + + uint32(e) { + for (assertUInt32(e); 127 < e;) this.buf.push(127 & e | 128), e >>>= 7; + return this.buf.push(e), this + } + + int32(e) { + return assertInt32(e), varint32write(e, this.buf), this + } + + bool(e) { + return this.buf.push(e ? 1 : 0), this + } + + bytes(e) { + return this.uint32(e.byteLength), this.raw(e) + } + + string(e) { + e = this.textEncoder.encode(e); + return this.uint32(e.byteLength), this.raw(e) + } + + float(e) { + assertFloat32(e); + var r = new Uint8Array(4); + return new DataView(r.buffer).setFloat32(0, e, !0), this.raw(r) + } + + double(e) { + var r = new Uint8Array(8); + return new DataView(r.buffer).setFloat64(0, e, !0), this.raw(r) + } + + fixed32(e) { + assertUInt32(e); + var r = new Uint8Array(4); + return new DataView(r.buffer).setUint32(0, e, !0), this.raw(r) + } + + sfixed32(e) { + assertInt32(e); + var r = new Uint8Array(4); + return new DataView(r.buffer).setInt32(0, e, !0), this.raw(r) + } + + sint32(e) { + return assertInt32(e), varint32write(e = (e << 1 ^ e >> 31) >>> 0, this.buf), this + } + + sfixed64(e) { + var r = new Uint8Array(8), t = new DataView(r.buffer), e = PbLong.from(e); + return t.setInt32(0, e.lo, !0), t.setInt32(4, e.hi, !0), this.raw(r) + } + + fixed64(e) { + var r = new Uint8Array(8), t = new DataView(r.buffer), e = PbULong.from(e); + return t.setInt32(0, e.lo, !0), t.setInt32(4, e.hi, !0), this.raw(r) + } + + int64(e) { + e = PbLong.from(e); + return varint64write(e.lo, e.hi, this.buf), this + } + + sint64(e) { + var e = PbLong.from(e), r = e.hi >> 31; + return varint64write(e.lo << 1 ^ r, (e.hi << 1 | e.lo >>> 31) ^ r, this.buf), this + } + + uint64(e) { + e = PbULong.from(e); + return varint64write(e.lo, e.hi, this.buf), this + } + } + + function binaryWriteOptions(e) { + return e ? __spreadValues(__spreadValues({}, defaultsWrite$1), e) : defaultsWrite$1 + } + + function binaryReadOptions(e) { + return e ? __spreadValues(__spreadValues({}, defaultsRead$1), e) : defaultsRead$1 + } + + !function (i) { + i.symbol = Symbol.for("protobuf-ts/unknown"), i.onRead = (e, r, t, a, n) => { + (s(r) ? r[i.symbol] : r[i.symbol] = []).push({no: t, wireType: a, data: n}) + }, i.onWrite = (e, r, t) => { + for (var {no: a, wireType: n, data: s} of i.list(r)) t.tag(a, n).raw(s) + }, i.list = (e, r) => s(e) ? (e = e[i.symbol], r ? e.filter((e => e.no == r)) : e) : [], i.last = (e, r) => i.list(e, r).slice(-1)[0]; + const s = e => e && Array.isArray(e[i.symbol]) + }(UnknownFieldHandler = UnknownFieldHandler || {}); + const defaultsRead$1 = {readUnknownField: !0, readerFactory: e => new BinaryReader(e)}, + defaultsWrite$1 = {writeUnknownFields: !0, writerFactory: () => new BinaryWriter}, + MESSAGE_TYPE = (!function (e) { + e[e.Varint = 0] = "Varint", e[e.Bit64 = 1] = "Bit64", e[e.LengthDelimited = 2] = "LengthDelimited", e[e.StartGroup = 3] = "StartGroup", e[e.EndGroup = 4] = "EndGroup", e[e.Bit32 = 5] = "Bit32" + }(WireType = WireType || {}), Symbol.for("protobuf-ts/message-type")); + + function lowerCamelCase(r) { + let t = !1; + var a = []; + for (let e = 0; e < r.length; e++) { + var n = r.charAt(e); + "_" == n ? t = !0 : /\d/.test(n) ? (a.push(n), t = !0) : t ? (a.push(n.toUpperCase()), t = !1) : 0 == e ? a.push(n.toLowerCase()) : a.push(n) + } + return a.join("") + } + + function normalizeFieldInfo(e) { + var r; + return e.localName = null != (r = e.localName) ? r : lowerCamelCase(e.name), e.jsonName = null != (r = e.jsonName) ? r : lowerCamelCase(e.name), e.repeat = null != (r = e.repeat) ? r : 0, e.opt = null != (r = e.opt) ? r : !e.repeat && (!e.oneof && "message" == e.kind), e + } + + function isOneofGroup(e) { + if ("object" != typeof e || null === e || !e.hasOwnProperty("oneofKind")) return !1; + switch (typeof e.oneofKind) { + case"string": + return void 0 === e[e.oneofKind] ? !1 : 2 == Object.keys(e).length; + case"undefined": + return 1 == Object.keys(e).length; + default: + return !1 + } + } + + !function (e) { + e[e.DOUBLE = 1] = "DOUBLE", e[e.FLOAT = 2] = "FLOAT", e[e.INT64 = 3] = "INT64", e[e.UINT64 = 4] = "UINT64", e[e.INT32 = 5] = "INT32", e[e.FIXED64 = 6] = "FIXED64", e[e.FIXED32 = 7] = "FIXED32", e[e.BOOL = 8] = "BOOL", e[e.STRING = 9] = "STRING", e[e.BYTES = 12] = "BYTES", e[e.UINT32 = 13] = "UINT32", e[e.SFIXED32 = 15] = "SFIXED32", e[e.SFIXED64 = 16] = "SFIXED64", e[e.SINT32 = 17] = "SINT32", e[e.SINT64 = 18] = "SINT64" + }(ScalarType = ScalarType || {}), function (e) { + e[e.BIGINT = 0] = "BIGINT", e[e.STRING = 1] = "STRING", e[e.NUMBER = 2] = "NUMBER" + }(LongType = LongType || {}), function (e) { + e[e.NO = 0] = "NO", e[e.PACKED = 1] = "PACKED", e[e.UNPACKED = 2] = "UNPACKED" + }(RepeatType = RepeatType || {}); + + class ReflectionTypeCheck { + constructor(e) { + this.fields = null != (e = e.fields) ? e : [] + } + + prepare() { + if (!this.data) { + var e, r = [], t = [], a = []; + for (e of this.fields) if (e.oneof) a.includes(e.oneof) || (a.push(e.oneof), r.push(e.oneof), t.push(e.oneof)); else switch (t.push(e.localName), e.kind) { + case"scalar": + case"enum": + e.opt && !e.repeat || r.push(e.localName); + break; + case"message": + e.repeat && r.push(e.localName); + break; + case"map": + r.push(e.localName) } - create(value) { - const message = { - tIcon: {}, - relates: [], - cms: [], - }; - globalThis.Object.defineProperty( - message, - MESSAGE_TYPE, - { enumerable: false, value: this } - ); - if (value !== undefined) - reflectionMergePartial(this, message, value); - return message; - } - internalBinaryRead( - reader, - length, - options, - target - ) { - let message = target ?? this.create(), - end = reader.pos + length; - while (reader.pos < end) { - let [fieldNo, wireType] = reader.tag(); - switch (fieldNo) { - case 6: - this.binaryReadMap6( - message.tIcon, - reader, - options - ); - break; - case 10: - message.relates.push( - Relate.internalBinaryRead( - reader, - reader.uint32(), - options - ) - ); - break; - case 30: - message.cms.push( - CM.internalBinaryRead( - reader, - reader.uint32(), - options - ) - ); - break; - case 31: - message.cmConfig = - CMConfig.internalBinaryRead( - reader, - reader.uint32(), - options, - message.cmConfig - ); - break; - case 41: - message.cmIpad = CmIpad.internalBinaryRead( - reader, - reader.uint32(), - options, - message.cmIpad - ); - break; - default: - let u = options.readUnknownField; - if (u === 'throw') - throw new globalThis.Error( - `Unknown field ${fieldNo}(wire type ${wireType})for ${this.typeName}` - ); - let d = reader.skip(wireType); - if (u !== false) - (u === true - ? UnknownFieldHandler.onRead - : u)( - this.typeName, - message, - fieldNo, - wireType, - d - ); + this.data = {req: r, known: t, oneofs: Object.values(a)} + } + } + + is(e, a, n = !1) { + if (!(a < 0)) { + if (null == e || "object" != typeof e) return !1; + this.prepare(); + let r = Object.keys(e), t = this.data; + if (r.length < t.req.length || t.req.some((e => !r.includes(e)))) return !1; + if (!n && r.some((e => !t.known.includes(e)))) return !1; + if (!(a < 1)) { + for (const i of t.oneofs) { + const o = e[i]; + if (!isOneofGroup(o)) return !1; + if (void 0 !== o.oneofKind) { + var s = this.fields.find((e => e.localName === o.oneofKind)); + if (!s) return !1; + if (!this.field(o[o.oneofKind], s, n, a)) return !1 + } } - } - return message; + for (const l of this.fields) if (void 0 === l.oneof && !this.field(e[l.localName], l, n, a)) return !1 } - binaryReadMap6(map, reader, options) { - let len = reader.uint32(), - end = reader.pos + len, - key, - val; - while (reader.pos < end) { - let [fieldNo, wireType] = reader.tag(); - switch (fieldNo) { - case 1: - key = reader.string(); - break; - case 2: - val = TIcon.internalBinaryRead( - reader, - reader.uint32(), - options - ); - break; - default: - throw new globalThis.Error( - 'unknown map entry field for field ViewReply.t_icon' - ); + } + return !0 + } + + field(e, r, t, a) { + var n = r.repeat; + switch (r.kind) { + case"scalar": + return void 0 === e ? r.opt : n ? this.scalars(e, r.T, a, r.L) : this.scalar(e, r.T, r.L); + case"enum": + return void 0 === e ? r.opt : n ? this.scalars(e, ScalarType.INT32, a) : this.scalar(e, ScalarType.INT32); + case"message": + return void 0 === e ? !0 : n ? this.messages(e, r.T(), t, a) : this.message(e, r.T(), t, a); + case"map": + if ("object" != typeof e || null === e) return !1; + if (a < 2) return !0; + if (!this.mapKeys(e, r.K, a)) return !1; + switch (r.V.kind) { + case"scalar": + return this.scalars(Object.values(e), r.V.T, a, r.V.L); + case"enum": + return this.scalars(Object.values(e), ScalarType.INT32, a); + case"message": + return this.messages(Object.values(e), r.V.T(), t, a) } - } - map[key ?? ''] = val ?? TIcon.create(); - } - internalBinaryWrite(message, writer, options) { - for (let k of Object.keys(message.tIcon)) { - writer - .tag(6, WireType.LengthDelimited) - .fork() - .tag(1, WireType.LengthDelimited) - .string(k); - writer.tag(2, WireType.LengthDelimited).fork(); - TIcon.internalBinaryWrite( - message.tIcon[k], - writer, - options - ); - writer.join().join(); - } - for (let i = 0; i < message.relates.length; i++) - Relate.internalBinaryWrite( - message.relates[i], - writer - .tag(10, WireType.LengthDelimited) - .fork(), - options - ).join(); - for (let i = 0; i < message.cms.length; i++) - CM.internalBinaryWrite( - message.cms[i], - writer - .tag(30, WireType.LengthDelimited) - .fork(), - options - ).join(); - if (message.cmConfig) - CMConfig.internalBinaryWrite( - message.cmConfig, - writer - .tag(31, WireType.LengthDelimited) - .fork(), - options - ).join(); - if (message.cmIpad) - CmIpad.internalBinaryWrite( - message.cmIpad, - writer - .tag(41, WireType.LengthDelimited) - .fork(), - options - ).join(); - let u = options.writeUnknownFields; - if (u !== false) - (u == true ? UnknownFieldHandler.onWrite : u)( - this.typeName, - message, - writer - ); - return writer; - } - } - const ViewReply = new ViewReply$Type(); - class CM$Type extends MessageType { - constructor() { - super('CM', [ - { - no: 1, - name: 'source_content', - kind: 'message', - T: () => Any, - }, - ]); - } - create(value) { - const message = {}; - globalThis.Object.defineProperty( - message, - MESSAGE_TYPE, - { enumerable: false, value: this } - ); - if (value !== undefined) - reflectionMergePartial(this, message, value); - return message; - } - internalBinaryRead( - reader, - length, - options, - target - ) { - let message = target ?? this.create(), - end = reader.pos + length; - while (reader.pos < end) { - let [fieldNo, wireType] = reader.tag(); - switch (fieldNo) { - case 1: - message.sourceContent = - Any.internalBinaryRead( - reader, - reader.uint32(), - options, - message.sourceContent - ); - break; - default: - let u = options.readUnknownField; - if (u === 'throw') - throw new globalThis.Error( - `Unknown field ${fieldNo}(wire type ${wireType})for ${this.typeName}` - ); - let d = reader.skip(wireType); - if (u !== false) - (u === true - ? UnknownFieldHandler.onRead - : u)( - this.typeName, - message, - fieldNo, - wireType, - d - ); + } + return !0 + } + + message(e, r, t, a) { + return t ? r.isAssignable(e, a) : r.is(e, a) + } + + messages(r, t, e, a) { + if (!Array.isArray(r)) return !1; + if (!(a < 2)) if (e) { + for (let e = 0; e < r.length && e < a; e++) if (!t.isAssignable(r[e], a - 1)) return !1 + } else for (let e = 0; e < r.length && e < a; e++) if (!t.is(r[e], a - 1)) return !1; + return !0 + } + + scalar(e, r, t) { + var a = typeof e; + switch (r) { + case ScalarType.UINT64: + case ScalarType.FIXED64: + case ScalarType.INT64: + case ScalarType.SFIXED64: + case ScalarType.SINT64: + switch (t) { + case LongType.BIGINT: + return "bigint" == a; + case LongType.NUMBER: + return "number" == a && !isNaN(e); + default: + return "string" == a } - } - return message; - } - internalBinaryWrite(message, writer, options) { - if (message.sourceContent) - Any.internalBinaryWrite( - message.sourceContent, - writer - .tag(1, WireType.LengthDelimited) - .fork(), - options - ).join(); - let u = options.writeUnknownFields; - if (u !== false) - (u == true ? UnknownFieldHandler.onWrite : u)( - this.typeName, - message, - writer - ); - return writer; - } - } - const CM = new CM$Type(); - class CMConfig$Type extends MessageType { - constructor() { - super('CMConfig', [ - { - no: 1, - name: 'ads_control', - kind: 'message', - T: () => Any, - }, - ]); - } - create(value) { - const message = {}; - globalThis.Object.defineProperty( - message, - MESSAGE_TYPE, - { enumerable: false, value: this } - ); - if (value !== undefined) - reflectionMergePartial(this, message, value); - return message; - } - internalBinaryRead( - reader, - length, - options, - target - ) { - let message = target ?? this.create(), - end = reader.pos + length; - while (reader.pos < end) { - let [fieldNo, wireType] = reader.tag(); - switch (fieldNo) { - case 1: - message.adsControl = Any.internalBinaryRead( - reader, - reader.uint32(), - options, - message.adsControl - ); - break; - default: - let u = options.readUnknownField; - if (u === 'throw') - throw new globalThis.Error( - `Unknown field ${fieldNo}(wire type ${wireType})for ${this.typeName}` - ); - let d = reader.skip(wireType); - if (u !== false) - (u === true - ? UnknownFieldHandler.onRead - : u)( - this.typeName, - message, - fieldNo, - wireType, - d - ); - } - } - return message; - } - internalBinaryWrite(message, writer, options) { - if (message.adsControl) - Any.internalBinaryWrite( - message.adsControl, - writer - .tag(1, WireType.LengthDelimited) - .fork(), - options - ).join(); - let u = options.writeUnknownFields; - if (u !== false) - (u == true ? UnknownFieldHandler.onWrite : u)( - this.typeName, - message, - writer - ); - return writer; - } - } - const CMConfig = new CMConfig$Type(); - class CmIpad$Type extends MessageType { - constructor() { - super('CmIpad', [ - { - no: 5, - name: 'aid', - kind: 'scalar', - T: 3, - L: 0, - }, - ]); - } - create(value) { - const message = { aid: 0n }; - globalThis.Object.defineProperty( - message, - MESSAGE_TYPE, - { enumerable: false, value: this } - ); - if (value !== undefined) - reflectionMergePartial(this, message, value); - return message; - } - internalBinaryRead( - reader, - length, - options, - target - ) { - let message = target ?? this.create(), - end = reader.pos + length; - while (reader.pos < end) { - let [fieldNo, wireType] = reader.tag(); - switch (fieldNo) { - case 5: - message.aid = reader.int64().toBigInt(); - break; - default: - let u = options.readUnknownField; - if (u === 'throw') - throw new globalThis.Error( - `Unknown field ${fieldNo}(wire type ${wireType})for ${this.typeName}` - ); - let d = reader.skip(wireType); - if (u !== false) - (u === true - ? UnknownFieldHandler.onRead - : u)( - this.typeName, - message, - fieldNo, - wireType, - d - ); - } - } - return message; - } - internalBinaryWrite(message, writer, options) { - if (message.aid !== 0n) - writer - .tag(5, WireType.Varint) - .int64(message.aid); - let u = options.writeUnknownFields; - if (u !== false) - (u == true ? UnknownFieldHandler.onWrite : u)( - this.typeName, - message, - writer - ); - return writer; - } - } - const CmIpad = new CmIpad$Type(); - class TIcon$Type extends MessageType { - constructor() { - super('TIcon', [ - { no: 1, name: 'icon', kind: 'scalar', T: 9 }, - ]); - } - create(value) { - const message = { icon: '' }; - globalThis.Object.defineProperty( - message, - MESSAGE_TYPE, - { enumerable: false, value: this } - ); - if (value !== undefined) - reflectionMergePartial(this, message, value); - return message; - } - internalBinaryRead( - reader, - length, - options, - target - ) { - let message = target ?? this.create(), - end = reader.pos + length; - while (reader.pos < end) { - let [fieldNo, wireType] = reader.tag(); - switch (fieldNo) { - case 1: - message.icon = reader.string(); - break; - default: - let u = options.readUnknownField; - if (u === 'throw') - throw new globalThis.Error( - `Unknown field ${fieldNo}(wire type ${wireType})for ${this.typeName}` - ); - let d = reader.skip(wireType); - if (u !== false) - (u === true - ? UnknownFieldHandler.onRead - : u)( - this.typeName, - message, - fieldNo, - wireType, - d - ); - } - } - return message; - } - internalBinaryWrite(message, writer, options) { - if (message.icon !== '') - writer - .tag(1, WireType.LengthDelimited) - .string(message.icon); - let u = options.writeUnknownFields; - if (u !== false) - (u == true ? UnknownFieldHandler.onWrite : u)( - this.typeName, - message, - writer - ); - return writer; - } - } - const TIcon = new TIcon$Type(); - class Relate$Type extends MessageType { - constructor() { - super('Relate', [ - { - no: 28, - name: 'cm', - kind: 'message', - T: () => CM, - }, - ]); - } - create(value) { - const message = {}; - globalThis.Object.defineProperty( - message, - MESSAGE_TYPE, - { enumerable: false, value: this } - ); - if (value !== undefined) - reflectionMergePartial(this, message, value); - return message; - } - internalBinaryRead( - reader, - length, - options, - target - ) { - let message = target ?? this.create(), - end = reader.pos + length; - while (reader.pos < end) { - let [fieldNo, wireType] = reader.tag(); - switch (fieldNo) { - case 28: - message.cm = CM.internalBinaryRead( - reader, - reader.uint32(), - options, - message.cm - ); - break; - default: - let u = options.readUnknownField; - if (u === 'throw') - throw new globalThis.Error( - `Unknown field ${fieldNo}(wire type ${wireType})for ${this.typeName}` - ); - let d = reader.skip(wireType); - if (u !== false) - (u === true - ? UnknownFieldHandler.onRead - : u)( - this.typeName, - message, - fieldNo, - wireType, - d - ); - } - } - return message; - } - internalBinaryWrite(message, writer, options) { - if (message.cm) - CM.internalBinaryWrite( - message.cm, - writer - .tag(28, WireType.LengthDelimited) - .fork(), - options - ).join(); - let u = options.writeUnknownFields; - if (u !== false) - (u == true ? UnknownFieldHandler.onWrite : u)( - this.typeName, - message, - writer - ); - return writer; - } - } - const Relate = new Relate$Type(); - /****************** initialization finish ******************/ - switch (Settings?.Detail?.view) { - case true: + case ScalarType.BOOL: + return "boolean" == a; + case ScalarType.STRING: + return "string" == a; + case ScalarType.BYTES: + return e instanceof Uint8Array; + case ScalarType.DOUBLE: + case ScalarType.FLOAT: + return "number" == a && !isNaN(e); default: - let data = ViewReply.fromBinary(body); - if (data.cms?.length) { - data.cms = []; - $.log(`🎉 ${$.name}`, '播放页广告卡片去除'); - } - if (data.relates?.length) { - data.relates = data.relates.filter((item) => { - if (item.cm) { - $.log( - `🎉 ${$.name}`, - '播放页关联推荐广告去除' - ); - return false; - } - return true; - }); - } - if (data.cmConfig || data.cmIpad) { - delete data.cmConfig; - delete data.cmIpad; - $.log(`🎉 ${$.name}`, '播放页定制tab去除'); - } - for (const i in data.tIcon) { - if (data.tIcon[i] === null) { - // 解决tIcon的null is not an object问题 - // console.log(`tIconMap:${i}`); - delete data.tIcon[i]; - } - } - body = ViewReply.toBinary(data); - break; - case false: - $.log(`🚧 ${$.name}`, '用户设置播放页广告不去除'); - break; - } - break; - case 'TFInfo': - /****************** initialization start *******************/ - // protobuf/bilibili/app/view/view.proto - class TFInfoReply$Type extends MessageType { - constructor() { - super('TFInfoReply', [ - { - no: 1, - name: 'tipsId', - kind: 'scalar', - T: 3, - L: 0, - }, - { - no: 2, - name: 'tfToast', - kind: 'message', - T: () => TFToast, - }, - { - no: 3, - name: 'tfPanelCustomized', - kind: 'message', - T: () => TFPanelCustomized, - }, - ]); - } - create(value) { - const message = { tipsId: 0n }; - globalThis.Object.defineProperty( - message, - MESSAGE_TYPE, - { enumerable: false, value: this } - ); - if (value !== undefined) - reflectionMergePartial(this, message, value); - return message; - } - internalBinaryRead( - reader, - length, - options, - target - ) { - let message = target ?? this.create(), - end = reader.pos + length; - while (reader.pos < end) { - let [fieldNo, wireType] = reader.tag(); - switch (fieldNo) { - case 1: - message.tipsId = reader.int64().toBigInt(); - break; - case 2: - message.tfToast = - TFToast.internalBinaryRead( - reader, - reader.uint32(), - options, - message.tfToast - ); - break; - case 3: - message.tfPanelCustomized = - TFPanelCustomized.internalBinaryRead( - reader, - reader.uint32(), - options, - message.tfPanelCustomized - ); - break; - default: - let u = options.readUnknownField; - if (u === 'throw') - throw new globalThis.Error( - `Unknown field ${fieldNo}(wire type ${wireType})for ${this.typeName}` - ); - let d = reader.skip(wireType); - if (u !== false) - (u === true - ? UnknownFieldHandler.onRead - : u)( - this.typeName, - message, - fieldNo, - wireType, - d - ); - } - } - return message; - } - internalBinaryWrite(message, writer, options) { - if (message.tipsId !== 0n) - writer - .tag(1, WireType.Varint) - .int64(message.tipsId); - if (message.tfToast) - TFToast.internalBinaryWrite( - message.tfToast, - writer - .tag(2, WireType.LengthDelimited) - .fork(), - options - ).join(); - if (message.tfPanelCustomized) - TFPanelCustomized.internalBinaryWrite( - message.tfPanelCustomized, - writer - .tag(3, WireType.LengthDelimited) - .fork(), - options - ).join(); - let u = options.writeUnknownFields; - if (u !== false) - (u == true ? UnknownFieldHandler.onWrite : u)( - this.typeName, - message, - writer - ); - return writer; - } - } - const TFInfoReply = new TFInfoReply$Type(); - class TFToast$Type extends MessageType { - constructor() { - super('TFToast', [ - { - no: 1, - name: 'btnText', - kind: 'scalar', - T: 9, - }, - ]); - } - create(value) { - const message = { btnText: '' }; - globalThis.Object.defineProperty( - message, - MESSAGE_TYPE, - { enumerable: false, value: this } - ); - if (value !== undefined) - reflectionMergePartial(this, message, value); - return message; - } - internalBinaryRead( - reader, - length, - options, - target - ) { - let message = target ?? this.create(), - end = reader.pos + length; - while (reader.pos < end) { - let [fieldNo, wireType] = reader.tag(); - switch (fieldNo) { - case 1: - message.btnText = reader.string(); - break; - default: - let u = options.readUnknownField; - if (u === 'throw') - throw new globalThis.Error( - `Unknown field ${fieldNo}(wire type ${wireType})for ${this.typeName}` - ); - let d = reader.skip(wireType); - if (u !== false) - (u === true - ? UnknownFieldHandler.onRead - : u)( - this.typeName, - message, - fieldNo, - wireType, - d - ); - } - } - return message; - } - internalBinaryWrite(message, writer, options) { - if (message.btnText !== '') - writer - .tag(1, WireType.LengthDelimited) - .string(message.btnText); - let u = options.writeUnknownFields; - if (u !== false) - (u == true ? UnknownFieldHandler.onWrite : u)( - this.typeName, - message, - writer - ); - return writer; - } - } - const TFToast = new TFToast$Type(); - class TFPanelCustomized$Type extends MessageType { - constructor() { - super('TFPanelCustomized', [ - { - no: 2, - name: 'rightBtnText', - kind: 'scalar', - T: 9, - }, - ]); - } - create(value) { - const message = { rightBtnText: '' }; - globalThis.Object.defineProperty( - message, - MESSAGE_TYPE, - { enumerable: false, value: this } - ); - if (value !== undefined) - reflectionMergePartial(this, message, value); - return message; - } - internalBinaryRead( - reader, - length, - options, - target - ) { - let message = target ?? this.create(), - end = reader.pos + length; - while (reader.pos < end) { - let [fieldNo, wireType] = reader.tag(); - switch (fieldNo) { - case 2: - message.rightBtnText = reader.string(); - break; - default: - let u = options.readUnknownField; - if (u === 'throw') - throw new globalThis.Error( - `Unknown field ${fieldNo}(wire type ${wireType})for ${this.typeName}` - ); - let d = reader.skip(wireType); - if (u !== false) - (u === true - ? UnknownFieldHandler.onRead - : u)( - this.typeName, - message, - fieldNo, - wireType, - d - ); - } - } - return message; - } - internalBinaryWrite(message, writer, options) { - if (message.rightBtnText !== '') - writer - .tag(2, WireType.LengthDelimited) - .string(message.rightBtnText); - let u = options.writeUnknownFields; - if (u !== false) - (u == true ? UnknownFieldHandler.onWrite : u)( - this.typeName, - message, - writer - ); - return writer; - } - } - const TFPanelCustomized = - new TFPanelCustomized$Type(); - /****************** initialization finish ******************/ - let data = TFInfoReply.fromBinary(body); - $.log(data.tipsId); - if (data?.tipsId) { - delete data.tfToast; - delete data.tfPanelCustomized; - $.log(`🎉 ${$.name}`, '播放页办卡免流广告去除'); - } - body = TFInfoReply.toBinary(data); - break; - } - break; - case 'bilibili.app.interface.v1.Teenagers': // 青少年模式 - class ModeStatus$Type extends MessageType { - constructor() { - super('ModeStatus', [ - { - no: 1, - name: 'modes', - kind: 'message', - repeat: 1, - T: () => Mode, - }, - ]); + return "number" == a && Number.isInteger(e) } - create(value) { - const message = { modes: [] }; - globalThis.Object.defineProperty( - message, - MESSAGE_TYPE, - { enumerable: false, value: this } - ); - if (value !== undefined) - reflectionMergePartial(this, message, value); - return message; - } - internalBinaryRead(reader, length, options, target) { - let message = target ?? this.create(), - end = reader.pos + length; - while (reader.pos < end) { - let [fieldNo, wireType] = reader.tag(); - switch (fieldNo) { - case 1: - message.modes.push( - Mode.internalBinaryRead( - reader, - reader.uint32(), - options - ) - ); - break; - default: - let u = options.readUnknownField; - if (u === 'throw') - throw new globalThis.Error( - `Unknown field ${fieldNo}(wire type ${wireType})for ${this.typeName}` - ); - let d = reader.skip(wireType); - if (u !== false) - (u === true ? UnknownFieldHandler.onRead : u)( - this.typeName, - message, - fieldNo, - wireType, - d - ); - } - } - return message; - } - internalBinaryWrite(message, writer, options) { - for (let i = 0; i < message.modes.length; i++) - Mode.internalBinaryWrite( - message.modes[i], - writer.tag(1, WireType.LengthDelimited).fork(), - options - ).join(); - let u = options.writeUnknownFields; - if (u !== false) - (u == true ? UnknownFieldHandler.onWrite : u)( - this.typeName, - message, - writer - ); - return writer; - } - } - const ModeStatus = new ModeStatus$Type(); - class Mode$Type extends MessageType { - constructor() { - super('Mode', [ - { no: 2, name: 'name', kind: 'scalar', T: 9 }, - { no: 5, name: 'f5', kind: 'message', T: () => F5 }, - ]); - } - create(value) { - const message = { name: '' }; - globalThis.Object.defineProperty( - message, - MESSAGE_TYPE, - { enumerable: false, value: this } - ); - if (value !== undefined) - reflectionMergePartial(this, message, value); - return message; - } - internalBinaryRead(reader, length, options, target) { - let message = target ?? this.create(), - end = reader.pos + length; - while (reader.pos < end) { - let [fieldNo, wireType] = reader.tag(); - switch (fieldNo) { - case 2: - message.name = reader.string(); - break; - case 5: - message.f5 = F5.internalBinaryRead( - reader, - reader.uint32(), - options, - message.f5 - ); - break; - default: - let u = options.readUnknownField; - if (u === 'throw') - throw new globalThis.Error( - `Unknown field ${fieldNo}(wire type ${wireType})for ${this.typeName}` - ); - let d = reader.skip(wireType); - if (u !== false) - (u === true ? UnknownFieldHandler.onRead : u)( - this.typeName, - message, - fieldNo, - wireType, - d - ); - } - } - return message; - } - internalBinaryWrite(message, writer, options) { - if (message.name !== '') - writer - .tag(2, WireType.LengthDelimited) - .string(message.name); - if (message.f5) - F5.internalBinaryWrite( - message.f5, - writer.tag(5, WireType.LengthDelimited).fork(), - options - ).join(); - let u = options.writeUnknownFields; - if (u !== false) - (u == true ? UnknownFieldHandler.onWrite : u)( - this.typeName, - message, - writer - ); - return writer; - } - } - const Mode = new Mode$Type(); - class F5$Type extends MessageType { - constructor() { - super('F5', [ - { no: 1, name: 'f1', kind: 'scalar', T: 5 }, - ]); - } - create(value) { - const message = { f1: 0 }; - globalThis.Object.defineProperty( - message, - MESSAGE_TYPE, - { enumerable: false, value: this } - ); - if (value !== undefined) - reflectionMergePartial(this, message, value); - return message; - } - internalBinaryRead(reader, length, options, target) { - let message = target ?? this.create(), - end = reader.pos + length; - while (reader.pos < end) { - let [fieldNo, wireType] = reader.tag(); - switch (fieldNo) { - case 1: - message.f1 = reader.int32(); - break; - default: - let u = options.readUnknownField; - if (u === 'throw') - throw new globalThis.Error( - `Unknown field ${fieldNo}(wire type ${wireType})for ${this.typeName}` - ); - let d = reader.skip(wireType); - if (u !== false) - (u === true ? UnknownFieldHandler.onRead : u)( - this.typeName, - message, - fieldNo, - wireType, - d - ); - } - } - return message; - } - internalBinaryWrite(message, writer, options) { - if (message.f1 !== 0) - writer.tag(1, WireType.Varint).int32(message.f1); - let u = options.writeUnknownFields; - if (u !== false) - (u == true ? UnknownFieldHandler.onWrite : u)( - this.typeName, - message, - writer - ); - return writer; - } - } - const F5 = new F5$Type(); - switch (PATHs?.[1]) { - case 'ModeStatus': // 青少年模式 - data = ModeStatus.fromBinary(body); - data.modes = data.modes.map((mode) => { - if (mode?.name === 'teenagers') { - if (mode?.f5?.f1) { - mode.f5.f1 = 0; - $.log(`🎉 ${$.name}`, '青少年模式弹窗去除'); - } - } - return mode; - }); - body = ModeStatus.toBinary(data); - break; - } - break; - case 'bilibili.community.service.dm.v1.DM': //弹幕 - class CommandDm$Type extends MessageType { - constructor() { - super('CommandDm', [ - { no: 1, name: 'id', kind: 'scalar', T: 3, L: 0 }, - ]); - } - create(value) { - const message = { id: 0n }; - globalThis.Object.defineProperty( - message, - MESSAGE_TYPE, - { enumerable: false, value: this } - ); - if (value !== undefined) - reflectionMergePartial(this, message, value); - return message; - } - internalBinaryRead(reader, length, options, target) { - let message = target ?? this.create(), - end = reader.pos + length; - while (reader.pos < end) { - let [fieldNo, wireType] = reader.tag(); - switch (fieldNo) { - case 1: - message.id = reader.int64().toBigInt(); - break; - default: - let u = options.readUnknownField; - if (u === 'throw') - throw new globalThis.Error( - `Unknown field ${fieldNo}(wire type ${wireType})for ${this.typeName}` - ); - let d = reader.skip(wireType); - if (u !== false) - (u === true ? UnknownFieldHandler.onRead : u)( - this.typeName, - message, - fieldNo, - wireType, - d - ); - } - } - return message; - } - internalBinaryWrite(message, writer, options) { - if (message.id !== 0n) - writer.tag(1, WireType.Varint).int64(message.id); - let u = options.writeUnknownFields; - if (u !== false) - (u == true ? UnknownFieldHandler.onWrite : u)( - this.typeName, - message, - writer - ); - return writer; - } - } - const CommandDm = new CommandDm$Type(); - class DmView$Type extends MessageType { - constructor() { - super('DmView', [ - { - no: 1, - name: 'commandDms', - kind: 'message', - repeat: 1, - T: () => CommandDm, - }, - ]); - } - create(value) { - const message = { commandDms: [] }; - globalThis.Object.defineProperty( - message, - MESSAGE_TYPE, - { enumerable: false, value: this } - ); - if (value !== undefined) - reflectionMergePartial(this, message, value); - return message; - } - internalBinaryRead(reader, length, options, target) { - let message = target ?? this.create(), - end = reader.pos + length; - while (reader.pos < end) { - let [fieldNo, wireType] = reader.tag(); - switch (fieldNo) { - case 1: - message.commandDms.push( - CommandDm.internalBinaryRead( - reader, - reader.uint32(), - options - ) - ); - break; - default: - let u = options.readUnknownField; - if (u === 'throw') - throw new globalThis.Error( - `Unknown field ${fieldNo}(wire type ${wireType})for ${this.typeName}` - ); - let d = reader.skip(wireType); - if (u !== false) - (u === true ? UnknownFieldHandler.onRead : u)( - this.typeName, - message, - fieldNo, - wireType, - d - ); - } - } - return message; - } - internalBinaryWrite(message, writer, options) { - for (let i = 0; i < message.commandDms.length; i++) - CommandDm.internalBinaryWrite( - message.commandDms[i], - writer.tag(1, WireType.LengthDelimited).fork(), - options - ).join(); - let u = options.writeUnknownFields; - if (u !== false) - (u == true ? UnknownFieldHandler.onWrite : u)( - this.typeName, - message, - writer - ); - return writer; - } - } - const DmView = new DmView$Type(); - class DmViewReply$Type extends MessageType { - constructor() { - super('DmViewReply', [ - { - no: 22, - name: 'dmView', - kind: 'message', - T: () => DmView, - }, - ]); - } - create(value) { - const message = {}; - globalThis.Object.defineProperty( - message, - MESSAGE_TYPE, - { enumerable: false, value: this } - ); - if (value !== undefined) - reflectionMergePartial(this, message, value); - return message; - } - internalBinaryRead(reader, length, options, target) { - let message = target ?? this.create(), - end = reader.pos + length; - while (reader.pos < end) { - let [fieldNo, wireType] = reader.tag(); - switch (fieldNo) { - case 22: - message.dmView = DmView.internalBinaryRead( - reader, - reader.uint32(), - options, - message.dmView - ); - break; - default: - let u = options.readUnknownField; - if (u === 'throw') - throw new globalThis.Error( - `Unknown field ${fieldNo}(wire type ${wireType})for ${this.typeName}` - ); - let d = reader.skip(wireType); - if (u !== false) - (u === true ? UnknownFieldHandler.onRead : u)( - this.typeName, - message, - fieldNo, - wireType, - d - ); - } - } - return message; - } - internalBinaryWrite(message, writer, options) { - if (message.dmView) - DmView.internalBinaryWrite( - message.dmView, - writer.tag(22, WireType.LengthDelimited).fork(), - options - ).join(); - let u = options.writeUnknownFields; - if (u !== false) - (u == true ? UnknownFieldHandler.onWrite : u)( - this.typeName, - message, - writer - ); - return writer; - } - } - const DmViewReply = new DmViewReply$Type(); - class DmSegMobileReply$Type extends MessageType { - constructor() { - super('DmSegMobileReply', [ - { - no: 1, - name: 'elems', - kind: 'message', - repeat: 1, - T: () => DanmakuElem, - }, - ]); - } - create(value) { - const message = { elems: [] }; - globalThis.Object.defineProperty( - message, - MESSAGE_TYPE, - { enumerable: false, value: this } - ); - if (value !== undefined) - reflectionMergePartial(this, message, value); - return message; - } - internalBinaryRead(reader, length, options, target) { - let message = target ?? this.create(), - end = reader.pos + length; - while (reader.pos < end) { - let [fieldNo, wireType] = reader.tag(); - switch (fieldNo) { - case 1: - message.elems.push( - DanmakuElem.internalBinaryRead( - reader, - reader.uint32(), - options - ) - ); - break; - default: - let u = options.readUnknownField; - if (u === 'throw') - throw new globalThis.Error( - `Unknown field ${fieldNo}(wire type ${wireType})for ${this.typeName}` - ); - let d = reader.skip(wireType); - if (u !== false) - (u === true ? UnknownFieldHandler.onRead : u)( - this.typeName, - message, - fieldNo, - wireType, - d - ); - } - } - return message; - } - internalBinaryWrite(message, writer, options) { - for (let i = 0; i < message.elems.length; i++) - DanmakuElem.internalBinaryWrite( - message.elems[i], - writer.tag(1, WireType.LengthDelimited).fork(), - options - ).join(); - let u = options.writeUnknownFields; - if (u !== false) - (u == true ? UnknownFieldHandler.onWrite : u)( - this.typeName, - message, - writer - ); - return writer; - } - } - const DmSegMobileReply = new DmSegMobileReply$Type(); - class DanmakuElem$Type extends MessageType { - constructor() { - super('DanmakuElem', [ - { no: 24, name: 'colorful', kind: 'scalar', T: 5 }, - ]); - } - create(value) { - const message = { colorful: 0 }; - globalThis.Object.defineProperty( - message, - MESSAGE_TYPE, - { enumerable: false, value: this } - ); - if (value !== undefined) - reflectionMergePartial(this, message, value); - return message; - } - internalBinaryRead(reader, length, options, target) { - let message = target ?? this.create(), - end = reader.pos + length; - while (reader.pos < end) { - let [fieldNo, wireType] = reader.tag(); - switch (fieldNo) { - case 24: - message.colorful = reader.int32(); - break; - default: - let u = options.readUnknownField; - if (u === 'throw') - throw new globalThis.Error( - `Unknown field ${fieldNo}(wire type ${wireType})for ${this.typeName}` - ); - let d = reader.skip(wireType); - if (u !== false) - (u === true ? UnknownFieldHandler.onRead : u)( - this.typeName, - message, - fieldNo, - wireType, - d - ); - } - } - return message; - } - internalBinaryWrite(message, writer, options) { - if (message.colorful !== 0) - writer - .tag(24, WireType.Varint) - .int32(message.colorful); - let u = options.writeUnknownFields; - if (u !== false) - (u == true ? UnknownFieldHandler.onWrite : u)( - this.typeName, - message, - writer - ); - return writer; - } - } - const DanmakuElem = new DanmakuElem$Type(); - switch (PATHs?.[1]) { - case 'DmView': // 弹幕配置 - switch (Settings?.Detail?.commandDms) { - case true: - let data = DmViewReply.fromBinary(body); - if (data.dmView?.commandDms?.length) { - data.dmView.commandDms.length = 0; - $.log(`🎉 ${$.name}`, '交互式弹幕去除'); - } - body = DmViewReply.toBinary(data); - break; - case false: + } + + scalars(r, t, a, n) { + if (!Array.isArray(r)) return !1; + if (!(a < 2) && Array.isArray(r)) for (let e = 0; e < r.length && e < a; e++) if (!this.scalar(r[e], t, n)) return !1; + return !0 + } + + mapKeys(e, r, t) { + var a = Object.keys(e); + switch (r) { + case ScalarType.INT32: + case ScalarType.FIXED32: + case ScalarType.SFIXED32: + case ScalarType.SINT32: + case ScalarType.UINT32: + return this.scalars(a.slice(0, t).map((e => parseInt(e))), r, t); + case ScalarType.BOOL: + return this.scalars(a.slice(0, t).map((e => "true" == e || "false" != e && e)), r, t); default: - $.log(`🎉 ${$.name}`, '用户设置交互式弹幕不去除'); - break; - } - break; - case 'DmSegMobile': // 弹幕列表 - switch (Settings?.Detail?.colorfulDms) { - case true: - let data = DmSegMobileReply.fromBinary(body); - data.elems = data.elems.map((ele) => { - if (ele?.colorful === 60001) { - ele.colorful = 0; - } - return ele; - }); - $.log(`🎉 ${$.name}`, '会员弹幕已替换为普通弹幕'); - body = DmSegMobileReply.toBinary(data); - break; - case false: + return this.scalars(a, r, t, LongType.STRING) + } + } + } + + function typeofJsonValue(e) { + var r = typeof e; + if ("object" == r) { + if (Array.isArray(e)) return "array"; + if (null === e) return "null" + } + return r + } + + function isJsonObject(e) { + return null !== e && "object" == typeof e && !Array.isArray(e) + } + + let encTable = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".split(""), + decTable = []; + for (let e = 0; e < encTable.length; e++) decTable[encTable[e].charCodeAt(0)] = e; + + function base64decode(r) { + let e = 3 * r.length / 4, + t = ("=" == r[r.length - 2] ? e -= 2 : "=" == r[r.length - 1] && --e, new Uint8Array(e)), a = 0, + n = 0, s, i = 0; + for (let e = 0; e < r.length; e++) { + if (void 0 === (s = decTable[r.charCodeAt(e)])) switch (r[e]) { + case"=": + n = 0; + case"\n": + case"\r": + case"\t": + case" ": + continue; default: - $.log(`🎉 ${$.name}`, '用户设置会员弹幕不修改'); - break; - } - break; - } - break; - case 'bilibili.main.community.reply.v1.Reply': - class MainListReply$Type extends MessageType { - constructor() { - super('MainListReply', [ - { - no: 11, - name: 'cm', - kind: 'message', - T: () => CM, - }, - ]); + throw Error("invalid base64 string.") } - create(value) { - const message = {}; - globalThis.Object.defineProperty( - message, - MESSAGE_TYPE, - { enumerable: false, value: this } - ); - if (value !== undefined) - reflectionMergePartial(this, message, value); - return message; - } - internalBinaryRead(reader, length, options, target) { - let message = target ?? this.create(), - end = reader.pos + length; - while (reader.pos < end) { - let [fieldNo, wireType] = reader.tag(); - switch (fieldNo) { - case 11: - message.cm = CM.internalBinaryRead( - reader, - reader.uint32(), - options, - message.cm - ); + switch (n) { + case 0: + i = s, n = 1; break; - default: - let u = options.readUnknownField; - if (u === 'throw') - throw new globalThis.Error( - `Unknown field ${fieldNo}(wire type ${wireType})for ${this.typeName}` - ); - let d = reader.skip(wireType); - if (u !== false) - (u === true ? UnknownFieldHandler.onRead : u)( - this.typeName, - message, - fieldNo, - wireType, - d - ); - } - } - return message; + case 1: + t[a++] = i << 2 | (48 & s) >> 4, i = s, n = 2; + break; + case 2: + t[a++] = (15 & i) << 4 | (60 & s) >> 2, i = s, n = 3; + break; + case 3: + t[a++] = (3 & i) << 6 | s, n = 0 } - internalBinaryWrite(message, writer, options) { - if (message.cm) - CM.internalBinaryWrite( - message.cm, - writer.tag(11, WireType.LengthDelimited).fork(), - options - ).join(); - let u = options.writeUnknownFields; - if (u !== false) - (u == true ? UnknownFieldHandler.onWrite : u)( - this.typeName, - message, - writer - ); - return writer; + } + if (1 == n) throw Error("invalid base64 string."); + return t.subarray(0, a) + } + + function base64encode(r) { + let t = "", a = 0, n, s = 0; + for (let e = 0; e < r.length; e++) switch (n = r[e], a) { + case 0: + t += encTable[n >> 2], s = (3 & n) << 4, a = 1; + break; + case 1: + t += encTable[s | n >> 4], s = (15 & n) << 2, a = 2; + break; + case 2: + t = (t += encTable[s | n >> 6]) + encTable[63 & n], a = 0 + } + return a && (t = t + encTable[s] + "=", 1 == a && (t += "=")), t + } + + function reflectionLongConvert(e, r) { + switch (r) { + case LongType.BIGINT: + return e.toBigInt(); + case LongType.NUMBER: + return e.toNumber(); + default: + return e.toString() + } + } + + decTable["-".charCodeAt(0)] = encTable.indexOf("+"), decTable["_".charCodeAt(0)] = encTable.indexOf("/"); + + class ReflectionJsonReader { + constructor(e) { + this.info = e + } + + prepare() { + var e; + if (void 0 === this.fMap) { + this.fMap = {}; + for (const r of null != (e = this.info.fields) ? e : []) this.fMap[r.name] = r, this.fMap[r.jsonName] = r, this.fMap[r.localName] = r } - } - const MainListReply = new MainListReply$Type(); - switch (PATHs?.[1]) { - case 'MainList': - switch (Settings?.Detail?.MainList) { - case true: - default: - let data = MainListReply.fromBinary(body); - delete data.cm; - body = MainListReply.toBinary(data); - $.log(`🎉 ${$.name}`, '评论列表广告去除'); - break; - case false: - $.log( - `🎉 ${$.name}`, - '用户设置评论列表广告不去除' - ); - break; - } - break; - } - break; - case 'bilibili.pgc.gateway.player.v2.PlayURL': // 番剧 - /****************** initialization start *******************/ - /****************** initialization finish *******************/ - switch (PATHs?.[1]) { - case 'PlayView': // 播放地址 - /****************** initialization start *******************/ - /****************** initialization finish *******************/ - break; - case 'PlayConf': // 播放配置 - break; - } - break; - case 'bilibili.app.nativeact.v1.NativeAct': // 活动-节目、动画、韩综(港澳台) - switch (PATHs?.[1]) { - case 'Index': // 首页 - break; - } - break; - case 'bilibili.app.interface.v1.Search': // 搜索框 - switch (PATHs?.[1]) { - case 'Suggest3': // 搜索建议 - break; - } - break; - case 'bilibili.polymer.app.search.v1.Search': // 搜索结果 - /****************** initialization start *******************/ - /****************** initialization finish *******************/ - switch (PATHs?.[1]) { - case 'SearchAll': { - // 全部结果(综合) - /****************** initialization start *******************/ - class SearchAllResponse$Type extends MessageType { - constructor() { - super('SearchAllResponse', [ - { - no: 4, - name: 'item', - kind: 'message', - repeat: 1, - T: () => Item, - }, - ]); + } + + assert(e, r, t) { + if (!e) { + let e = typeofJsonValue(t); + throw "number" != e && "boolean" != e || (e = t.toString()), new Error(`Cannot parse JSON ${e} for ${this.info.typeName}#` + r) + } + } + + read(e, r, t) { + this.prepare(); + var a, n, s = []; + for ([a, n] of Object.entries(e)) { + var i = this.fMap[a]; + if (!i) { + if (t.ignoreUnknownFields) continue; + throw new Error(`Found unknown field while reading ${this.info.typeName} from JSON format. JSON key: ` + a) } - create(value) { - const message = { item: [] }; - globalThis.Object.defineProperty( - message, - MESSAGE_TYPE, - { enumerable: false, value: this } - ); - if (value !== undefined) - reflectionMergePartial(this, message, value); - return message; - } - internalBinaryRead( - reader, - length, - options, - target - ) { - let message = target ?? this.create(), - end = reader.pos + length; - while (reader.pos < end) { - let [fieldNo, wireType] = reader.tag(); - switch (fieldNo) { - case 4: - message.item.push( - Item.internalBinaryRead( - reader, - reader.uint32(), - options - ) - ); - break; - default: - let u = options.readUnknownField; - if (u === 'throw') - throw new globalThis.Error( - `Unknown field ${fieldNo}(wire type ${wireType})for ${this.typeName}` - ); - let d = reader.skip(wireType); - if (u !== false) - (u === true - ? UnknownFieldHandler.onRead - : u)( - this.typeName, - message, - fieldNo, - wireType, - d - ); + var o = i.localName; + let e; + if (i.oneof) { + if (s.includes(i.oneof)) throw new Error(`Multiple members of the oneof group "${i.oneof}" of ${this.info.typeName} are present in JSON.`); + s.push(i.oneof), e = r[i.oneof] = {oneofKind: o} + } else e = r; + if ("map" == i.kind) { + if (null !== n) { + this.assert(isJsonObject(n), i.name, n); + var l, c, u = e[o]; + for ([l, c] of Object.entries(n)) { + this.assert(null !== c, i.name + " map value", null); + let e; + switch (i.V.kind) { + case"message": + e = i.V.T().internalJsonRead(c, t); + break; + case"enum": + if (!1 === (e = this.enum(i.V.T(), c, i.name, t.ignoreUnknownFields))) continue; + break; + case"scalar": + e = this.scalar(c, i.V.T, i.V.L, i.name) + } + this.assert(void 0 !== e, i.name + " map value", c); + let r = l; + i.K == ScalarType.BOOL && (r = "true" == r || "false" != r && r), u[r = this.scalar(r, i.K, LongType.STRING, i.name).toString()] = e + } } - } - return message; + } else if (i.repeat) { + if (null !== n) { + this.assert(Array.isArray(n), i.name, n); + var f = e[o]; + for (const p of n) { + this.assert(null !== p, i.name, null); + let e; + switch (i.kind) { + case"message": + e = i.T().internalJsonRead(p, t); + break; + case"enum": + if (!1 === (e = this.enum(i.T(), p, i.name, t.ignoreUnknownFields))) continue; + break; + case"scalar": + e = this.scalar(p, i.T, i.L, i.name) + } + this.assert(void 0 !== e, i.name, n), f.push(e) + } + } + } else switch (i.kind) { + case"message": + null === n && "google.protobuf.Value" != i.T().typeName ? this.assert(void 0 === i.oneof, i.name + " (oneof member)", null) : e[o] = i.T().internalJsonRead(n, t, e[o]); + break; + case"enum": + var h = this.enum(i.T(), n, i.name, t.ignoreUnknownFields); + !1 !== h && (e[o] = h); + break; + case"scalar": + e[o] = this.scalar(n, i.T, i.L, i.name) } - internalBinaryWrite(message, writer, options) { - for (let i = 0; i < message.item.length; i++) - Item.internalBinaryWrite( - message.item[i], - writer - .tag(4, WireType.LengthDelimited) - .fork(), - options - ).join(); - let u = options.writeUnknownFields; - if (u !== false) - (u == true ? UnknownFieldHandler.onWrite : u)( - this.typeName, - message, - writer - ); - return writer; + } + } + + enum(r, t, a, n) { + if ("google.protobuf.NullValue" == r[0] && assert(null === t, `Unable to parse field ${this.info.typeName}#${a}, enum ${r[0]} only accepts null.`), null === t) return 0; + switch (typeof t) { + case"number": + return assert(Number.isInteger(t), `Unable to parse field ${this.info.typeName}#${a}, enum can only be integral number, got ${t}.`), t; + case"string": + let e = t; + r[2] && t.substring(0, r[2].length) === r[2] && (e = t.substring(r[2].length)); + var s = r[1][e]; + return void 0 === s && n ? !1 : (assert("number" == typeof s, `Unable to parse field ${this.info.typeName}#${a}, enum ${r[0]} has no value for "${t}".`), s) + } + assert(!1, `Unable to parse field ${this.info.typeName}#${a}, cannot parse enum value from ${typeof t}".`) + } + + scalar(r, t, a, e) { + let n; + try { + switch (t) { + case ScalarType.DOUBLE: + case ScalarType.FLOAT: + if (null === r) return 0; + if ("NaN" === r) return Number.NaN; + if ("Infinity" === r) return Number.POSITIVE_INFINITY; + if ("-Infinity" === r) return Number.NEGATIVE_INFINITY; + if ("" === r) n = "empty string"; else if ("string" == typeof r && r.trim().length !== r.length) n = "extra whitespace"; else if ("string" == typeof r || "number" == typeof r) { + var s = Number(r); + if (Number.isNaN(s)) n = "not a number"; else { + if (Number.isFinite(s)) return t == ScalarType.FLOAT && assertFloat32(s), s; + n = "too large or small" + } + } + break; + case ScalarType.INT32: + case ScalarType.FIXED32: + case ScalarType.SFIXED32: + case ScalarType.SINT32: + case ScalarType.UINT32: + if (null === r) return 0; + let e; + if ("number" == typeof r ? e = r : "" === r ? n = "empty string" : "string" == typeof r && (r.trim().length !== r.length ? n = "extra whitespace" : e = Number(r)), void 0 === e) break; + return (t == ScalarType.UINT32 ? assertUInt32 : assertInt32)(e), e; + case ScalarType.INT64: + case ScalarType.SFIXED64: + case ScalarType.SINT64: + if (null === r) return reflectionLongConvert(PbLong.ZERO, a); + if ("number" != typeof r && "string" != typeof r) break; + return reflectionLongConvert(PbLong.from(r), a); + case ScalarType.FIXED64: + case ScalarType.UINT64: + if (null === r) return reflectionLongConvert(PbULong.ZERO, a); + if ("number" != typeof r && "string" != typeof r) break; + return reflectionLongConvert(PbULong.from(r), a); + case ScalarType.BOOL: + if (null === r) return !1; + if ("boolean" != typeof r) break; + return r; + case ScalarType.STRING: + if (null === r) return ""; + if ("string" != typeof r) { + n = "extra whitespace"; + break + } + try { + encodeURIComponent(r) + } catch (e) { + 0; + break + } + return r; + case ScalarType.BYTES: + if (null === r || "" === r) return new Uint8Array(0); + if ("string" != typeof r) break; + return base64decode(r) } - } - const SearchAllResponse = - new SearchAllResponse$Type(); - class Item$Type extends MessageType { - constructor() { - super('Item', [ - { - no: 25, - name: 'cm', - kind: 'message', - oneof: 'cardItem', - T: () => SearchAdCard, - }, - ]); + } catch (e) { + n = e.message + } + this.assert(!1, e + (n ? " - " + n : ""), r) + } + } + + class ReflectionJsonWriter { + constructor(e) { + this.fields = null != (e = e.fields) ? e : [] + } + + write(e, r) { + var t, a, n = {}, s = e; + for (const i of this.fields) i.oneof ? (t = s[i.oneof]).oneofKind === i.localName && (a = "scalar" == i.kind || "enum" == i.kind ? __spreadProps(__spreadValues({}, r), {emitDefaultValues: !0}) : r, assert(void 0 !== (t = this.field(i, t[i.localName], a))), n[r.useProtoFieldName ? i.name : i.jsonName] = t) : void 0 !== (a = this.field(i, s[i.localName], r)) && (n[r.useProtoFieldName ? i.name : i.jsonName] = a); + return n + } + + field(r, t, a) { + let e = void 0; + if ("map" == r.kind) { + assert("object" == typeof t && null !== t); + var n = {}; + switch (r.V.kind) { + case"scalar": + for (var [s, i] of Object.entries(t)) { + i = this.scalar(r.V.T, i, r.name, !1, !0); + assert(void 0 !== i), n[s.toString()] = i + } + break; + case"message": + var o, l, c = r.V.T(); + for ([o, l] of Object.entries(t)) { + var u = this.message(c, l, r.name, a); + assert(void 0 !== u), n[o.toString()] = u + } + break; + case"enum": + var f, h, p = r.V.T(); + for ([f, h] of Object.entries(t)) { + assert(void 0 === h || "number" == typeof h); + var d = this.enum(p, h, r.name, !1, !0, a.enumAsInteger); + assert(void 0 !== d), n[f.toString()] = d + } } - create(value) { - const message = { - cardItem: { oneofKind: undefined }, - }; - globalThis.Object.defineProperty( - message, - MESSAGE_TYPE, - { enumerable: false, value: this } - ); - if (value !== undefined) - reflectionMergePartial(this, message, value); - return message; + (a.emitDefaultValues || 0 < Object.keys(n).length) && (e = n) + } else if (r.repeat) { + assert(Array.isArray(t)); + var y = []; + switch (r.kind) { + case"scalar": + for (let e = 0; e < t.length; e++) { + var T = this.scalar(r.T, t[e], r.name, r.opt, !0); + assert(void 0 !== T), y.push(T) + } + break; + case"enum": + var g = r.T(); + for (let e = 0; e < t.length; e++) { + assert(void 0 === t[e] || "number" == typeof t[e]); + var b = this.enum(g, t[e], r.name, r.opt, !0, a.enumAsInteger); + assert(void 0 !== b), y.push(b) + } + break; + case"message": + var m = r.T(); + for (let e = 0; e < t.length; e++) { + var w = this.message(m, t[e], r.name, a); + assert(void 0 !== w), y.push(w) + } } - internalBinaryRead( - reader, - length, - options, - target - ) { - let message = target ?? this.create(), - end = reader.pos + length; - while (reader.pos < end) { - let [fieldNo, wireType] = reader.tag(); - switch (fieldNo) { - case 25: - message.cardItem = { - oneofKind: 'cm', - cm: SearchAdCard.internalBinaryRead( - reader, - reader.uint32(), - options, - message.cardItem.cm - ), + (a.emitDefaultValues || 0 < y.length || a.emitDefaultValues) && (e = y) + } else switch (r.kind) { + case"scalar": + e = this.scalar(r.T, t, r.name, r.opt, a.emitDefaultValues); + break; + case"enum": + e = this.enum(r.T(), t, r.name, r.opt, a.emitDefaultValues, a.enumAsInteger); + break; + case"message": + e = this.message(r.T(), t, r.name, a) + } + return e + } + + enum(e, r, t, a, n, s) { + if ("google.protobuf.NullValue" == e[0]) return null; + if (void 0 === r) assert(a); else if (0 !== r || n || a) return assert("number" == typeof r), assert(Number.isInteger(r)), s || !e[1].hasOwnProperty(r) ? r : e[2] ? e[2] + e[1][r] : e[1][r] + } + + message(e, r, t, a) { + return void 0 === r ? a.emitDefaultValues ? null : void 0 : e.internalJsonWrite(r, a) + } + + scalar(e, r, t, a, n) { + if (void 0 === r) assert(a); else { + var s = n || a; + switch (e) { + case ScalarType.INT32: + case ScalarType.SFIXED32: + case ScalarType.SINT32: + return 0 === r ? s ? 0 : void 0 : (assertInt32(r), r); + case ScalarType.FIXED32: + case ScalarType.UINT32: + return 0 === r ? s ? 0 : void 0 : (assertUInt32(r), r); + case ScalarType.FLOAT: + assertFloat32(r); + case ScalarType.DOUBLE: + return 0 === r ? s ? 0 : void 0 : (assert("number" == typeof r), Number.isNaN(r) ? "NaN" : r === Number.POSITIVE_INFINITY ? "Infinity" : r === Number.NEGATIVE_INFINITY ? "-Infinity" : r); + case ScalarType.STRING: + return "" === r ? s ? "" : void 0 : (assert("string" == typeof r), r); + case ScalarType.BOOL: + return !1 === r ? !s && void 0 : (assert("boolean" == typeof r), r); + case ScalarType.UINT64: + case ScalarType.FIXED64: + assert("number" == typeof r || "string" == typeof r || "bigint" == typeof r); + var i = PbULong.from(r); + return i.isZero() && !s ? void 0 : i.toString(); + case ScalarType.INT64: + case ScalarType.SFIXED64: + case ScalarType.SINT64: + assert("number" == typeof r || "string" == typeof r || "bigint" == typeof r); + i = PbLong.from(r); + return i.isZero() && !s ? void 0 : i.toString(); + case ScalarType.BYTES: + return (assert(r instanceof Uint8Array), r.byteLength) ? base64encode(r) : s ? "" : void 0 + } + } + } + } + + function reflectionScalarDefault(e, r = LongType.STRING) { + switch (e) { + case ScalarType.BOOL: + return !1; + case ScalarType.UINT64: + case ScalarType.FIXED64: + return reflectionLongConvert(PbULong.ZERO, r); + case ScalarType.INT64: + case ScalarType.SFIXED64: + case ScalarType.SINT64: + return reflectionLongConvert(PbLong.ZERO, r); + case ScalarType.DOUBLE: + case ScalarType.FLOAT: + return 0; + case ScalarType.BYTES: + return new Uint8Array(0); + case ScalarType.STRING: + return ""; + default: + return 0 + } + } + + class ReflectionBinaryReader { + constructor(e) { + this.info = e + } + + prepare() { + var e; + this.fieldNoToField || (e = null != (e = this.info.fields) ? e : [], this.fieldNoToField = new Map(e.map((e => [e.no, e])))) + } + + read(a, n, s, e) { + this.prepare(); + for (var r = void 0 === e ? a.len : a.pos + e; a.pos < r;) { + var [t, i] = a.tag(), o = this.fieldNoToField.get(t); + if (o) { + let e = n, r = o.repeat, t = o.localName; + switch (o.oneof && (e = e[o.oneof]).oneofKind !== t && (e = n[o.oneof] = {oneofKind: t}), o.kind) { + case"scalar": + case"enum": + var l = "enum" == o.kind ? ScalarType.INT32 : o.T, + c = "scalar" == o.kind ? o.L : void 0; + if (r) { + var u = e[t]; + if (i == WireType.LengthDelimited && l != ScalarType.STRING && l != ScalarType.BYTES) for (var f = a.uint32() + a.pos; a.pos < f;) u.push(this.scalar(a, l, c)); else u.push(this.scalar(a, l, c)) + } else e[t] = this.scalar(a, l, c); + break; + case"message": + r ? (h = e[t], p = o.T().internalBinaryRead(a, a.uint32(), s), h.push(p)) : e[t] = o.T().internalBinaryRead(a, a.uint32(), s, e[t]); + break; + case"map": + var [h, p] = this.mapEntry(o, a, s); + e[t][h] = p + } + } else { + var d = s.readUnknownField; + if ("throw" == d) throw new Error(`Unknown field ${t} (wire type ${i}) for ` + this.info.typeName); + var y = a.skip(i); + !1 !== d && (!0 === d ? UnknownFieldHandler.onRead : d)(this.info.typeName, n, t, i, y) + } + } + } + + mapEntry(e, r, t) { + var a = r.uint32(), n = r.pos + a; + let s = void 0, i = void 0; + for (; r.pos < n;) { + var [o, l] = r.tag(); + switch (o) { + case 1: + s = e.K == ScalarType.BOOL ? r.bool().toString() : this.scalar(r, e.K, LongType.STRING); + break; + case 2: + switch (e.V.kind) { + case"scalar": + i = this.scalar(r, e.V.T, e.V.L); + break; + case"enum": + i = r.int32(); + break; + case"message": + i = e.V.T().internalBinaryRead(r, r.uint32(), t) + } + break; + default: + throw new Error(`Unknown field ${o} (wire type ${l}) in map entry for ${this.info.typeName}#` + e.name) + } + } + if (void 0 === s && (a = reflectionScalarDefault(e.K), s = e.K == ScalarType.BOOL ? a.toString() : a), void 0 === i) switch (e.V.kind) { + case"scalar": + i = reflectionScalarDefault(e.V.T, e.V.L); + break; + case"enum": + i = 0; + break; + case"message": + i = e.V.T().create() + } + return [s, i] + } + + scalar(e, r, t) { + switch (r) { + case ScalarType.INT32: + return e.int32(); + case ScalarType.STRING: + return e.string(); + case ScalarType.BOOL: + return e.bool(); + case ScalarType.DOUBLE: + return e.double(); + case ScalarType.FLOAT: + return e.float(); + case ScalarType.INT64: + return reflectionLongConvert(e.int64(), t); + case ScalarType.UINT64: + return reflectionLongConvert(e.uint64(), t); + case ScalarType.FIXED64: + return reflectionLongConvert(e.fixed64(), t); + case ScalarType.FIXED32: + return e.fixed32(); + case ScalarType.BYTES: + return e.bytes(); + case ScalarType.UINT32: + return e.uint32(); + case ScalarType.SFIXED32: + return e.sfixed32(); + case ScalarType.SFIXED64: + return reflectionLongConvert(e.sfixed64(), t); + case ScalarType.SINT32: + return e.sint32(); + case ScalarType.SINT64: + return reflectionLongConvert(e.sint64(), t) + } + } + } + + class ReflectionBinaryWriter { + constructor(e) { + this.info = e + } + + prepare() { + var e; + this.fields || (e = this.info.fields ? this.info.fields.concat() : [], this.fields = e.sort(((e, r) => e.no - r.no))) + } + + write(n, s, i) { + this.prepare(); + for (const f of this.fields) { + let e, r, t = f.repeat, a = f.localName; + if (f.oneof) { + var o = n[f.oneof]; + if (o.oneofKind !== a) continue; + e = o[a], r = !0 + } else e = n[a], r = !1; + switch (f.kind) { + case"scalar": + case"enum": + var l = "enum" == f.kind ? ScalarType.INT32 : f.T; + if (t) if (assert(Array.isArray(e)), t == RepeatType.PACKED) this.packed(s, l, f.no, e); else for (const h of e) this.scalar(s, l, f.no, h, !0); else void 0 === e ? assert(f.opt) : this.scalar(s, l, f.no, e, r || f.opt); + break; + case"message": + if (t) { + assert(Array.isArray(e)); + for (const p of e) this.message(s, i, f.T(), f.no, p) + } else this.message(s, i, f.T(), f.no, e); + break; + case"map": + assert("object" == typeof e && null !== e); + for (var [c, u] of Object.entries(e)) this.mapEntry(s, i, f, c, u) + } + } + var e = i.writeUnknownFields; + !1 !== e && (!0 === e ? UnknownFieldHandler.onWrite : e)(this.info.typeName, n, s) + } + + mapEntry(e, r, t, a, n) { + e.tag(t.no, WireType.LengthDelimited), e.fork(); + let s = a; + switch (t.K) { + case ScalarType.INT32: + case ScalarType.FIXED32: + case ScalarType.UINT32: + case ScalarType.SFIXED32: + case ScalarType.SINT32: + s = Number.parseInt(a); + break; + case ScalarType.BOOL: + assert("true" == a || "false" == a), s = "true" == a + } + switch (this.scalar(e, t.K, 1, s, !0), t.V.kind) { + case"scalar": + this.scalar(e, t.V.T, 2, n, !0); + break; + case"enum": + this.scalar(e, ScalarType.INT32, 2, n, !0); + break; + case"message": + this.message(e, r, t.V.T(), 2, n) + } + e.join() + } + + message(e, r, t, a, n) { + void 0 !== n && (t.internalBinaryWrite(n, e.tag(a, WireType.LengthDelimited).fork(), r), e.join()) + } + + scalar(e, r, t, a, n) { + var [r, s, i] = this.scalarInfo(r, a); + i && !n || (e.tag(t, r), e[s](a)) + } + + packed(r, e, t, a) { + if (a.length) { + assert(e !== ScalarType.BYTES && e !== ScalarType.STRING), r.tag(t, WireType.LengthDelimited), r.fork(); + var [, n] = this.scalarInfo(e); + for (let e = 0; e < a.length; e++) r[n](a[e]); + r.join() + } + } + + scalarInfo(e, r) { + let t = WireType.Varint, a; + var n = void 0 === r; + let s = 0 === r; + switch (e) { + case ScalarType.INT32: + a = "int32"; + break; + case ScalarType.STRING: + s = n || !r.length, t = WireType.LengthDelimited, a = "string"; + break; + case ScalarType.BOOL: + s = !1 === r, a = "bool"; + break; + case ScalarType.UINT32: + a = "uint32"; + break; + case ScalarType.DOUBLE: + t = WireType.Bit64, a = "double"; + break; + case ScalarType.FLOAT: + t = WireType.Bit32, a = "float"; + break; + case ScalarType.INT64: + s = n || PbLong.from(r).isZero(), a = "int64"; + break; + case ScalarType.UINT64: + s = n || PbULong.from(r).isZero(), a = "uint64"; + break; + case ScalarType.FIXED64: + s = n || PbULong.from(r).isZero(), t = WireType.Bit64, a = "fixed64"; + break; + case ScalarType.BYTES: + s = n || !r.byteLength, t = WireType.LengthDelimited, a = "bytes"; + break; + case ScalarType.FIXED32: + t = WireType.Bit32, a = "fixed32"; + break; + case ScalarType.SFIXED32: + t = WireType.Bit32, a = "sfixed32"; + break; + case ScalarType.SFIXED64: + s = n || PbLong.from(r).isZero(), t = WireType.Bit64, a = "sfixed64"; + break; + case ScalarType.SINT32: + a = "sint32"; + break; + case ScalarType.SINT64: + s = n || PbLong.from(r).isZero(), a = "sint64" + } + return [t, a, n || s] + } + } + + function reflectionCreate(e) { + var r, t = {}; + Object.defineProperty(t, MESSAGE_TYPE, {enumerable: !1, value: e}); + for (r of e.fields) { + var a = r.localName; + if (!r.opt) if (r.oneof) t[r.oneof] = {oneofKind: void 0}; else if (r.repeat) t[a] = []; else switch (r.kind) { + case"scalar": + t[a] = reflectionScalarDefault(r.T, r.L); + break; + case"enum": + t[a] = 0; + break; + case"map": + t[a] = {} + } + } + return t + } + + function reflectionMergePartial(e, r, t) { + let a, n = t, s; + for (var i of e.fields) { + var o = i.localName; + if (i.oneof) { + var l = n[i.oneof]; + if (void 0 === l) continue; + if (a = l[o], (s = r[i.oneof]).oneofKind = l.oneofKind, void 0 === a) { + delete s[o]; + continue + } + } else if (a = n[o], s = r, void 0 === a) continue; + switch (i.kind) { + case"scalar": + case"enum": + i.repeat ? s[o] = a.concat() : s[o] = a; + break; + case"message": + var c = i.T(); + if (i.repeat) for (let e = 0; e < a.length; e++) s[o][e] = c.create(a[e]); else void 0 === s[o] ? s[o] = c.create(a) : c.mergePartial(s[o], a); + break; + case"map": + switch (i.V.kind) { + case"scalar": + case"enum": + Object.assign(s[o], a); + break; + case"message": + var u, f = i.V.T(); + for (u of Object.keys(a)) s[o][u] = f.create(a[u]) + } + } + } + } + + const defaultsWrite = { + emitDefaultValues: !1, + enumAsInteger: !1, + useProtoFieldName: !1, + prettySpaces: 0 + }, defaultsRead = {ignoreUnknownFields: !1}; + + function jsonReadOptions(e) { + return e ? __spreadValues(__spreadValues({}, defaultsRead), e) : defaultsRead + } + + function jsonWriteOptions(e) { + return e ? __spreadValues(__spreadValues({}, defaultsWrite), e) : defaultsWrite + } + + function reflectionEquals(e, r, t) { + if (r !== t) { + if (!r || !t) return !1; + for (var a of e.fields) { + var n = a.localName, s = (a.oneof ? r[a.oneof] : r)[n], i = (a.oneof ? t[a.oneof] : t)[n]; + switch (a.kind) { + case"enum": + case"scalar": + var o = "enum" == a.kind ? ScalarType.INT32 : a.T; + if ((a.repeat ? repeatedPrimitiveEq : primitiveEq)(o, s, i)) break; + return !1; + case"map": + if ("message" == a.V.kind ? repeatedMsgEq(a.V.T(), objectValues(s), objectValues(i)) : repeatedPrimitiveEq("enum" == a.V.kind ? ScalarType.INT32 : a.V.T, objectValues(s), objectValues(i))) break; + return !1; + case"message": + o = a.T(); + if (a.repeat ? repeatedMsgEq(o, s, i) : o.equals(s, i)) break; + return !1 + } + } + } + return !0 + } + + const objectValues = Object.values; + + function primitiveEq(e, r, t) { + if (r !== t) { + if (e !== ScalarType.BYTES) return !1; + var a = r, n = t; + if (a.length !== n.length) return !1; + for (let e = 0; e < a.length; e++) if (a[e] != n[e]) return !1 + } + return !0 + } + + function repeatedPrimitiveEq(r, t, a) { + if (t.length !== a.length) return !1; + for (let e = 0; e < t.length; e++) if (!primitiveEq(r, t[e], a[e])) return !1; + return !0 + } + + function repeatedMsgEq(r, t, a) { + if (t.length !== a.length) return !1; + for (let e = 0; e < t.length; e++) if (!r.equals(t[e], a[e])) return !1; + return !0 + } + + class MessageType { + constructor(e, r, t) { + this.defaultCheckDepth = 16, this.typeName = e, this.fields = r.map(normalizeFieldInfo), this.options = null != t ? t : {}, this.refTypeCheck = new ReflectionTypeCheck(this), this.refJsonReader = new ReflectionJsonReader(this), this.refJsonWriter = new ReflectionJsonWriter(this), this.refBinReader = new ReflectionBinaryReader(this), this.refBinWriter = new ReflectionBinaryWriter(this) + } + + create(e) { + var r = reflectionCreate(this); + return void 0 !== e && reflectionMergePartial(this, r, e), r + } + + clone(e) { + var r = this.create(); + return reflectionMergePartial(this, r, e), r + } + + equals(e, r) { + return reflectionEquals(this, e, r) + } + + is(e, r = this.defaultCheckDepth) { + return this.refTypeCheck.is(e, r, !1) + } + + isAssignable(e, r = this.defaultCheckDepth) { + return this.refTypeCheck.is(e, r, !0) + } + + mergePartial(e, r) { + reflectionMergePartial(this, e, r) + } + + fromBinary(e, r) { + r = binaryReadOptions(r); + return this.internalBinaryRead(r.readerFactory(e), e.byteLength, r) + } + + fromJson(e, r) { + return this.internalJsonRead(e, jsonReadOptions(r)) + } + + fromJsonString(e, r) { + e = JSON.parse(e); + return this.fromJson(e, r) + } + + toJson(e, r) { + return this.internalJsonWrite(e, jsonWriteOptions(r)) + } + + toJsonString(e, r) { + var e = this.toJson(e, r); + return JSON.stringify(e, null, null != (e = null == r ? void 0 : r.prettySpaces) ? e : 0) + } + + toBinary(e, r) { + r = binaryWriteOptions(r); + return this.internalBinaryWrite(e, r.writerFactory(), r).finish() + } + + internalJsonRead(e, r, t) { + if (null === e || "object" != typeof e || Array.isArray(e)) throw new Error(`Unable to parse message ${this.typeName} from JSON ${typeofJsonValue(e)}.`); + return t = null != t ? t : this.create(), this.refJsonReader.read(e, t, r), t + } + + internalJsonWrite(e, r) { + return this.refJsonWriter.write(e, r) + } + + internalBinaryWrite(e, r, t) { + return this.refBinWriter.write(e, r, t), r + } + + internalBinaryRead(e, r, t, a) { + a = null != a ? a : this.create(); + return this.refBinReader.read(e, a, t, r), a + } + }; + /****************** initialization finish ******************/ + switch (FORMAT) { + case "application/x-protobuf": + break; + case "application/grpc": + case "application/grpc+proto": + /****************** initialization start *******************/ + // pako 2.0.4 + !function (t, e) { + "object" == typeof exports && "undefined" != typeof module ? e(exports) : "function" == typeof define && define.amd ? define(["exports"], e) : e((t = "undefined" != typeof globalThis ? globalThis : t || self).pako = {}) + }(this, (function (t) { + "use strict"; + + function e(t) { + let e = t.length; + for (; --e >= 0;) t[e] = 0 + } + + const a = 256, i = 286, n = 30, s = 15, + r = new Uint8Array([0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 0]), + l = new Uint8Array([0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13]), + o = new Uint8Array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 3, 7]), + h = new Uint8Array([16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15]), + d = new Array(576); + e(d); + const _ = new Array(60); + e(_); + const f = new Array(512); + e(f); + const c = new Array(256); + e(c); + const u = new Array(29); + e(u); + const w = new Array(n); + + function b(t, e, a, i, n) { + this.static_tree = t, this.extra_bits = e, this.extra_base = a, this.elems = i, this.max_length = n, this.has_stree = t && t.length + } + + let g, p, m; + + function k(t, e) { + this.dyn_tree = t, this.max_code = 0, this.stat_desc = e + } + + e(w); + const v = t => t < 256 ? f[t] : f[256 + (t >>> 7)], y = (t, e) => { + t.pending_buf[t.pending++] = 255 & e, t.pending_buf[t.pending++] = e >>> 8 & 255 + }, x = (t, e, a) => { + t.bi_valid > 16 - a ? (t.bi_buf |= e << t.bi_valid & 65535, y(t, t.bi_buf), t.bi_buf = e >> 16 - t.bi_valid, t.bi_valid += a - 16) : (t.bi_buf |= e << t.bi_valid & 65535, t.bi_valid += a) + }, z = (t, e, a) => { + x(t, a[2 * e], a[2 * e + 1]) + }, A = (t, e) => { + let a = 0; + do { + a |= 1 & t, t >>>= 1, a <<= 1 + } while (--e > 0); + return a >>> 1 + }, E = (t, e, a) => { + const i = new Array(16); + let n, r, l = 0; + for (n = 1; n <= s; n++) i[n] = l = l + a[n - 1] << 1; + for (r = 0; r <= e; r++) { + let e = t[2 * r + 1]; + 0 !== e && (t[2 * r] = A(i[e]++, e)) + } + }, R = t => { + let e; + for (e = 0; e < i; e++) t.dyn_ltree[2 * e] = 0; + for (e = 0; e < n; e++) t.dyn_dtree[2 * e] = 0; + for (e = 0; e < 19; e++) t.bl_tree[2 * e] = 0; + t.dyn_ltree[512] = 1, t.opt_len = t.static_len = 0, t.last_lit = t.matches = 0 + }, Z = t => { + t.bi_valid > 8 ? y(t, t.bi_buf) : t.bi_valid > 0 && (t.pending_buf[t.pending++] = t.bi_buf), t.bi_buf = 0, t.bi_valid = 0 + }, U = (t, e, a, i) => { + const n = 2 * e, s = 2 * a; + return t[n] < t[s] || t[n] === t[s] && i[e] <= i[a] + }, S = (t, e, a) => { + const i = t.heap[a]; + let n = a << 1; + for (; n <= t.heap_len && (n < t.heap_len && U(e, t.heap[n + 1], t.heap[n], t.depth) && n++, !U(e, i, t.heap[n], t.depth));) t.heap[a] = t.heap[n], a = n, n <<= 1; + t.heap[a] = i + }, D = (t, e, i) => { + let n, s, o, h, d = 0; + if (0 !== t.last_lit) do { + n = t.pending_buf[t.d_buf + 2 * d] << 8 | t.pending_buf[t.d_buf + 2 * d + 1], s = t.pending_buf[t.l_buf + d], d++, 0 === n ? z(t, s, e) : (o = c[s], z(t, o + a + 1, e), h = r[o], 0 !== h && (s -= u[o], x(t, s, h)), n--, o = v(n), z(t, o, i), h = l[o], 0 !== h && (n -= w[o], x(t, n, h))) + } while (d < t.last_lit); + z(t, 256, e) + }, T = (t, e) => { + const a = e.dyn_tree, i = e.stat_desc.static_tree, n = e.stat_desc.has_stree, + r = e.stat_desc.elems; + let l, o, h, d = -1; + for (t.heap_len = 0, t.heap_max = 573, l = 0; l < r; l++) 0 !== a[2 * l] ? (t.heap[++t.heap_len] = d = l, t.depth[l] = 0) : a[2 * l + 1] = 0; + for (; t.heap_len < 2;) h = t.heap[++t.heap_len] = d < 2 ? ++d : 0, a[2 * h] = 1, t.depth[h] = 0, t.opt_len--, n && (t.static_len -= i[2 * h + 1]); + for (e.max_code = d, l = t.heap_len >> 1; l >= 1; l--) S(t, a, l); + h = r; + do { + l = t.heap[1], t.heap[1] = t.heap[t.heap_len--], S(t, a, 1), o = t.heap[1], t.heap[--t.heap_max] = l, t.heap[--t.heap_max] = o, a[2 * h] = a[2 * l] + a[2 * o], t.depth[h] = (t.depth[l] >= t.depth[o] ? t.depth[l] : t.depth[o]) + 1, a[2 * l + 1] = a[2 * o + 1] = h, t.heap[1] = h++, S(t, a, 1) + } while (t.heap_len >= 2); + t.heap[--t.heap_max] = t.heap[1], ((t, e) => { + const a = e.dyn_tree, i = e.max_code, n = e.stat_desc.static_tree, + r = e.stat_desc.has_stree, l = e.stat_desc.extra_bits, + o = e.stat_desc.extra_base, h = e.stat_desc.max_length; + let d, _, f, c, u, w, b = 0; + for (c = 0; c <= s; c++) t.bl_count[c] = 0; + for (a[2 * t.heap[t.heap_max] + 1] = 0, d = t.heap_max + 1; d < 573; d++) _ = t.heap[d], c = a[2 * a[2 * _ + 1] + 1] + 1, c > h && (c = h, b++), a[2 * _ + 1] = c, _ > i || (t.bl_count[c]++, u = 0, _ >= o && (u = l[_ - o]), w = a[2 * _], t.opt_len += w * (c + u), r && (t.static_len += w * (n[2 * _ + 1] + u))); + if (0 !== b) { + do { + for (c = h - 1; 0 === t.bl_count[c];) c--; + t.bl_count[c]--, t.bl_count[c + 1] += 2, t.bl_count[h]--, b -= 2 + } while (b > 0); + for (c = h; 0 !== c; c--) for (_ = t.bl_count[c]; 0 !== _;) f = t.heap[--d], f > i || (a[2 * f + 1] !== c && (t.opt_len += (c - a[2 * f + 1]) * a[2 * f], a[2 * f + 1] = c), _--) + } + })(t, e), E(a, d, t.bl_count) + }, O = (t, e, a) => { + let i, n, s = -1, r = e[1], l = 0, o = 7, h = 4; + for (0 === r && (o = 138, h = 3), e[2 * (a + 1) + 1] = 65535, i = 0; i <= a; i++) n = r, r = e[2 * (i + 1) + 1], ++l < o && n === r || (l < h ? t.bl_tree[2 * n] += l : 0 !== n ? (n !== s && t.bl_tree[2 * n]++, t.bl_tree[32]++) : l <= 10 ? t.bl_tree[34]++ : t.bl_tree[36]++, l = 0, s = n, 0 === r ? (o = 138, h = 3) : n === r ? (o = 6, h = 3) : (o = 7, h = 4)) + }, I = (t, e, a) => { + let i, n, s = -1, r = e[1], l = 0, o = 7, h = 4; + for (0 === r && (o = 138, h = 3), i = 0; i <= a; i++) if (n = r, r = e[2 * (i + 1) + 1], !(++l < o && n === r)) { + if (l < h) do { + z(t, n, t.bl_tree) + } while (0 != --l); else 0 !== n ? (n !== s && (z(t, n, t.bl_tree), l--), z(t, 16, t.bl_tree), x(t, l - 3, 2)) : l <= 10 ? (z(t, 17, t.bl_tree), x(t, l - 3, 3)) : (z(t, 18, t.bl_tree), x(t, l - 11, 7)); + l = 0, s = n, 0 === r ? (o = 138, h = 3) : n === r ? (o = 6, h = 3) : (o = 7, h = 4) + } + }; + let F = !1; + const L = (t, e, a, i) => { + x(t, 0 + (i ? 1 : 0), 3), ((t, e, a, i) => { + Z(t), i && (y(t, a), y(t, ~a)), t.pending_buf.set(t.window.subarray(e, e + a), t.pending), t.pending += a + })(t, e, a, !0) + }; + var N = { + _tr_init: t => { + F || ((() => { + let t, e, a, h, k; + const v = new Array(16); + for (a = 0, h = 0; h < 28; h++) for (u[h] = a, t = 0; t < 1 << r[h]; t++) c[a++] = h; + for (c[a - 1] = h, k = 0, h = 0; h < 16; h++) for (w[h] = k, t = 0; t < 1 << l[h]; t++) f[k++] = h; + for (k >>= 7; h < n; h++) for (w[h] = k << 7, t = 0; t < 1 << l[h] - 7; t++) f[256 + k++] = h; + for (e = 0; e <= s; e++) v[e] = 0; + for (t = 0; t <= 143;) d[2 * t + 1] = 8, t++, v[8]++; + for (; t <= 255;) d[2 * t + 1] = 9, t++, v[9]++; + for (; t <= 279;) d[2 * t + 1] = 7, t++, v[7]++; + for (; t <= 287;) d[2 * t + 1] = 8, t++, v[8]++; + for (E(d, 287, v), t = 0; t < n; t++) _[2 * t + 1] = 5, _[2 * t] = A(t, 5); + g = new b(d, r, 257, i, s), p = new b(_, l, 0, n, s), m = new b(new Array(0), o, 0, 19, 7) + })(), F = !0), t.l_desc = new k(t.dyn_ltree, g), t.d_desc = new k(t.dyn_dtree, p), t.bl_desc = new k(t.bl_tree, m), t.bi_buf = 0, t.bi_valid = 0, R(t) + }, + _tr_stored_block: L, + _tr_flush_block: (t, e, i, n) => { + let s, r, l = 0; + t.level > 0 ? (2 === t.strm.data_type && (t.strm.data_type = (t => { + let e, i = 4093624447; + for (e = 0; e <= 31; e++, i >>>= 1) if (1 & i && 0 !== t.dyn_ltree[2 * e]) return 0; + if (0 !== t.dyn_ltree[18] || 0 !== t.dyn_ltree[20] || 0 !== t.dyn_ltree[26]) return 1; + for (e = 32; e < a; e++) if (0 !== t.dyn_ltree[2 * e]) return 1; + return 0 + })(t)), T(t, t.l_desc), T(t, t.d_desc), l = (t => { + let e; + for (O(t, t.dyn_ltree, t.l_desc.max_code), O(t, t.dyn_dtree, t.d_desc.max_code), T(t, t.bl_desc), e = 18; e >= 3 && 0 === t.bl_tree[2 * h[e] + 1]; e--) ; + return t.opt_len += 3 * (e + 1) + 5 + 5 + 4, e + })(t), s = t.opt_len + 3 + 7 >>> 3, r = t.static_len + 3 + 7 >>> 3, r <= s && (s = r)) : s = r = i + 5, i + 4 <= s && -1 !== e ? L(t, e, i, n) : 4 === t.strategy || r === s ? (x(t, 2 + (n ? 1 : 0), 3), D(t, d, _)) : (x(t, 4 + (n ? 1 : 0), 3), ((t, e, a, i) => { + let n; + for (x(t, e - 257, 5), x(t, a - 1, 5), x(t, i - 4, 4), n = 0; n < i; n++) x(t, t.bl_tree[2 * h[n] + 1], 3); + I(t, t.dyn_ltree, e - 1), I(t, t.dyn_dtree, a - 1) + })(t, t.l_desc.max_code + 1, t.d_desc.max_code + 1, l + 1), D(t, t.dyn_ltree, t.dyn_dtree)), R(t), n && Z(t) + }, + _tr_tally: (t, e, i) => (t.pending_buf[t.d_buf + 2 * t.last_lit] = e >>> 8 & 255, t.pending_buf[t.d_buf + 2 * t.last_lit + 1] = 255 & e, t.pending_buf[t.l_buf + t.last_lit] = 255 & i, t.last_lit++, 0 === e ? t.dyn_ltree[2 * i]++ : (t.matches++, e--, t.dyn_ltree[2 * (c[i] + a + 1)]++, t.dyn_dtree[2 * v(e)]++), t.last_lit === t.lit_bufsize - 1), + _tr_align: t => { + x(t, 2, 3), z(t, 256, d), (t => { + 16 === t.bi_valid ? (y(t, t.bi_buf), t.bi_buf = 0, t.bi_valid = 0) : t.bi_valid >= 8 && (t.pending_buf[t.pending++] = 255 & t.bi_buf, t.bi_buf >>= 8, t.bi_valid -= 8) + })(t) + } + }; + var B = (t, e, a, i) => { + let n = 65535 & t | 0, s = t >>> 16 & 65535 | 0, r = 0; + for (; 0 !== a;) { + r = a > 2e3 ? 2e3 : a, a -= r; + do { + n = n + e[i++] | 0, s = s + n | 0 + } while (--r); + n %= 65521, s %= 65521 + } + return n | s << 16 | 0 + }; + const C = new Uint32Array((() => { + let t, e = []; + for (var a = 0; a < 256; a++) { + t = a; + for (var i = 0; i < 8; i++) t = 1 & t ? 3988292384 ^ t >>> 1 : t >>> 1; + e[a] = t + } + return e + })()); + var M = (t, e, a, i) => { + const n = C, s = i + a; + t ^= -1; + for (let a = i; a < s; a++) t = t >>> 8 ^ n[255 & (t ^ e[a])]; + return -1 ^ t + }, H = { + 2: "need dictionary", + 1: "stream end", + 0: "", + "-1": "file error", + "-2": "stream error", + "-3": "data error", + "-4": "insufficient memory", + "-5": "buffer error", + "-6": "incompatible version" + }, j = { + Z_NO_FLUSH: 0, + Z_PARTIAL_FLUSH: 1, + Z_SYNC_FLUSH: 2, + Z_FULL_FLUSH: 3, + Z_FINISH: 4, + Z_BLOCK: 5, + Z_TREES: 6, + Z_OK: 0, + Z_STREAM_END: 1, + Z_NEED_DICT: 2, + Z_ERRNO: -1, + Z_STREAM_ERROR: -2, + Z_DATA_ERROR: -3, + Z_MEM_ERROR: -4, + Z_BUF_ERROR: -5, + Z_NO_COMPRESSION: 0, + Z_BEST_SPEED: 1, + Z_BEST_COMPRESSION: 9, + Z_DEFAULT_COMPRESSION: -1, + Z_FILTERED: 1, + Z_HUFFMAN_ONLY: 2, + Z_RLE: 3, + Z_FIXED: 4, + Z_DEFAULT_STRATEGY: 0, + Z_BINARY: 0, + Z_TEXT: 1, + Z_UNKNOWN: 2, + Z_DEFLATED: 8 + }; + const { + _tr_init: K, + _tr_stored_block: P, + _tr_flush_block: Y, + _tr_tally: G, + _tr_align: X + } = N, { + Z_NO_FLUSH: W, + Z_PARTIAL_FLUSH: q, + Z_FULL_FLUSH: J, + Z_FINISH: Q, + Z_BLOCK: V, + Z_OK: $, + Z_STREAM_END: tt, + Z_STREAM_ERROR: et, + Z_DATA_ERROR: at, + Z_BUF_ERROR: it, + Z_DEFAULT_COMPRESSION: nt, + Z_FILTERED: st, + Z_HUFFMAN_ONLY: rt, + Z_RLE: lt, + Z_FIXED: ot, + Z_DEFAULT_STRATEGY: ht, + Z_UNKNOWN: dt, + Z_DEFLATED: _t + } = j, ft = 258, ct = 262, ut = 103, wt = 113, bt = 666, + gt = (t, e) => (t.msg = H[e], e), pt = t => (t << 1) - (t > 4 ? 9 : 0), mt = t => { + let e = t.length; + for (; --e >= 0;) t[e] = 0 }; - break; - default: - let u = options.readUnknownField; - if (u === 'throw') - throw new globalThis.Error( - `Unknown field ${fieldNo}(wire type ${wireType})for ${this.typeName}` - ); - let d = reader.skip(wireType); - if (u !== false) - (u === true - ? UnknownFieldHandler.onRead - : u)( - this.typeName, - message, - fieldNo, - wireType, - d - ); + let kt = (t, e, a) => (e << t.hash_shift ^ a) & t.hash_mask; + const vt = t => { + const e = t.state; + let a = e.pending; + a > t.avail_out && (a = t.avail_out), 0 !== a && (t.output.set(e.pending_buf.subarray(e.pending_out, e.pending_out + a), t.next_out), t.next_out += a, e.pending_out += a, t.total_out += a, t.avail_out -= a, e.pending -= a, 0 === e.pending && (e.pending_out = 0)) + }, yt = (t, e) => { + Y(t, t.block_start >= 0 ? t.block_start : -1, t.strstart - t.block_start, e), t.block_start = t.strstart, vt(t.strm) + }, xt = (t, e) => { + t.pending_buf[t.pending++] = e + }, zt = (t, e) => { + t.pending_buf[t.pending++] = e >>> 8 & 255, t.pending_buf[t.pending++] = 255 & e + }, At = (t, e, a, i) => { + let n = t.avail_in; + return n > i && (n = i), 0 === n ? 0 : (t.avail_in -= n, e.set(t.input.subarray(t.next_in, t.next_in + n), a), 1 === t.state.wrap ? t.adler = B(t.adler, e, n, a) : 2 === t.state.wrap && (t.adler = M(t.adler, e, n, a)), t.next_in += n, t.total_in += n, n) + }, Et = (t, e) => { + let a, i, n = t.max_chain_length, s = t.strstart, r = t.prev_length, + l = t.nice_match; + const o = t.strstart > t.w_size - ct ? t.strstart - (t.w_size - ct) : 0, + h = t.window, d = t.w_mask, _ = t.prev, f = t.strstart + ft; + let c = h[s + r - 1], u = h[s + r]; + t.prev_length >= t.good_match && (n >>= 2), l > t.lookahead && (l = t.lookahead); + do { + if (a = e, h[a + r] === u && h[a + r - 1] === c && h[a] === h[s] && h[++a] === h[s + 1]) { + s += 2, a++; + do { + } while (h[++s] === h[++a] && h[++s] === h[++a] && h[++s] === h[++a] && h[++s] === h[++a] && h[++s] === h[++a] && h[++s] === h[++a] && h[++s] === h[++a] && h[++s] === h[++a] && s < f); + if (i = ft - (f - s), s = f - ft, i > r) { + if (t.match_start = e, r = i, i >= l) break; + c = h[s + r - 1], u = h[s + r] + } + } + } while ((e = _[e & d]) > o && 0 != --n); + return r <= t.lookahead ? r : t.lookahead + }, Rt = t => { + const e = t.w_size; + let a, i, n, s, r; + do { + if (s = t.window_size - t.lookahead - t.strstart, t.strstart >= e + (e - ct)) { + t.window.set(t.window.subarray(e, e + e), 0), t.match_start -= e, t.strstart -= e, t.block_start -= e, i = t.hash_size, a = i; + do { + n = t.head[--a], t.head[a] = n >= e ? n - e : 0 + } while (--i); + i = e, a = i; + do { + n = t.prev[--a], t.prev[a] = n >= e ? n - e : 0 + } while (--i); + s += e + } + if (0 === t.strm.avail_in) break; + if (i = At(t.strm, t.window, t.strstart + t.lookahead, s), t.lookahead += i, t.lookahead + t.insert >= 3) for (r = t.strstart - t.insert, t.ins_h = t.window[r], t.ins_h = kt(t, t.ins_h, t.window[r + 1]); t.insert && (t.ins_h = kt(t, t.ins_h, t.window[r + 3 - 1]), t.prev[r & t.w_mask] = t.head[t.ins_h], t.head[t.ins_h] = r, r++, t.insert--, !(t.lookahead + t.insert < 3));) ; + } while (t.lookahead < ct && 0 !== t.strm.avail_in) + }, Zt = (t, e) => { + let a, i; + for (; ;) { + if (t.lookahead < ct) { + if (Rt(t), t.lookahead < ct && e === W) return 1; + if (0 === t.lookahead) break + } + if (a = 0, t.lookahead >= 3 && (t.ins_h = kt(t, t.ins_h, t.window[t.strstart + 3 - 1]), a = t.prev[t.strstart & t.w_mask] = t.head[t.ins_h], t.head[t.ins_h] = t.strstart), 0 !== a && t.strstart - a <= t.w_size - ct && (t.match_length = Et(t, a)), t.match_length >= 3) if (i = G(t, t.strstart - t.match_start, t.match_length - 3), t.lookahead -= t.match_length, t.match_length <= t.max_lazy_match && t.lookahead >= 3) { + t.match_length--; + do { + t.strstart++, t.ins_h = kt(t, t.ins_h, t.window[t.strstart + 3 - 1]), a = t.prev[t.strstart & t.w_mask] = t.head[t.ins_h], t.head[t.ins_h] = t.strstart + } while (0 != --t.match_length); + t.strstart++ + } else t.strstart += t.match_length, t.match_length = 0, t.ins_h = t.window[t.strstart], t.ins_h = kt(t, t.ins_h, t.window[t.strstart + 1]); else i = G(t, 0, t.window[t.strstart]), t.lookahead--, t.strstart++; + if (i && (yt(t, !1), 0 === t.strm.avail_out)) return 1 + } + return t.insert = t.strstart < 2 ? t.strstart : 2, e === Q ? (yt(t, !0), 0 === t.strm.avail_out ? 3 : 4) : t.last_lit && (yt(t, !1), 0 === t.strm.avail_out) ? 1 : 2 + }, Ut = (t, e) => { + let a, i, n; + for (; ;) { + if (t.lookahead < ct) { + if (Rt(t), t.lookahead < ct && e === W) return 1; + if (0 === t.lookahead) break + } + if (a = 0, t.lookahead >= 3 && (t.ins_h = kt(t, t.ins_h, t.window[t.strstart + 3 - 1]), a = t.prev[t.strstart & t.w_mask] = t.head[t.ins_h], t.head[t.ins_h] = t.strstart), t.prev_length = t.match_length, t.prev_match = t.match_start, t.match_length = 2, 0 !== a && t.prev_length < t.max_lazy_match && t.strstart - a <= t.w_size - ct && (t.match_length = Et(t, a), t.match_length <= 5 && (t.strategy === st || 3 === t.match_length && t.strstart - t.match_start > 4096) && (t.match_length = 2)), t.prev_length >= 3 && t.match_length <= t.prev_length) { + n = t.strstart + t.lookahead - 3, i = G(t, t.strstart - 1 - t.prev_match, t.prev_length - 3), t.lookahead -= t.prev_length - 1, t.prev_length -= 2; + do { + ++t.strstart <= n && (t.ins_h = kt(t, t.ins_h, t.window[t.strstart + 3 - 1]), a = t.prev[t.strstart & t.w_mask] = t.head[t.ins_h], t.head[t.ins_h] = t.strstart) + } while (0 != --t.prev_length); + if (t.match_available = 0, t.match_length = 2, t.strstart++, i && (yt(t, !1), 0 === t.strm.avail_out)) return 1 + } else if (t.match_available) { + if (i = G(t, 0, t.window[t.strstart - 1]), i && yt(t, !1), t.strstart++, t.lookahead--, 0 === t.strm.avail_out) return 1 + } else t.match_available = 1, t.strstart++, t.lookahead-- + } + return t.match_available && (i = G(t, 0, t.window[t.strstart - 1]), t.match_available = 0), t.insert = t.strstart < 2 ? t.strstart : 2, e === Q ? (yt(t, !0), 0 === t.strm.avail_out ? 3 : 4) : t.last_lit && (yt(t, !1), 0 === t.strm.avail_out) ? 1 : 2 + }; + + function St(t, e, a, i, n) { + this.good_length = t, this.max_lazy = e, this.nice_length = a, this.max_chain = i, this.func = n } - } - return message; - } - internalBinaryWrite(message, writer, options) { - if (message.cardItem.oneofKind === 'cm') - SearchAdCard.internalBinaryWrite( - message.cardItem.cm, - writer - .tag(25, WireType.LengthDelimited) - .fork(), - options - ).join(); - let u = options.writeUnknownFields; - if (u !== false) - (u == true ? UnknownFieldHandler.onWrite : u)( - this.typeName, - message, - writer - ); - return writer; - } - } - const Item = new Item$Type(); - class SearchAdCard$Type extends MessageType { - constructor() { - super('SearchAdCard', [ - { - no: 1, - name: 'json_str', - kind: 'scalar', - T: 9, - }, - ]); - } - create(value) { - const message = { jsonStr: '' }; - globalThis.Object.defineProperty( - message, - MESSAGE_TYPE, - { enumerable: false, value: this } - ); - if (value !== undefined) - reflectionMergePartial(this, message, value); - return message; - } - internalBinaryRead( - reader, - length, - options, - target - ) { - let message = target ?? this.create(), - end = reader.pos + length; - while (reader.pos < end) { - let [fieldNo, wireType] = reader.tag(); - switch (fieldNo) { - case 1: - message.jsonStr = reader.string(); - break; - default: - let u = options.readUnknownField; - if (u === 'throw') - throw new globalThis.Error( - `Unknown field ${fieldNo}(wire type ${wireType})for ${this.typeName}` - ); - let d = reader.skip(wireType); - if (u !== false) - (u === true - ? UnknownFieldHandler.onRead - : u)( - this.typeName, - message, - fieldNo, - wireType, - d - ); + + const Dt = [new St(0, 0, 0, 0, ((t, e) => { + let a = 65535; + for (a > t.pending_buf_size - 5 && (a = t.pending_buf_size - 5); ;) { + if (t.lookahead <= 1) { + if (Rt(t), 0 === t.lookahead && e === W) return 1; + if (0 === t.lookahead) break + } + t.strstart += t.lookahead, t.lookahead = 0; + const i = t.block_start + a; + if ((0 === t.strstart || t.strstart >= i) && (t.lookahead = t.strstart - i, t.strstart = i, yt(t, !1), 0 === t.strm.avail_out)) return 1; + if (t.strstart - t.block_start >= t.w_size - ct && (yt(t, !1), 0 === t.strm.avail_out)) return 1 + } + return t.insert = 0, e === Q ? (yt(t, !0), 0 === t.strm.avail_out ? 3 : 4) : (t.strstart > t.block_start && (yt(t, !1), t.strm.avail_out), 1) + })), new St(4, 4, 8, 4, Zt), new St(4, 5, 16, 8, Zt), new St(4, 6, 32, 32, Zt), new St(4, 4, 16, 16, Ut), new St(8, 16, 32, 32, Ut), new St(8, 16, 128, 128, Ut), new St(8, 32, 128, 256, Ut), new St(32, 128, 258, 1024, Ut), new St(32, 258, 258, 4096, Ut)]; + + function Tt() { + this.strm = null, this.status = 0, this.pending_buf = null, this.pending_buf_size = 0, this.pending_out = 0, this.pending = 0, this.wrap = 0, this.gzhead = null, this.gzindex = 0, this.method = _t, this.last_flush = -1, this.w_size = 0, this.w_bits = 0, this.w_mask = 0, this.window = null, this.window_size = 0, this.prev = null, this.head = null, this.ins_h = 0, this.hash_size = 0, this.hash_bits = 0, this.hash_mask = 0, this.hash_shift = 0, this.block_start = 0, this.match_length = 0, this.prev_match = 0, this.match_available = 0, this.strstart = 0, this.match_start = 0, this.lookahead = 0, this.prev_length = 0, this.max_chain_length = 0, this.max_lazy_match = 0, this.level = 0, this.strategy = 0, this.good_match = 0, this.nice_match = 0, this.dyn_ltree = new Uint16Array(1146), this.dyn_dtree = new Uint16Array(122), this.bl_tree = new Uint16Array(78), mt(this.dyn_ltree), mt(this.dyn_dtree), mt(this.bl_tree), this.l_desc = null, this.d_desc = null, this.bl_desc = null, this.bl_count = new Uint16Array(16), this.heap = new Uint16Array(573), mt(this.heap), this.heap_len = 0, this.heap_max = 0, this.depth = new Uint16Array(573), mt(this.depth), this.l_buf = 0, this.lit_bufsize = 0, this.last_lit = 0, this.d_buf = 0, this.opt_len = 0, this.static_len = 0, this.matches = 0, this.insert = 0, this.bi_buf = 0, this.bi_valid = 0 } - } - return message; + + const Ot = t => { + if (!t || !t.state) return gt(t, et); + t.total_in = t.total_out = 0, t.data_type = dt; + const e = t.state; + return e.pending = 0, e.pending_out = 0, e.wrap < 0 && (e.wrap = -e.wrap), e.status = e.wrap ? 42 : wt, t.adler = 2 === e.wrap ? 0 : 1, e.last_flush = W, K(e), $ + }, It = t => { + const e = Ot(t); + var a; + return e === $ && ((a = t.state).window_size = 2 * a.w_size, mt(a.head), a.max_lazy_match = Dt[a.level].max_lazy, a.good_match = Dt[a.level].good_length, a.nice_match = Dt[a.level].nice_length, a.max_chain_length = Dt[a.level].max_chain, a.strstart = 0, a.block_start = 0, a.lookahead = 0, a.insert = 0, a.match_length = a.prev_length = 2, a.match_available = 0, a.ins_h = 0), e + }, Ft = (t, e, a, i, n, s) => { + if (!t) return et; + let r = 1; + if (e === nt && (e = 6), i < 0 ? (r = 0, i = -i) : i > 15 && (r = 2, i -= 16), n < 1 || n > 9 || a !== _t || i < 8 || i > 15 || e < 0 || e > 9 || s < 0 || s > ot) return gt(t, et); + 8 === i && (i = 9); + const l = new Tt; + return t.state = l, l.strm = t, l.wrap = r, l.gzhead = null, l.w_bits = i, l.w_size = 1 << l.w_bits, l.w_mask = l.w_size - 1, l.hash_bits = n + 7, l.hash_size = 1 << l.hash_bits, l.hash_mask = l.hash_size - 1, l.hash_shift = ~~((l.hash_bits + 3 - 1) / 3), l.window = new Uint8Array(2 * l.w_size), l.head = new Uint16Array(l.hash_size), l.prev = new Uint16Array(l.w_size), l.lit_bufsize = 1 << n + 6, l.pending_buf_size = 4 * l.lit_bufsize, l.pending_buf = new Uint8Array(l.pending_buf_size), l.d_buf = 1 * l.lit_bufsize, l.l_buf = 3 * l.lit_bufsize, l.level = e, l.strategy = s, l.method = a, It(t) + }; + var Lt = { + deflateInit: (t, e) => Ft(t, e, _t, 15, 8, ht), + deflateInit2: Ft, + deflateReset: It, + deflateResetKeep: Ot, + deflateSetHeader: (t, e) => t && t.state ? 2 !== t.state.wrap ? et : (t.state.gzhead = e, $) : et, + deflate: (t, e) => { + let a, i; + if (!t || !t.state || e > V || e < 0) return t ? gt(t, et) : et; + const n = t.state; + if (!t.output || !t.input && 0 !== t.avail_in || n.status === bt && e !== Q) return gt(t, 0 === t.avail_out ? it : et); + n.strm = t; + const s = n.last_flush; + if (n.last_flush = e, 42 === n.status) if (2 === n.wrap) t.adler = 0, xt(n, 31), xt(n, 139), xt(n, 8), n.gzhead ? (xt(n, (n.gzhead.text ? 1 : 0) + (n.gzhead.hcrc ? 2 : 0) + (n.gzhead.extra ? 4 : 0) + (n.gzhead.name ? 8 : 0) + (n.gzhead.comment ? 16 : 0)), xt(n, 255 & n.gzhead.time), xt(n, n.gzhead.time >> 8 & 255), xt(n, n.gzhead.time >> 16 & 255), xt(n, n.gzhead.time >> 24 & 255), xt(n, 9 === n.level ? 2 : n.strategy >= rt || n.level < 2 ? 4 : 0), xt(n, 255 & n.gzhead.os), n.gzhead.extra && n.gzhead.extra.length && (xt(n, 255 & n.gzhead.extra.length), xt(n, n.gzhead.extra.length >> 8 & 255)), n.gzhead.hcrc && (t.adler = M(t.adler, n.pending_buf, n.pending, 0)), n.gzindex = 0, n.status = 69) : (xt(n, 0), xt(n, 0), xt(n, 0), xt(n, 0), xt(n, 0), xt(n, 9 === n.level ? 2 : n.strategy >= rt || n.level < 2 ? 4 : 0), xt(n, 3), n.status = wt); else { + let e = _t + (n.w_bits - 8 << 4) << 8, a = -1; + a = n.strategy >= rt || n.level < 2 ? 0 : n.level < 6 ? 1 : 6 === n.level ? 2 : 3, e |= a << 6, 0 !== n.strstart && (e |= 32), e += 31 - e % 31, n.status = wt, zt(n, e), 0 !== n.strstart && (zt(n, t.adler >>> 16), zt(n, 65535 & t.adler)), t.adler = 1 + } + if (69 === n.status) if (n.gzhead.extra) { + for (a = n.pending; n.gzindex < (65535 & n.gzhead.extra.length) && (n.pending !== n.pending_buf_size || (n.gzhead.hcrc && n.pending > a && (t.adler = M(t.adler, n.pending_buf, n.pending - a, a)), vt(t), a = n.pending, n.pending !== n.pending_buf_size));) xt(n, 255 & n.gzhead.extra[n.gzindex]), n.gzindex++; + n.gzhead.hcrc && n.pending > a && (t.adler = M(t.adler, n.pending_buf, n.pending - a, a)), n.gzindex === n.gzhead.extra.length && (n.gzindex = 0, n.status = 73) + } else n.status = 73; + if (73 === n.status) if (n.gzhead.name) { + a = n.pending; + do { + if (n.pending === n.pending_buf_size && (n.gzhead.hcrc && n.pending > a && (t.adler = M(t.adler, n.pending_buf, n.pending - a, a)), vt(t), a = n.pending, n.pending === n.pending_buf_size)) { + i = 1; + break + } + i = n.gzindex < n.gzhead.name.length ? 255 & n.gzhead.name.charCodeAt(n.gzindex++) : 0, xt(n, i) + } while (0 !== i); + n.gzhead.hcrc && n.pending > a && (t.adler = M(t.adler, n.pending_buf, n.pending - a, a)), 0 === i && (n.gzindex = 0, n.status = 91) + } else n.status = 91; + if (91 === n.status) if (n.gzhead.comment) { + a = n.pending; + do { + if (n.pending === n.pending_buf_size && (n.gzhead.hcrc && n.pending > a && (t.adler = M(t.adler, n.pending_buf, n.pending - a, a)), vt(t), a = n.pending, n.pending === n.pending_buf_size)) { + i = 1; + break + } + i = n.gzindex < n.gzhead.comment.length ? 255 & n.gzhead.comment.charCodeAt(n.gzindex++) : 0, xt(n, i) + } while (0 !== i); + n.gzhead.hcrc && n.pending > a && (t.adler = M(t.adler, n.pending_buf, n.pending - a, a)), 0 === i && (n.status = ut) + } else n.status = ut; + if (n.status === ut && (n.gzhead.hcrc ? (n.pending + 2 > n.pending_buf_size && vt(t), n.pending + 2 <= n.pending_buf_size && (xt(n, 255 & t.adler), xt(n, t.adler >> 8 & 255), t.adler = 0, n.status = wt)) : n.status = wt), 0 !== n.pending) { + if (vt(t), 0 === t.avail_out) return n.last_flush = -1, $ + } else if (0 === t.avail_in && pt(e) <= pt(s) && e !== Q) return gt(t, it); + if (n.status === bt && 0 !== t.avail_in) return gt(t, it); + if (0 !== t.avail_in || 0 !== n.lookahead || e !== W && n.status !== bt) { + let a = n.strategy === rt ? ((t, e) => { + let a; + for (; ;) { + if (0 === t.lookahead && (Rt(t), 0 === t.lookahead)) { + if (e === W) return 1; + break + } + if (t.match_length = 0, a = G(t, 0, t.window[t.strstart]), t.lookahead--, t.strstart++, a && (yt(t, !1), 0 === t.strm.avail_out)) return 1 + } + return t.insert = 0, e === Q ? (yt(t, !0), 0 === t.strm.avail_out ? 3 : 4) : t.last_lit && (yt(t, !1), 0 === t.strm.avail_out) ? 1 : 2 + })(n, e) : n.strategy === lt ? ((t, e) => { + let a, i, n, s; + const r = t.window; + for (; ;) { + if (t.lookahead <= ft) { + if (Rt(t), t.lookahead <= ft && e === W) return 1; + if (0 === t.lookahead) break + } + if (t.match_length = 0, t.lookahead >= 3 && t.strstart > 0 && (n = t.strstart - 1, i = r[n], i === r[++n] && i === r[++n] && i === r[++n])) { + s = t.strstart + ft; + do { + } while (i === r[++n] && i === r[++n] && i === r[++n] && i === r[++n] && i === r[++n] && i === r[++n] && i === r[++n] && i === r[++n] && n < s); + t.match_length = ft - (s - n), t.match_length > t.lookahead && (t.match_length = t.lookahead) + } + if (t.match_length >= 3 ? (a = G(t, 1, t.match_length - 3), t.lookahead -= t.match_length, t.strstart += t.match_length, t.match_length = 0) : (a = G(t, 0, t.window[t.strstart]), t.lookahead--, t.strstart++), a && (yt(t, !1), 0 === t.strm.avail_out)) return 1 + } + return t.insert = 0, e === Q ? (yt(t, !0), 0 === t.strm.avail_out ? 3 : 4) : t.last_lit && (yt(t, !1), 0 === t.strm.avail_out) ? 1 : 2 + })(n, e) : Dt[n.level].func(n, e); + if (3 !== a && 4 !== a || (n.status = bt), 1 === a || 3 === a) return 0 === t.avail_out && (n.last_flush = -1), $; + if (2 === a && (e === q ? X(n) : e !== V && (P(n, 0, 0, !1), e === J && (mt(n.head), 0 === n.lookahead && (n.strstart = 0, n.block_start = 0, n.insert = 0))), vt(t), 0 === t.avail_out)) return n.last_flush = -1, $ + } + return e !== Q ? $ : n.wrap <= 0 ? tt : (2 === n.wrap ? (xt(n, 255 & t.adler), xt(n, t.adler >> 8 & 255), xt(n, t.adler >> 16 & 255), xt(n, t.adler >> 24 & 255), xt(n, 255 & t.total_in), xt(n, t.total_in >> 8 & 255), xt(n, t.total_in >> 16 & 255), xt(n, t.total_in >> 24 & 255)) : (zt(n, t.adler >>> 16), zt(n, 65535 & t.adler)), vt(t), n.wrap > 0 && (n.wrap = -n.wrap), 0 !== n.pending ? $ : tt) + }, + deflateEnd: t => { + if (!t || !t.state) return et; + const e = t.state.status; + return 42 !== e && 69 !== e && 73 !== e && 91 !== e && e !== ut && e !== wt && e !== bt ? gt(t, et) : (t.state = null, e === wt ? gt(t, at) : $) + }, + deflateSetDictionary: (t, e) => { + let a = e.length; + if (!t || !t.state) return et; + const i = t.state, n = i.wrap; + if (2 === n || 1 === n && 42 !== i.status || i.lookahead) return et; + if (1 === n && (t.adler = B(t.adler, e, a, 0)), i.wrap = 0, a >= i.w_size) { + 0 === n && (mt(i.head), i.strstart = 0, i.block_start = 0, i.insert = 0); + let t = new Uint8Array(i.w_size); + t.set(e.subarray(a - i.w_size, a), 0), e = t, a = i.w_size + } + const s = t.avail_in, r = t.next_in, l = t.input; + for (t.avail_in = a, t.next_in = 0, t.input = e, Rt(i); i.lookahead >= 3;) { + let t = i.strstart, e = i.lookahead - 2; + do { + i.ins_h = kt(i, i.ins_h, i.window[t + 3 - 1]), i.prev[t & i.w_mask] = i.head[i.ins_h], i.head[i.ins_h] = t, t++ + } while (--e); + i.strstart = t, i.lookahead = 2, Rt(i) + } + return i.strstart += i.lookahead, i.block_start = i.strstart, i.insert = i.lookahead, i.lookahead = 0, i.match_length = i.prev_length = 2, i.match_available = 0, t.next_in = r, t.input = l, t.avail_in = s, i.wrap = n, $ + }, + deflateInfo: "pako deflate (from Nodeca project)" + }; + const Nt = (t, e) => Object.prototype.hasOwnProperty.call(t, e); + var Bt = function (t) { + const e = Array.prototype.slice.call(arguments, 1); + for (; e.length;) { + const a = e.shift(); + if (a) { + if ("object" != typeof a) throw new TypeError(a + "must be non-object"); + for (const e in a) Nt(a, e) && (t[e] = a[e]) + } + } + return t + }, Ct = t => { + let e = 0; + for (let a = 0, i = t.length; a < i; a++) e += t[a].length; + const a = new Uint8Array(e); + for (let e = 0, i = 0, n = t.length; e < n; e++) { + let n = t[e]; + a.set(n, i), i += n.length + } + return a + }; + let Mt = !0; + try { + String.fromCharCode.apply(null, new Uint8Array(1)) + } catch (t) { + Mt = !1 + } + const Ht = new Uint8Array(256); + for (let t = 0; t < 256; t++) Ht[t] = t >= 252 ? 6 : t >= 248 ? 5 : t >= 240 ? 4 : t >= 224 ? 3 : t >= 192 ? 2 : 1; + Ht[254] = Ht[254] = 1; + var jt = t => { + if ("function" == typeof TextEncoder && TextEncoder.prototype.encode) return (new TextEncoder).encode(t); + let e, a, i, n, s, r = t.length, l = 0; + for (n = 0; n < r; n++) a = t.charCodeAt(n), 55296 == (64512 & a) && n + 1 < r && (i = t.charCodeAt(n + 1), 56320 == (64512 & i) && (a = 65536 + (a - 55296 << 10) + (i - 56320), n++)), l += a < 128 ? 1 : a < 2048 ? 2 : a < 65536 ? 3 : 4; + for (e = new Uint8Array(l), s = 0, n = 0; s < l; n++) a = t.charCodeAt(n), 55296 == (64512 & a) && n + 1 < r && (i = t.charCodeAt(n + 1), 56320 == (64512 & i) && (a = 65536 + (a - 55296 << 10) + (i - 56320), n++)), a < 128 ? e[s++] = a : a < 2048 ? (e[s++] = 192 | a >>> 6, e[s++] = 128 | 63 & a) : a < 65536 ? (e[s++] = 224 | a >>> 12, e[s++] = 128 | a >>> 6 & 63, e[s++] = 128 | 63 & a) : (e[s++] = 240 | a >>> 18, e[s++] = 128 | a >>> 12 & 63, e[s++] = 128 | a >>> 6 & 63, e[s++] = 128 | 63 & a); + return e + }, Kt = (t, e) => { + const a = e || t.length; + if ("function" == typeof TextDecoder && TextDecoder.prototype.decode) return (new TextDecoder).decode(t.subarray(0, e)); + let i, n; + const s = new Array(2 * a); + for (n = 0, i = 0; i < a;) { + let e = t[i++]; + if (e < 128) { + s[n++] = e; + continue + } + let r = Ht[e]; + if (r > 4) s[n++] = 65533, i += r - 1; else { + for (e &= 2 === r ? 31 : 3 === r ? 15 : 7; r > 1 && i < a;) e = e << 6 | 63 & t[i++], r--; + r > 1 ? s[n++] = 65533 : e < 65536 ? s[n++] = e : (e -= 65536, s[n++] = 55296 | e >> 10 & 1023, s[n++] = 56320 | 1023 & e) + } + } + return ((t, e) => { + if (e < 65534 && t.subarray && Mt) return String.fromCharCode.apply(null, t.length === e ? t : t.subarray(0, e)); + let a = ""; + for (let i = 0; i < e; i++) a += String.fromCharCode(t[i]); + return a + })(s, n) + }, Pt = (t, e) => { + (e = e || t.length) > t.length && (e = t.length); + let a = e - 1; + for (; a >= 0 && 128 == (192 & t[a]);) a--; + return a < 0 || 0 === a ? e : a + Ht[t[a]] > e ? a : e + }; + var Yt = function () { + this.input = null, this.next_in = 0, this.avail_in = 0, this.total_in = 0, this.output = null, this.next_out = 0, this.avail_out = 0, this.total_out = 0, this.msg = "", this.state = null, this.data_type = 2, this.adler = 0 + }; + const Gt = Object.prototype.toString, { + Z_NO_FLUSH: Xt, + Z_SYNC_FLUSH: Wt, + Z_FULL_FLUSH: qt, + Z_FINISH: Jt, + Z_OK: Qt, + Z_STREAM_END: Vt, + Z_DEFAULT_COMPRESSION: $t, + Z_DEFAULT_STRATEGY: te, + Z_DEFLATED: ee + } = j; + + function ae(t) { + this.options = Bt({ + level: $t, + method: ee, + chunkSize: 16384, + windowBits: 15, + memLevel: 8, + strategy: te + }, t || {}); + let e = this.options; + e.raw && e.windowBits > 0 ? e.windowBits = -e.windowBits : e.gzip && e.windowBits > 0 && e.windowBits < 16 && (e.windowBits += 16), this.err = 0, this.msg = "", this.ended = !1, this.chunks = [], this.strm = new Yt, this.strm.avail_out = 0; + let a = Lt.deflateInit2(this.strm, e.level, e.method, e.windowBits, e.memLevel, e.strategy); + if (a !== Qt) throw new Error(H[a]); + if (e.header && Lt.deflateSetHeader(this.strm, e.header), e.dictionary) { + let t; + if (t = "string" == typeof e.dictionary ? jt(e.dictionary) : "[object ArrayBuffer]" === Gt.call(e.dictionary) ? new Uint8Array(e.dictionary) : e.dictionary, a = Lt.deflateSetDictionary(this.strm, t), a !== Qt) throw new Error(H[a]); + this._dict_set = !0 + } + } + + function ie(t, e) { + const a = new ae(e); + if (a.push(t, !0), a.err) throw a.msg || H[a.err]; + return a.result + } + + ae.prototype.push = function (t, e) { + const a = this.strm, i = this.options.chunkSize; + let n, s; + if (this.ended) return !1; + for (s = e === ~~e ? e : !0 === e ? Jt : Xt, "string" == typeof t ? a.input = jt(t) : "[object ArrayBuffer]" === Gt.call(t) ? a.input = new Uint8Array(t) : a.input = t, a.next_in = 0, a.avail_in = a.input.length; ;) if (0 === a.avail_out && (a.output = new Uint8Array(i), a.next_out = 0, a.avail_out = i), (s === Wt || s === qt) && a.avail_out <= 6) this.onData(a.output.subarray(0, a.next_out)), a.avail_out = 0; else { + if (n = Lt.deflate(a, s), n === Vt) return a.next_out > 0 && this.onData(a.output.subarray(0, a.next_out)), n = Lt.deflateEnd(this.strm), this.onEnd(n), this.ended = !0, n === Qt; + if (0 !== a.avail_out) { + if (s > 0 && a.next_out > 0) this.onData(a.output.subarray(0, a.next_out)), a.avail_out = 0; else if (0 === a.avail_in) break + } else this.onData(a.output) + } + return !0 + }, ae.prototype.onData = function (t) { + this.chunks.push(t) + }, ae.prototype.onEnd = function (t) { + t === Qt && (this.result = Ct(this.chunks)), this.chunks = [], this.err = t, this.msg = this.strm.msg + }; + var ne = { + Deflate: ae, deflate: ie, deflateRaw: function (t, e) { + return (e = e || {}).raw = !0, ie(t, e) + }, gzip: function (t, e) { + return (e = e || {}).gzip = !0, ie(t, e) + }, constants: j + }; + var se = function (t, e) { + let a, i, n, s, r, l, o, h, d, _, f, c, u, w, b, g, p, m, k, v, y, x, z, A; + const E = t.state; + a = t.next_in, z = t.input, i = a + (t.avail_in - 5), n = t.next_out, A = t.output, s = n - (e - t.avail_out), r = n + (t.avail_out - 257), l = E.dmax, o = E.wsize, h = E.whave, d = E.wnext, _ = E.window, f = E.hold, c = E.bits, u = E.lencode, w = E.distcode, b = (1 << E.lenbits) - 1, g = (1 << E.distbits) - 1; + t:do { + c < 15 && (f += z[a++] << c, c += 8, f += z[a++] << c, c += 8), p = u[f & b]; + e:for (; ;) { + if (m = p >>> 24, f >>>= m, c -= m, m = p >>> 16 & 255, 0 === m) A[n++] = 65535 & p; else { + if (!(16 & m)) { + if (0 == (64 & m)) { + p = u[(65535 & p) + (f & (1 << m) - 1)]; + continue e + } + if (32 & m) { + E.mode = 12; + break t + } + t.msg = "invalid literal/length code", E.mode = 30; + break t + } + k = 65535 & p, m &= 15, m && (c < m && (f += z[a++] << c, c += 8), k += f & (1 << m) - 1, f >>>= m, c -= m), c < 15 && (f += z[a++] << c, c += 8, f += z[a++] << c, c += 8), p = w[f & g]; + a:for (; ;) { + if (m = p >>> 24, f >>>= m, c -= m, m = p >>> 16 & 255, !(16 & m)) { + if (0 == (64 & m)) { + p = w[(65535 & p) + (f & (1 << m) - 1)]; + continue a + } + t.msg = "invalid distance code", E.mode = 30; + break t + } + if (v = 65535 & p, m &= 15, c < m && (f += z[a++] << c, c += 8, c < m && (f += z[a++] << c, c += 8)), v += f & (1 << m) - 1, v > l) { + t.msg = "invalid distance too far back", E.mode = 30; + break t + } + if (f >>>= m, c -= m, m = n - s, v > m) { + if (m = v - m, m > h && E.sane) { + t.msg = "invalid distance too far back", E.mode = 30; + break t + } + if (y = 0, x = _, 0 === d) { + if (y += o - m, m < k) { + k -= m; + do { + A[n++] = _[y++] + } while (--m); + y = n - v, x = A + } + } else if (d < m) { + if (y += o + d - m, m -= d, m < k) { + k -= m; + do { + A[n++] = _[y++] + } while (--m); + if (y = 0, d < k) { + m = d, k -= m; + do { + A[n++] = _[y++] + } while (--m); + y = n - v, x = A + } + } + } else if (y += d - m, m < k) { + k -= m; + do { + A[n++] = _[y++] + } while (--m); + y = n - v, x = A + } + for (; k > 2;) A[n++] = x[y++], A[n++] = x[y++], A[n++] = x[y++], k -= 3; + k && (A[n++] = x[y++], k > 1 && (A[n++] = x[y++])) + } else { + y = n - v; + do { + A[n++] = A[y++], A[n++] = A[y++], A[n++] = A[y++], k -= 3 + } while (k > 2); + k && (A[n++] = A[y++], k > 1 && (A[n++] = A[y++])) + } + break + } + } + break + } + } while (a < i && n < r); + k = c >> 3, a -= k, c -= k << 3, f &= (1 << c) - 1, t.next_in = a, t.next_out = n, t.avail_in = a < i ? i - a + 5 : 5 - (a - i), t.avail_out = n < r ? r - n + 257 : 257 - (n - r), E.hold = f, E.bits = c + }; + const re = 15, + le = new Uint16Array([3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31, 35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0]), + oe = new Uint8Array([16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 18, 18, 18, 18, 19, 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 16, 72, 78]), + he = new Uint16Array([1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193, 257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145, 8193, 12289, 16385, 24577, 0, 0]), + de = new Uint8Array([16, 16, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22, 23, 23, 24, 24, 25, 25, 26, 26, 27, 27, 28, 28, 29, 29, 64, 64]); + var _e = (t, e, a, i, n, s, r, l) => { + const o = l.bits; + let h, d, _, f, c, u, w = 0, b = 0, g = 0, p = 0, m = 0, k = 0, v = 0, y = 0, x = 0, + z = 0, A = null, E = 0; + const R = new Uint16Array(16), Z = new Uint16Array(16); + let U, S, D, T = null, O = 0; + for (w = 0; w <= re; w++) R[w] = 0; + for (b = 0; b < i; b++) R[e[a + b]]++; + for (m = o, p = re; p >= 1 && 0 === R[p]; p--) ; + if (m > p && (m = p), 0 === p) return n[s++] = 20971520, n[s++] = 20971520, l.bits = 1, 0; + for (g = 1; g < p && 0 === R[g]; g++) ; + for (m < g && (m = g), y = 1, w = 1; w <= re; w++) if (y <<= 1, y -= R[w], y < 0) return -1; + if (y > 0 && (0 === t || 1 !== p)) return -1; + for (Z[1] = 0, w = 1; w < re; w++) Z[w + 1] = Z[w] + R[w]; + for (b = 0; b < i; b++) 0 !== e[a + b] && (r[Z[e[a + b]]++] = b); + if (0 === t ? (A = T = r, u = 19) : 1 === t ? (A = le, E -= 257, T = oe, O -= 257, u = 256) : (A = he, T = de, u = -1), z = 0, b = 0, w = g, c = s, k = m, v = 0, _ = -1, x = 1 << m, f = x - 1, 1 === t && x > 852 || 2 === t && x > 592) return 1; + for (; ;) { + U = w - v, r[b] < u ? (S = 0, D = r[b]) : r[b] > u ? (S = T[O + r[b]], D = A[E + r[b]]) : (S = 96, D = 0), h = 1 << w - v, d = 1 << k, g = d; + do { + d -= h, n[c + (z >> v) + d] = U << 24 | S << 16 | D | 0 + } while (0 !== d); + for (h = 1 << w - 1; z & h;) h >>= 1; + if (0 !== h ? (z &= h - 1, z += h) : z = 0, b++, 0 == --R[w]) { + if (w === p) break; + w = e[a + r[b]] + } + if (w > m && (z & f) !== _) { + for (0 === v && (v = m), c += g, k = w - v, y = 1 << k; k + v < p && (y -= R[k + v], !(y <= 0));) k++, y <<= 1; + if (x += 1 << k, 1 === t && x > 852 || 2 === t && x > 592) return 1; + _ = z & f, n[_] = m << 24 | k << 16 | c - s | 0 + } + } + return 0 !== z && (n[c + z] = w - v << 24 | 64 << 16 | 0), l.bits = m, 0 + }; + const { + Z_FINISH: fe, + Z_BLOCK: ce, + Z_TREES: ue, + Z_OK: we, + Z_STREAM_END: be, + Z_NEED_DICT: ge, + Z_STREAM_ERROR: pe, + Z_DATA_ERROR: me, + Z_MEM_ERROR: ke, + Z_BUF_ERROR: ve, + Z_DEFLATED: ye + } = j, xe = 12, ze = 30, + Ae = t => (t >>> 24 & 255) + (t >>> 8 & 65280) + ((65280 & t) << 8) + ((255 & t) << 24); + + function Ee() { + this.mode = 0, this.last = !1, this.wrap = 0, this.havedict = !1, this.flags = 0, this.dmax = 0, this.check = 0, this.total = 0, this.head = null, this.wbits = 0, this.wsize = 0, this.whave = 0, this.wnext = 0, this.window = null, this.hold = 0, this.bits = 0, this.length = 0, this.offset = 0, this.extra = 0, this.lencode = null, this.distcode = null, this.lenbits = 0, this.distbits = 0, this.ncode = 0, this.nlen = 0, this.ndist = 0, this.have = 0, this.next = null, this.lens = new Uint16Array(320), this.work = new Uint16Array(288), this.lendyn = null, this.distdyn = null, this.sane = 0, this.back = 0, this.was = 0 + } + + const Re = t => { + if (!t || !t.state) return pe; + const e = t.state; + return t.total_in = t.total_out = e.total = 0, t.msg = "", e.wrap && (t.adler = 1 & e.wrap), e.mode = 1, e.last = 0, e.havedict = 0, e.dmax = 32768, e.head = null, e.hold = 0, e.bits = 0, e.lencode = e.lendyn = new Int32Array(852), e.distcode = e.distdyn = new Int32Array(592), e.sane = 1, e.back = -1, we + }, Ze = t => { + if (!t || !t.state) return pe; + const e = t.state; + return e.wsize = 0, e.whave = 0, e.wnext = 0, Re(t) + }, Ue = (t, e) => { + let a; + if (!t || !t.state) return pe; + const i = t.state; + return e < 0 ? (a = 0, e = -e) : (a = 1 + (e >> 4), e < 48 && (e &= 15)), e && (e < 8 || e > 15) ? pe : (null !== i.window && i.wbits !== e && (i.window = null), i.wrap = a, i.wbits = e, Ze(t)) + }, Se = (t, e) => { + if (!t) return pe; + const a = new Ee; + t.state = a, a.window = null; + const i = Ue(t, e); + return i !== we && (t.state = null), i + }; + let De, Te, Oe = !0; + const Ie = t => { + if (Oe) { + De = new Int32Array(512), Te = new Int32Array(32); + let e = 0; + for (; e < 144;) t.lens[e++] = 8; + for (; e < 256;) t.lens[e++] = 9; + for (; e < 280;) t.lens[e++] = 7; + for (; e < 288;) t.lens[e++] = 8; + for (_e(1, t.lens, 0, 288, De, 0, t.work, {bits: 9}), e = 0; e < 32;) t.lens[e++] = 5; + _e(2, t.lens, 0, 32, Te, 0, t.work, {bits: 5}), Oe = !1 + } + t.lencode = De, t.lenbits = 9, t.distcode = Te, t.distbits = 5 + }, Fe = (t, e, a, i) => { + let n; + const s = t.state; + return null === s.window && (s.wsize = 1 << s.wbits, s.wnext = 0, s.whave = 0, s.window = new Uint8Array(s.wsize)), i >= s.wsize ? (s.window.set(e.subarray(a - s.wsize, a), 0), s.wnext = 0, s.whave = s.wsize) : (n = s.wsize - s.wnext, n > i && (n = i), s.window.set(e.subarray(a - i, a - i + n), s.wnext), (i -= n) ? (s.window.set(e.subarray(a - i, a), 0), s.wnext = i, s.whave = s.wsize) : (s.wnext += n, s.wnext === s.wsize && (s.wnext = 0), s.whave < s.wsize && (s.whave += n))), 0 + }; + var Le = { + inflateReset: Ze, + inflateReset2: Ue, + inflateResetKeep: Re, + inflateInit: t => Se(t, 15), + inflateInit2: Se, + inflate: (t, e) => { + let a, i, n, s, r, l, o, h, d, _, f, c, u, w, b, g, p, m, k, v, y, x, z = 0; + const A = new Uint8Array(4); + let E, R; + const Z = new Uint8Array([16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15]); + if (!t || !t.state || !t.output || !t.input && 0 !== t.avail_in) return pe; + a = t.state, a.mode === xe && (a.mode = 13), r = t.next_out, n = t.output, o = t.avail_out, s = t.next_in, i = t.input, l = t.avail_in, h = a.hold, d = a.bits, _ = l, f = o, x = we; + t:for (; ;) switch (a.mode) { + case 1: + if (0 === a.wrap) { + a.mode = 13; + break + } + for (; d < 16;) { + if (0 === l) break t; + l--, h += i[s++] << d, d += 8 + } + if (2 & a.wrap && 35615 === h) { + a.check = 0, A[0] = 255 & h, A[1] = h >>> 8 & 255, a.check = M(a.check, A, 2, 0), h = 0, d = 0, a.mode = 2; + break + } + if (a.flags = 0, a.head && (a.head.done = !1), !(1 & a.wrap) || (((255 & h) << 8) + (h >> 8)) % 31) { + t.msg = "incorrect header check", a.mode = ze; + break + } + if ((15 & h) !== ye) { + t.msg = "unknown compression method", a.mode = ze; + break + } + if (h >>>= 4, d -= 4, y = 8 + (15 & h), 0 === a.wbits) a.wbits = y; else if (y > a.wbits) { + t.msg = "invalid window size", a.mode = ze; + break + } + a.dmax = 1 << a.wbits, t.adler = a.check = 1, a.mode = 512 & h ? 10 : xe, h = 0, d = 0; + break; + case 2: + for (; d < 16;) { + if (0 === l) break t; + l--, h += i[s++] << d, d += 8 + } + if (a.flags = h, (255 & a.flags) !== ye) { + t.msg = "unknown compression method", a.mode = ze; + break + } + if (57344 & a.flags) { + t.msg = "unknown header flags set", a.mode = ze; + break + } + a.head && (a.head.text = h >> 8 & 1), 512 & a.flags && (A[0] = 255 & h, A[1] = h >>> 8 & 255, a.check = M(a.check, A, 2, 0)), h = 0, d = 0, a.mode = 3; + case 3: + for (; d < 32;) { + if (0 === l) break t; + l--, h += i[s++] << d, d += 8 + } + a.head && (a.head.time = h), 512 & a.flags && (A[0] = 255 & h, A[1] = h >>> 8 & 255, A[2] = h >>> 16 & 255, A[3] = h >>> 24 & 255, a.check = M(a.check, A, 4, 0)), h = 0, d = 0, a.mode = 4; + case 4: + for (; d < 16;) { + if (0 === l) break t; + l--, h += i[s++] << d, d += 8 + } + a.head && (a.head.xflags = 255 & h, a.head.os = h >> 8), 512 & a.flags && (A[0] = 255 & h, A[1] = h >>> 8 & 255, a.check = M(a.check, A, 2, 0)), h = 0, d = 0, a.mode = 5; + case 5: + if (1024 & a.flags) { + for (; d < 16;) { + if (0 === l) break t; + l--, h += i[s++] << d, d += 8 + } + a.length = h, a.head && (a.head.extra_len = h), 512 & a.flags && (A[0] = 255 & h, A[1] = h >>> 8 & 255, a.check = M(a.check, A, 2, 0)), h = 0, d = 0 + } else a.head && (a.head.extra = null); + a.mode = 6; + case 6: + if (1024 & a.flags && (c = a.length, c > l && (c = l), c && (a.head && (y = a.head.extra_len - a.length, a.head.extra || (a.head.extra = new Uint8Array(a.head.extra_len)), a.head.extra.set(i.subarray(s, s + c), y)), 512 & a.flags && (a.check = M(a.check, i, c, s)), l -= c, s += c, a.length -= c), a.length)) break t; + a.length = 0, a.mode = 7; + case 7: + if (2048 & a.flags) { + if (0 === l) break t; + c = 0; + do { + y = i[s + c++], a.head && y && a.length < 65536 && (a.head.name += String.fromCharCode(y)) + } while (y && c < l); + if (512 & a.flags && (a.check = M(a.check, i, c, s)), l -= c, s += c, y) break t + } else a.head && (a.head.name = null); + a.length = 0, a.mode = 8; + case 8: + if (4096 & a.flags) { + if (0 === l) break t; + c = 0; + do { + y = i[s + c++], a.head && y && a.length < 65536 && (a.head.comment += String.fromCharCode(y)) + } while (y && c < l); + if (512 & a.flags && (a.check = M(a.check, i, c, s)), l -= c, s += c, y) break t + } else a.head && (a.head.comment = null); + a.mode = 9; + case 9: + if (512 & a.flags) { + for (; d < 16;) { + if (0 === l) break t; + l--, h += i[s++] << d, d += 8 + } + if (h !== (65535 & a.check)) { + t.msg = "header crc mismatch", a.mode = ze; + break + } + h = 0, d = 0 + } + a.head && (a.head.hcrc = a.flags >> 9 & 1, a.head.done = !0), t.adler = a.check = 0, a.mode = xe; + break; + case 10: + for (; d < 32;) { + if (0 === l) break t; + l--, h += i[s++] << d, d += 8 + } + t.adler = a.check = Ae(h), h = 0, d = 0, a.mode = 11; + case 11: + if (0 === a.havedict) return t.next_out = r, t.avail_out = o, t.next_in = s, t.avail_in = l, a.hold = h, a.bits = d, ge; + t.adler = a.check = 1, a.mode = xe; + case xe: + if (e === ce || e === ue) break t; + case 13: + if (a.last) { + h >>>= 7 & d, d -= 7 & d, a.mode = 27; + break + } + for (; d < 3;) { + if (0 === l) break t; + l--, h += i[s++] << d, d += 8 + } + switch (a.last = 1 & h, h >>>= 1, d -= 1, 3 & h) { + case 0: + a.mode = 14; + break; + case 1: + if (Ie(a), a.mode = 20, e === ue) { + h >>>= 2, d -= 2; + break t + } + break; + case 2: + a.mode = 17; + break; + case 3: + t.msg = "invalid block type", a.mode = ze + } + h >>>= 2, d -= 2; + break; + case 14: + for (h >>>= 7 & d, d -= 7 & d; d < 32;) { + if (0 === l) break t; + l--, h += i[s++] << d, d += 8 + } + if ((65535 & h) != (h >>> 16 ^ 65535)) { + t.msg = "invalid stored block lengths", a.mode = ze; + break + } + if (a.length = 65535 & h, h = 0, d = 0, a.mode = 15, e === ue) break t; + case 15: + a.mode = 16; + case 16: + if (c = a.length, c) { + if (c > l && (c = l), c > o && (c = o), 0 === c) break t; + n.set(i.subarray(s, s + c), r), l -= c, s += c, o -= c, r += c, a.length -= c; + break + } + a.mode = xe; + break; + case 17: + for (; d < 14;) { + if (0 === l) break t; + l--, h += i[s++] << d, d += 8 + } + if (a.nlen = 257 + (31 & h), h >>>= 5, d -= 5, a.ndist = 1 + (31 & h), h >>>= 5, d -= 5, a.ncode = 4 + (15 & h), h >>>= 4, d -= 4, a.nlen > 286 || a.ndist > 30) { + t.msg = "too many length or distance symbols", a.mode = ze; + break + } + a.have = 0, a.mode = 18; + case 18: + for (; a.have < a.ncode;) { + for (; d < 3;) { + if (0 === l) break t; + l--, h += i[s++] << d, d += 8 + } + a.lens[Z[a.have++]] = 7 & h, h >>>= 3, d -= 3 + } + for (; a.have < 19;) a.lens[Z[a.have++]] = 0; + if (a.lencode = a.lendyn, a.lenbits = 7, E = {bits: a.lenbits}, x = _e(0, a.lens, 0, 19, a.lencode, 0, a.work, E), a.lenbits = E.bits, x) { + t.msg = "invalid code lengths set", a.mode = ze; + break + } + a.have = 0, a.mode = 19; + case 19: + for (; a.have < a.nlen + a.ndist;) { + for (; z = a.lencode[h & (1 << a.lenbits) - 1], b = z >>> 24, g = z >>> 16 & 255, p = 65535 & z, !(b <= d);) { + if (0 === l) break t; + l--, h += i[s++] << d, d += 8 + } + if (p < 16) h >>>= b, d -= b, a.lens[a.have++] = p; else { + if (16 === p) { + for (R = b + 2; d < R;) { + if (0 === l) break t; + l--, h += i[s++] << d, d += 8 + } + if (h >>>= b, d -= b, 0 === a.have) { + t.msg = "invalid bit length repeat", a.mode = ze; + break + } + y = a.lens[a.have - 1], c = 3 + (3 & h), h >>>= 2, d -= 2 + } else if (17 === p) { + for (R = b + 3; d < R;) { + if (0 === l) break t; + l--, h += i[s++] << d, d += 8 + } + h >>>= b, d -= b, y = 0, c = 3 + (7 & h), h >>>= 3, d -= 3 + } else { + for (R = b + 7; d < R;) { + if (0 === l) break t; + l--, h += i[s++] << d, d += 8 + } + h >>>= b, d -= b, y = 0, c = 11 + (127 & h), h >>>= 7, d -= 7 + } + if (a.have + c > a.nlen + a.ndist) { + t.msg = "invalid bit length repeat", a.mode = ze; + break + } + for (; c--;) a.lens[a.have++] = y + } + } + if (a.mode === ze) break; + if (0 === a.lens[256]) { + t.msg = "invalid code -- missing end-of-block", a.mode = ze; + break + } + if (a.lenbits = 9, E = {bits: a.lenbits}, x = _e(1, a.lens, 0, a.nlen, a.lencode, 0, a.work, E), a.lenbits = E.bits, x) { + t.msg = "invalid literal/lengths set", a.mode = ze; + break + } + if (a.distbits = 6, a.distcode = a.distdyn, E = {bits: a.distbits}, x = _e(2, a.lens, a.nlen, a.ndist, a.distcode, 0, a.work, E), a.distbits = E.bits, x) { + t.msg = "invalid distances set", a.mode = ze; + break + } + if (a.mode = 20, e === ue) break t; + case 20: + a.mode = 21; + case 21: + if (l >= 6 && o >= 258) { + t.next_out = r, t.avail_out = o, t.next_in = s, t.avail_in = l, a.hold = h, a.bits = d, se(t, f), r = t.next_out, n = t.output, o = t.avail_out, s = t.next_in, i = t.input, l = t.avail_in, h = a.hold, d = a.bits, a.mode === xe && (a.back = -1); + break + } + for (a.back = 0; z = a.lencode[h & (1 << a.lenbits) - 1], b = z >>> 24, g = z >>> 16 & 255, p = 65535 & z, !(b <= d);) { + if (0 === l) break t; + l--, h += i[s++] << d, d += 8 + } + if (g && 0 == (240 & g)) { + for (m = b, k = g, v = p; z = a.lencode[v + ((h & (1 << m + k) - 1) >> m)], b = z >>> 24, g = z >>> 16 & 255, p = 65535 & z, !(m + b <= d);) { + if (0 === l) break t; + l--, h += i[s++] << d, d += 8 + } + h >>>= m, d -= m, a.back += m + } + if (h >>>= b, d -= b, a.back += b, a.length = p, 0 === g) { + a.mode = 26; + break + } + if (32 & g) { + a.back = -1, a.mode = xe; + break + } + if (64 & g) { + t.msg = "invalid literal/length code", a.mode = ze; + break + } + a.extra = 15 & g, a.mode = 22; + case 22: + if (a.extra) { + for (R = a.extra; d < R;) { + if (0 === l) break t; + l--, h += i[s++] << d, d += 8 + } + a.length += h & (1 << a.extra) - 1, h >>>= a.extra, d -= a.extra, a.back += a.extra + } + a.was = a.length, a.mode = 23; + case 23: + for (; z = a.distcode[h & (1 << a.distbits) - 1], b = z >>> 24, g = z >>> 16 & 255, p = 65535 & z, !(b <= d);) { + if (0 === l) break t; + l--, h += i[s++] << d, d += 8 + } + if (0 == (240 & g)) { + for (m = b, k = g, v = p; z = a.distcode[v + ((h & (1 << m + k) - 1) >> m)], b = z >>> 24, g = z >>> 16 & 255, p = 65535 & z, !(m + b <= d);) { + if (0 === l) break t; + l--, h += i[s++] << d, d += 8 + } + h >>>= m, d -= m, a.back += m + } + if (h >>>= b, d -= b, a.back += b, 64 & g) { + t.msg = "invalid distance code", a.mode = ze; + break + } + a.offset = p, a.extra = 15 & g, a.mode = 24; + case 24: + if (a.extra) { + for (R = a.extra; d < R;) { + if (0 === l) break t; + l--, h += i[s++] << d, d += 8 + } + a.offset += h & (1 << a.extra) - 1, h >>>= a.extra, d -= a.extra, a.back += a.extra + } + if (a.offset > a.dmax) { + t.msg = "invalid distance too far back", a.mode = ze; + break + } + a.mode = 25; + case 25: + if (0 === o) break t; + if (c = f - o, a.offset > c) { + if (c = a.offset - c, c > a.whave && a.sane) { + t.msg = "invalid distance too far back", a.mode = ze; + break + } + c > a.wnext ? (c -= a.wnext, u = a.wsize - c) : u = a.wnext - c, c > a.length && (c = a.length), w = a.window + } else w = n, u = r - a.offset, c = a.length; + c > o && (c = o), o -= c, a.length -= c; + do { + n[r++] = w[u++] + } while (--c); + 0 === a.length && (a.mode = 21); + break; + case 26: + if (0 === o) break t; + n[r++] = a.length, o--, a.mode = 21; + break; + case 27: + if (a.wrap) { + for (; d < 32;) { + if (0 === l) break t; + l--, h |= i[s++] << d, d += 8 + } + if (f -= o, t.total_out += f, a.total += f, f && (t.adler = a.check = a.flags ? M(a.check, n, f, r - f) : B(a.check, n, f, r - f)), f = o, (a.flags ? h : Ae(h)) !== a.check) { + t.msg = "incorrect data check", a.mode = ze; + break + } + h = 0, d = 0 + } + a.mode = 28; + case 28: + if (a.wrap && a.flags) { + for (; d < 32;) { + if (0 === l) break t; + l--, h += i[s++] << d, d += 8 + } + if (h !== (4294967295 & a.total)) { + t.msg = "incorrect length check", a.mode = ze; + break + } + h = 0, d = 0 + } + a.mode = 29; + case 29: + x = be; + break t; + case ze: + x = me; + break t; + case 31: + return ke; + case 32: + default: + return pe + } + return t.next_out = r, t.avail_out = o, t.next_in = s, t.avail_in = l, a.hold = h, a.bits = d, (a.wsize || f !== t.avail_out && a.mode < ze && (a.mode < 27 || e !== fe)) && Fe(t, t.output, t.next_out, f - t.avail_out), _ -= t.avail_in, f -= t.avail_out, t.total_in += _, t.total_out += f, a.total += f, a.wrap && f && (t.adler = a.check = a.flags ? M(a.check, n, f, t.next_out - f) : B(a.check, n, f, t.next_out - f)), t.data_type = a.bits + (a.last ? 64 : 0) + (a.mode === xe ? 128 : 0) + (20 === a.mode || 15 === a.mode ? 256 : 0), (0 === _ && 0 === f || e === fe) && x === we && (x = ve), x + }, + inflateEnd: t => { + if (!t || !t.state) return pe; + let e = t.state; + return e.window && (e.window = null), t.state = null, we + }, + inflateGetHeader: (t, e) => { + if (!t || !t.state) return pe; + const a = t.state; + return 0 == (2 & a.wrap) ? pe : (a.head = e, e.done = !1, we) + }, + inflateSetDictionary: (t, e) => { + const a = e.length; + let i, n, s; + return t && t.state ? (i = t.state, 0 !== i.wrap && 11 !== i.mode ? pe : 11 === i.mode && (n = 1, n = B(n, e, a, 0), n !== i.check) ? me : (s = Fe(t, e, a, a), s ? (i.mode = 31, ke) : (i.havedict = 1, we))) : pe + }, + inflateInfo: "pako inflate (from Nodeca project)" + }; + var Ne = function () { + this.text = 0, this.time = 0, this.xflags = 0, this.os = 0, this.extra = null, this.extra_len = 0, this.name = "", this.comment = "", this.hcrc = 0, this.done = !1 + }; + const Be = Object.prototype.toString, { + Z_NO_FLUSH: Ce, + Z_FINISH: Me, + Z_OK: He, + Z_STREAM_END: je, + Z_NEED_DICT: Ke, + Z_STREAM_ERROR: Pe, + Z_DATA_ERROR: Ye, + Z_MEM_ERROR: Ge + } = j; + + function Xe(t) { + this.options = Bt({chunkSize: 65536, windowBits: 15, to: ""}, t || {}); + const e = this.options; + e.raw && e.windowBits >= 0 && e.windowBits < 16 && (e.windowBits = -e.windowBits, 0 === e.windowBits && (e.windowBits = -15)), !(e.windowBits >= 0 && e.windowBits < 16) || t && t.windowBits || (e.windowBits += 32), e.windowBits > 15 && e.windowBits < 48 && 0 == (15 & e.windowBits) && (e.windowBits |= 15), this.err = 0, this.msg = "", this.ended = !1, this.chunks = [], this.strm = new Yt, this.strm.avail_out = 0; + let a = Le.inflateInit2(this.strm, e.windowBits); + if (a !== He) throw new Error(H[a]); + if (this.header = new Ne, Le.inflateGetHeader(this.strm, this.header), e.dictionary && ("string" == typeof e.dictionary ? e.dictionary = jt(e.dictionary) : "[object ArrayBuffer]" === Be.call(e.dictionary) && (e.dictionary = new Uint8Array(e.dictionary)), e.raw && (a = Le.inflateSetDictionary(this.strm, e.dictionary), a !== He))) throw new Error(H[a]) + } + + function We(t, e) { + const a = new Xe(e); + if (a.push(t), a.err) throw a.msg || H[a.err]; + return a.result + } + + Xe.prototype.push = function (t, e) { + const a = this.strm, i = this.options.chunkSize, n = this.options.dictionary; + let s, r, l; + if (this.ended) return !1; + for (r = e === ~~e ? e : !0 === e ? Me : Ce, "[object ArrayBuffer]" === Be.call(t) ? a.input = new Uint8Array(t) : a.input = t, a.next_in = 0, a.avail_in = a.input.length; ;) { + for (0 === a.avail_out && (a.output = new Uint8Array(i), a.next_out = 0, a.avail_out = i), s = Le.inflate(a, r), s === Ke && n && (s = Le.inflateSetDictionary(a, n), s === He ? s = Le.inflate(a, r) : s === Ye && (s = Ke)); a.avail_in > 0 && s === je && a.state.wrap > 0 && 0 !== t[a.next_in];) Le.inflateReset(a), s = Le.inflate(a, r); + switch (s) { + case Pe: + case Ye: + case Ke: + case Ge: + return this.onEnd(s), this.ended = !0, !1 + } + if (l = a.avail_out, a.next_out && (0 === a.avail_out || s === je)) if ("string" === this.options.to) { + let t = Pt(a.output, a.next_out), e = a.next_out - t, n = Kt(a.output, t); + a.next_out = e, a.avail_out = i - e, e && a.output.set(a.output.subarray(t, t + e), 0), this.onData(n) + } else this.onData(a.output.length === a.next_out ? a.output : a.output.subarray(0, a.next_out)); + if (s !== He || 0 !== l) { + if (s === je) return s = Le.inflateEnd(this.strm), this.onEnd(s), this.ended = !0, !0; + if (0 === a.avail_in) break + } + } + return !0 + }, Xe.prototype.onData = function (t) { + this.chunks.push(t) + }, Xe.prototype.onEnd = function (t) { + t === He && ("string" === this.options.to ? this.result = this.chunks.join("") : this.result = Ct(this.chunks)), this.chunks = [], this.err = t, this.msg = this.strm.msg + }; + var qe = { + Inflate: Xe, inflate: We, inflateRaw: function (t, e) { + return (e = e || {}).raw = !0, We(t, e) + }, ungzip: We, constants: j + }; + const {Deflate: Je, deflate: Qe, deflateRaw: Ve, gzip: $e} = ne, { + Inflate: ta, + inflate: ea, + inflateRaw: aa, + ungzip: ia + } = qe; + var na = Je, sa = Qe, ra = Ve, la = $e, oa = ta, ha = ea, da = aa, _a = ia, fa = j, + ca = { + Deflate: na, + deflate: sa, + deflateRaw: ra, + gzip: la, + Inflate: oa, + inflate: ha, + inflateRaw: da, + ungzip: _a, + constants: fa + }; + t.Deflate = na, t.Inflate = oa, t.constants = fa, t.default = ca, t.deflate = sa, t.deflateRaw = ra, t.gzip = la, t.inflate = ha, t.inflateRaw = da, t.ungzip = _a, Object.defineProperty(t, "__esModule", {value: !0}) + })); + /****************** initialization finish ******************/ + // 先拆分B站gRPC校验头和protobuf数据体 + let header = rawBody.slice(0, 5); + body = rawBody.slice(5); + // 处理response压缩protobuf数据体 + switch (header?.[0]) { + case 0: // unGzip + break; + case 1: // Gzip + body = pako.ungzip(body); + header[0] = 0; // unGzip + break; } - internalBinaryWrite(message, writer, options) { - if (message.jsonStr !== '') - writer - .tag(1, WireType.LengthDelimited) - .string(message.jsonStr); - let u = options.writeUnknownFields; - if (u !== false) - (u == true ? UnknownFieldHandler.onWrite : u)( - this.typeName, - message, - writer - ); - return writer; + ; + // 解析链接并处理protobuf数据 + switch (HOST) { + case "grpc.biliapi.net": // HTTP/2 + case "app.bilibili.com": // HTTP/1.1 + /****************** initialization start *******************/ + // google.protobuf.Any + class Any$Type extends MessageType { + constructor() { + super("google.protobuf.Any", [{ + no: 1, + name: "type_url", + kind: "scalar", + T: 9 + }, {no: 2, name: "value", kind: "scalar", T: 12}]) + } + + pack(message, type) { + return { + typeUrl: this.typeNameToUrl(type.typeName), + value: type.toBinary(message), + } + } + + unpack(any, type, options) { + if (!this.contains(any, type)) throw new Error("Cannot unpack google.protobuf.Any with typeUrl '" + any.typeUrl + "' as " + type.typeName + "."); + return type.fromBinary(any.value, options) + } + + contains(any, type) { + if (!any.typeUrl.length) return false; + let wants = typeof type == "string" ? type : type.typeName; + let has = this.typeUrlToName(any.typeUrl); + return wants === has + } + + internalJsonWrite(any, options) { + if (any.typeUrl === "") return {}; + let typeName = this.typeUrlToName(any.typeUrl); + let opt = jsonWriteOptions(options); + let type = opt.typeRegistry?.find(t => t.typeName === typeName); + if (!type) throw new globalThis.Error("Unable to convert google.protobuf.Any with typeUrl '" + any.typeUrl + "' to JSON. The specified type " + typeName + " is not available in the type registry."); + let value = type.fromBinary(any.value, {readUnknownField: false}); + let json = type.internalJsonWrite(value, opt); + if (typeName.startsWith("google.protobuf.") || !isJsonObject(json)) json = {value: json}; + json["@type"] = any.typeUrl; + return json + } + + internalJsonRead(json, options, target) { + if (!isJsonObject(json)) throw new globalThis.Error("Unable to parse google.protobuf.Any from JSON " + typeofJsonValue(json) + "."); + if (typeof json["@type"] != "string" || json["@type"] == "") return this.create(); + let typeName = this.typeUrlToName(json["@type"]); + let type = options?.typeRegistry?.find(t => t.typeName == typeName); + if (!type) throw new globalThis.Error("Unable to parse google.protobuf.Any from JSON. The specified type " + typeName + " is not available in the type registry."); + let value; + if (typeName.startsWith("google.protobuf.") && json.hasOwnProperty("value")) value = type.fromJson(json["value"], options); else { + let copy = Object.assign({}, json); + delete copy["@type"]; + value = type.fromJson(copy, options) + } + if (target === undefined) target = this.create(); + target.typeUrl = json["@type"]; + target.value = type.toBinary(value); + return target + } + + typeNameToUrl(name) { + if (!name.length) throw new Error("invalid type name: " + name); + return "type.googleapis.com/" + name + } + + typeUrlToName(url) { + if (!url.length) throw new Error("invalid type url: " + url); + let slash = url.lastIndexOf("/"); + let name = slash > 0 ? url.substring(slash + 1) : url; + if (!name.length) throw new Error("invalid type url: " + url); + return name + } + + create(value) { + const message = {typeUrl: "", value: new Uint8Array(0)}; + globalThis.Object.defineProperty(message, MESSAGE_TYPE, { + enumerable: false, + value: this + }); + if (value !== undefined) reflectionMergePartial(this, message, value); + return message + } + + internalBinaryRead(reader, length, options, target) { + let message = target ?? this.create(), end = reader.pos + length; + while (reader.pos < end) { + let [fieldNo, wireType] = reader.tag(); + switch (fieldNo) { + case 1: + message.typeUrl = reader.string(); + break; + case 2: + message.value = reader.bytes(); + break; + default: + let u = options.readUnknownField; + if (u === "throw") throw new globalThis.Error(`Unknown field ${fieldNo}(wire type ${wireType})for ${this.typeName}`); + let d = reader.skip(wireType); + if (u !== false) (u === true ? UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d) + } + } + return message + } + + internalBinaryWrite(message, writer, options) { + if (message.typeUrl !== "") writer.tag(1, WireType.LengthDelimited).string(message.typeUrl); + if (message.value.length) writer.tag(2, WireType.LengthDelimited).bytes(message.value); + let u = options.writeUnknownFields; + if (u !== false) (u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer); + return writer + } + } + + const Any = new Any$Type(); + + // CM 广告 + class CM$Type extends MessageType { + constructor() { + super("CM", [{no: 1, name: "source_content", kind: "message", T: () => Any}]) + } + + create(value) { + const message = {}; + globalThis.Object.defineProperty(message, MESSAGE_TYPE, { + enumerable: false, + value: this + }); + if (value !== undefined) reflectionMergePartial(this, message, value); + return message + } + + internalBinaryRead(reader, length, options, target) { + let message = target ?? this.create(), end = reader.pos + length; + while (reader.pos < end) { + let [fieldNo, wireType] = reader.tag(); + switch (fieldNo) { + case 1: + message.sourceContent = Any.internalBinaryRead(reader, reader.uint32(), options, message.sourceContent); + break; + default: + let u = options.readUnknownField; + if (u === "throw") throw new globalThis.Error(`Unknown field ${fieldNo}(wire type ${wireType})for ${this.typeName}`); + let d = reader.skip(wireType); + if (u !== false) (u === true ? UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d) + } + } + return message + } + + internalBinaryWrite(message, writer, options) { + if (message.sourceContent) Any.internalBinaryWrite(message.sourceContent, writer.tag(1, WireType.LengthDelimited).fork(), options).join(); + let u = options.writeUnknownFields; + if (u !== false) (u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer); + return writer + } + } + + const CM = new CM$Type(); + /****************** initialization finish ******************/ + switch (PATHs?.[0]) { + case "bilibili.app.playurl.v1.PlayURL": // 投稿视频 + switch (PATHs?.[1]) { + case "PlayView": // 播放地址 + /****************** initialization start *******************/ + // protobuf/bilibili/app/playurl/playurl.proto + class PlayViewReply$Type extends MessageType { + constructor() { + super("PlayViewReply", [{ + no: 5, + name: "play_arc", + kind: "message", + T: () => PlayArcConf + }]) + } + + create(value) { + const message = {}; + globalThis.Object.defineProperty(message, MESSAGE_TYPE, { + enumerable: false, + value: this + }); + if (value !== undefined) reflectionMergePartial(this, message, value); + return message + } + + internalBinaryRead(reader, length, options, target) { + let message = target ?? this.create(), + end = reader.pos + length; + while (reader.pos < end) { + let [fieldNo, wireType] = reader.tag(); + switch (fieldNo) { + case 5: + message.playArc = PlayArcConf.internalBinaryRead(reader, reader.uint32(), options, message.playArc); + break; + default: + let u = options.readUnknownField; + if (u === "throw") throw new globalThis.Error(`Unknown field ${fieldNo}(wire type ${wireType})for ${this.typeName}`); + let d = reader.skip(wireType); + if (u !== false) (u === true ? UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d) + } + } + return message + } + + internalBinaryWrite(message, writer, options) { + if (message.playArc) PlayArcConf.internalBinaryWrite(message.playArc, writer.tag(5, WireType.LengthDelimited).fork(), options).join(); + let u = options.writeUnknownFields; + if (u !== false) (u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer); + return writer + } + } + + const PlayViewReply = new PlayViewReply$Type(); + + class PlayArcConf$Type extends MessageType { + constructor() { + super("PlayArcConf", [{ + no: 1, + name: "background_play_conf", + kind: "message", + T: () => ArcConf + }]) + } + + create(value) { + const message = {}; + globalThis.Object.defineProperty(message, MESSAGE_TYPE, { + enumerable: false, + value: this + }); + if (value !== undefined) reflectionMergePartial(this, message, value); + return message + } + + internalBinaryRead(reader, length, options, target) { + let message = target ?? this.create(), + end = reader.pos + length; + while (reader.pos < end) { + let [fieldNo, wireType] = reader.tag(); + switch (fieldNo) { + case 1: + message.backgroundPlayConf = ArcConf.internalBinaryRead(reader, reader.uint32(), options, message.backgroundPlayConf); + break; + default: + let u = options.readUnknownField; + if (u === "throw") throw new globalThis.Error(`Unknown field ${fieldNo}(wire type ${wireType})for ${this.typeName}`); + let d = reader.skip(wireType); + if (u !== false) (u === true ? UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d) + } + } + return message + } + + internalBinaryWrite(message, writer, options) { + if (message.backgroundPlayConf) ArcConf.internalBinaryWrite(message.backgroundPlayConf, writer.tag(1, WireType.LengthDelimited).fork(), options).join(); + let u = options.writeUnknownFields; + if (u !== false) (u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer); + return writer + } + } + + const PlayArcConf = new PlayArcConf$Type(); + + class ArcConf$Type extends MessageType { + constructor() { + super("ArcConf", [{ + no: 1, + name: "is_support", + kind: "scalar", + T: 8 + }, {no: 2, name: "disabled", kind: "scalar", T: 8}, { + no: 3, + name: "extra_content", + kind: "message", + T: () => ExtraContent + }]) + } + + create(value) { + const message = {isSupport: false, disabled: false}; + globalThis.Object.defineProperty(message, MESSAGE_TYPE, { + enumerable: false, + value: this + }); + if (value !== undefined) reflectionMergePartial(this, message, value); + return message + } + + internalBinaryRead(reader, length, options, target) { + let message = target ?? this.create(), + end = reader.pos + length; + while (reader.pos < end) { + let [fieldNo, wireType] = reader.tag(); + switch (fieldNo) { + case 1: + message.isSupport = reader.bool(); + break; + case 2: + message.disabled = reader.bool(); + break; + case 3: + message.extraContent = ExtraContent.internalBinaryRead(reader, reader.uint32(), options, message.extraContent); + break; + default: + let u = options.readUnknownField; + if (u === "throw") throw new globalThis.Error(`Unknown field ${fieldNo}(wire type ${wireType})for ${this.typeName}`); + let d = reader.skip(wireType); + if (u !== false) (u === true ? UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d) + } + } + return message + } + + internalBinaryWrite(message, writer, options) { + if (message.isSupport !== false) writer.tag(1, WireType.Varint).bool(message.isSupport); + if (message.disabled !== false) writer.tag(2, WireType.Varint).bool(message.disabled); + if (message.extraContent) ExtraContent.internalBinaryWrite(message.extraContent, writer.tag(3, WireType.LengthDelimited).fork(), options).join(); + let u = options.writeUnknownFields; + if (u !== false) (u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer); + return writer + } + } + + const ArcConf = new ArcConf$Type(); + + class ExtraContent$Type extends MessageType { + constructor() { + super("ExtraContent", [{ + no: 1, + name: "disabled_reason", + kind: "scalar", + T: 9 + }, {no: 2, name: "disabled_code", kind: "scalar", T: 3, L: 0}]) + } + + create(value) { + const message = {disabledReason: "", disabledCode: 0n}; + globalThis.Object.defineProperty(message, MESSAGE_TYPE, { + enumerable: false, + value: this + }); + if (value !== undefined) reflectionMergePartial(this, message, value); + return message + } + + internalBinaryRead(reader, length, options, target) { + let message = target ?? this.create(), + end = reader.pos + length; + while (reader.pos < end) { + let [fieldNo, wireType] = reader.tag(); + switch (fieldNo) { + case 1: + message.disabledReason = reader.string(); + break; + case 2: + message.disabledCode = reader.int64().toBigInt(); + break; + default: + let u = options.readUnknownField; + if (u === "throw") throw new globalThis.Error(`Unknown field ${fieldNo}(wire type ${wireType})for ${this.typeName}`); + let d = reader.skip(wireType); + if (u !== false) (u === true ? UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d) + } + } + return message + } + + internalBinaryWrite(message, writer, options) { + if (message.disabledReason !== "") writer.tag(1, WireType.LengthDelimited).string(message.disabledReason); + if (message.disabledCode !== 0n) writer.tag(2, WireType.Varint).int64(message.disabledCode); + let u = options.writeUnknownFields; + if (u !== false) (u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer); + return writer + } + } + + const ExtraContent = new ExtraContent$Type(); + /****************** initialization finish ******************/ + let data = PlayViewReply.fromBinary(body); + const oldBackgroundConf = data.playArc?.backgroundPlayConf; + if (oldBackgroundConf && (!oldBackgroundConf.isSupport || oldBackgroundConf.disabled)) { + $.log(`🎉 ${$.name}`, "后台播放限制去除"); + data.playArc.backgroundPlayConf.isSupport = true; + data.playArc.backgroundPlayConf.disabled = false; + data.playArc.backgroundPlayConf.extraContent = null; + } else { + $.log(`🚧 ${$.name}`, "无后台播放限制"); + } + body = PlayViewReply.toBinary(data); + break; + case "PlayConf": // 播放配置 + break; + } + ; + break; + case "bilibili.app.dynamic.v2.Dynamic": // 动态 + /****************** initialization start *******************/ + // protobuf/bilibili/app/dynamic/dynamic.proto + var DynamicType; + (function (DynamicType) { + DynamicType[DynamicType["dyn_none"] = 0] = "dyn_none"; + DynamicType[DynamicType["ad"] = 15] = "ad" + })(DynamicType || (DynamicType = {})); + + class DynAllReply$Type extends MessageType { + constructor() { + super("DynAllReply", [{ + no: 1, + name: "dynamic_list", + kind: "message", + T: () => DynamicList + }, { + no: 2, + name: "up_list", + kind: "message", + T: () => CardVideoUpList + }, {no: 3, name: "topic_list", kind: "message", T: () => TopicList}]) + } + + create(value) { + const message = {}; + globalThis.Object.defineProperty(message, MESSAGE_TYPE, { + enumerable: false, + value: this + }); + if (value !== undefined) reflectionMergePartial(this, message, value); + return message + } + + internalBinaryRead(reader, length, options, target) { + let message = target ?? this.create(), end = reader.pos + length; + while (reader.pos < end) { + let [fieldNo, wireType] = reader.tag(); + switch (fieldNo) { + case 1: + message.dynamicList = DynamicList.internalBinaryRead(reader, reader.uint32(), options, message.dynamicList); + break; + case 2: + message.upList = CardVideoUpList.internalBinaryRead(reader, reader.uint32(), options, message.upList); + break; + case 3: + message.topicList = TopicList.internalBinaryRead(reader, reader.uint32(), options, message.topicList); + break; + default: + let u = options.readUnknownField; + if (u === "throw") throw new globalThis.Error(`Unknown field ${fieldNo}(wire type ${wireType})for ${this.typeName}`); + let d = reader.skip(wireType); + if (u !== false) (u === true ? UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d) + } + } + return message + } + + internalBinaryWrite(message, writer, options) { + if (message.dynamicList) DynamicList.internalBinaryWrite(message.dynamicList, writer.tag(1, WireType.LengthDelimited).fork(), options).join(); + if (message.upList) CardVideoUpList.internalBinaryWrite(message.upList, writer.tag(2, WireType.LengthDelimited).fork(), options).join(); + if (message.topicList) TopicList.internalBinaryWrite(message.topicList, writer.tag(3, WireType.LengthDelimited).fork(), options).join(); + let u = options.writeUnknownFields; + if (u !== false) (u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer); + return writer + } + } + + const DynAllReply = new DynAllReply$Type(); + + class DynVideoReply$Type extends MessageType { + constructor() { + super("DynVideoReply", [{ + no: 2, + name: "video_up_list", + kind: "message", + T: () => CardVideoUpList + }]) + } + + create(value) { + const message = {}; + globalThis.Object.defineProperty(message, MESSAGE_TYPE, { + enumerable: false, + value: this + }); + if (value !== undefined) reflectionMergePartial(this, message, value); + return message + } + + internalBinaryRead(reader, length, options, target) { + let message = target ?? this.create(), end = reader.pos + length; + while (reader.pos < end) { + let [fieldNo, wireType] = reader.tag(); + switch (fieldNo) { + case 2: + message.videoUpList = CardVideoUpList.internalBinaryRead(reader, reader.uint32(), options, message.videoUpList); + break; + default: + let u = options.readUnknownField; + if (u === "throw") throw new globalThis.Error(`Unknown field ${fieldNo}(wire type ${wireType})for ${this.typeName}`); + let d = reader.skip(wireType); + if (u !== false) (u === true ? UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d) + } + } + return message + } + + internalBinaryWrite(message, writer, options) { + if (message.videoUpList) CardVideoUpList.internalBinaryWrite(message.videoUpList, writer.tag(2, WireType.LengthDelimited).fork(), options).join(); + let u = options.writeUnknownFields; + if (u !== false) (u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer); + return writer + } + } + + const DynVideoReply = new DynVideoReply$Type(); + + class DynamicList$Type extends MessageType { + constructor() { + super("DynamicList", [{ + no: 1, + name: "list", + kind: "message", + repeat: 1, + T: () => DynamicItem + }]) + } + + create(value) { + const message = {list: []}; + globalThis.Object.defineProperty(message, MESSAGE_TYPE, { + enumerable: false, + value: this + }); + if (value !== undefined) reflectionMergePartial(this, message, value); + return message + } + + internalBinaryRead(reader, length, options, target) { + let message = target ?? this.create(), end = reader.pos + length; + while (reader.pos < end) { + let [fieldNo, wireType] = reader.tag(); + switch (fieldNo) { + case 1: + message.list.push(DynamicItem.internalBinaryRead(reader, reader.uint32(), options)); + break; + default: + let u = options.readUnknownField; + if (u === "throw") throw new globalThis.Error(`Unknown field ${fieldNo}(wire type ${wireType})for ${this.typeName}`); + let d = reader.skip(wireType); + if (u !== false) (u === true ? UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d) + } + } + return message + } + + internalBinaryWrite(message, writer, options) { + for (let i = 0; i < message.list.length; i++) DynamicItem.internalBinaryWrite(message.list[i], writer.tag(1, WireType.LengthDelimited).fork(), options).join(); + let u = options.writeUnknownFields; + if (u !== false) (u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer); + return writer + } + } + + const DynamicList = new DynamicList$Type(); + + class CardVideoUpList$Type extends MessageType { + constructor() { + super("CardVideoUpList", [{no: 1, name: "title", kind: "scalar", T: 9}]) + } + + create(value) { + const message = {title: ""}; + globalThis.Object.defineProperty(message, MESSAGE_TYPE, { + enumerable: false, + value: this + }); + if (value !== undefined) reflectionMergePartial(this, message, value); + return message + } + + internalBinaryRead(reader, length, options, target) { + let message = target ?? this.create(), end = reader.pos + length; + while (reader.pos < end) { + let [fieldNo, wireType] = reader.tag(); + switch (fieldNo) { + case 1: + message.title = reader.string(); + break; + default: + let u = options.readUnknownField; + if (u === "throw") throw new globalThis.Error(`Unknown field ${fieldNo}(wire type ${wireType})for ${this.typeName}`); + let d = reader.skip(wireType); + if (u !== false) (u === true ? UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d) + } + } + return message + } + + internalBinaryWrite(message, writer, options) { + if (message.title !== "") writer.tag(1, WireType.LengthDelimited).string(message.title); + let u = options.writeUnknownFields; + if (u !== false) (u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer); + return writer + } + } + + const CardVideoUpList = new CardVideoUpList$Type(); + + class TopicList$Type extends MessageType { + constructor() { + super("TopicList", [{no: 1, name: "title", kind: "scalar", T: 9}]) + } + + create(value) { + const message = {title: ""}; + globalThis.Object.defineProperty(message, MESSAGE_TYPE, { + enumerable: false, + value: this + }); + if (value !== undefined) reflectionMergePartial(this, message, value); + return message + } + + internalBinaryRead(reader, length, options, target) { + let message = target ?? this.create(), end = reader.pos + length; + while (reader.pos < end) { + let [fieldNo, wireType] = reader.tag(); + switch (fieldNo) { + case 1: + message.title = reader.string(); + break; + default: + let u = options.readUnknownField; + if (u === "throw") throw new globalThis.Error(`Unknown field ${fieldNo}(wire type ${wireType})for ${this.typeName}`); + let d = reader.skip(wireType); + if (u !== false) (u === true ? UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d) + } + } + return message + } + + internalBinaryWrite(message, writer, options) { + if (message.title !== "") writer.tag(1, WireType.LengthDelimited).string(message.title); + let u = options.writeUnknownFields; + if (u !== false) (u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer); + return writer + } + } + + const TopicList = new TopicList$Type(); + + class DynamicItem$Type extends MessageType { + constructor() { + super("DynamicItem", [{ + no: 1, + name: "card_type", + kind: "enum", + T: () => ["DynamicType", DynamicType] + }]) + } + + create(value) { + const message = {cardType: 0}; + globalThis.Object.defineProperty(message, MESSAGE_TYPE, { + enumerable: false, + value: this + }); + if (value !== undefined) reflectionMergePartial(this, message, value); + return message + } + + internalBinaryRead(reader, length, options, target) { + let message = target ?? this.create(), end = reader.pos + length; + while (reader.pos < end) { + let [fieldNo, wireType] = reader.tag(); + switch (fieldNo) { + case 1: + message.cardType = reader.int32(); + break; + default: + let u = options.readUnknownField; + if (u === "throw") throw new globalThis.Error(`Unknown field ${fieldNo}(wire type ${wireType})for ${this.typeName}`); + let d = reader.skip(wireType); + if (u !== false) (u === true ? UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d) + } + } + return message + } + + internalBinaryWrite(message, writer, options) { + if (message.cardType !== 0) writer.tag(1, WireType.Varint).int32(message.cardType); + let u = options.writeUnknownFields; + if (u !== false) (u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer); + return writer + } + } + + const DynamicItem = new DynamicItem$Type(); + /****************** initialization finish ******************/ + switch (PATHs?.[1]) { + case "DynAll": // 动态综合页 + data = DynAllReply.fromBinary(body); + switch (Settings?.Detail?.Hot_topics) { + case true: + default: + if (data.topicList) { + data.topicList = null; + $.log(`🎉 ${$.name}`, "动态综合页热门话题去除"); + } + break; + case false: + $.log(`🚧 ${$.name}`, "用户设置动态综合页热门话题不去除"); + break; + } + switch (Settings?.Detail?.Most_visited) { + case true: + default: + if (data.upList) { + data.upList = null; + $.log(`🎉 ${$.name}`, "动态综合页最常访问去除"); + } + break; + case false: + $.log(`🚧 ${$.name}`, "用户设置动态综合页最常访问不去除"); + break; + } + switch (Settings?.Detail?.Dynamic_adcard) { + case true: + default: + if (data.dynamicList?.list?.length) { + data.dynamicList.list = data.dynamicList.list.filter( + (item) => { + if (item.cardType !== 15) { + return true; + } + $.log(`🎉 ${$.name}`, "动态综合页广告动态去除"); + return false; + } + ); + } + break; + case false: + $.log(`🚧 ${$.name}`, "用户设置动态综合页广告动态不去除"); + break; + } + body = DynAllReply.toBinary(data); + break; + case "DynVideo": // 动态视频页 + data = DynVideoReply.fromBinary(body); + switch (Settings?.Detail?.Most_visited) { + case true: + default: + if (data.videoUpList) { + data.videoUpList = null; + $.log(`🎉 ${$.name}`, "动态视频页最常访问去除"); + } + break; + case false: + $.log(`🚧 ${$.name}`, "用户设置动态视频页最常访问不去除"); + break; + } + body = DynVideoReply.toBinary(data); + break; + } + break; + case "bilibili.app.view.v1.View": // 视频 + switch (PATHs?.[1]) { + case "View": // 视频播放页 + /****************** initialization start *******************/ + // protobuf/bilibili/app/view/view.proto + class ViewReply$Type extends MessageType { + constructor() { + super("ViewReply", [{ + no: 6, + name: "t_icon", + kind: "map", + K: 9, + V: {kind: "message", T: () => TIcon} + }, { + no: 10, + name: "relates", + kind: "message", + repeat: 1, + T: () => Relate + }, { + no: 30, + name: "cms", + kind: "message", + repeat: 1, + T: () => CM + }, { + no: 31, + name: "cm_config", + kind: "message", + T: () => CMConfig + }, {no: 41, name: "cm_ipad", kind: "message", T: () => CmIpad}]) + } + + create(value) { + const message = {tIcon: {}, relates: [], cms: []}; + globalThis.Object.defineProperty(message, MESSAGE_TYPE, { + enumerable: false, + value: this + }); + if (value !== undefined) reflectionMergePartial(this, message, value); + return message + } + + internalBinaryRead(reader, length, options, target) { + let message = target ?? this.create(), + end = reader.pos + length; + while (reader.pos < end) { + let [fieldNo, wireType] = reader.tag(); + switch (fieldNo) { + case 6: + this.binaryReadMap6(message.tIcon, reader, options); + break; + case 10: + message.relates.push(Relate.internalBinaryRead(reader, reader.uint32(), options)); + break; + case 30: + message.cms.push(CM.internalBinaryRead(reader, reader.uint32(), options)); + break; + case 31: + message.cmConfig = CMConfig.internalBinaryRead(reader, reader.uint32(), options, message.cmConfig); + break; + case 41: + message.cmIpad = CmIpad.internalBinaryRead(reader, reader.uint32(), options, message.cmIpad); + break; + default: + let u = options.readUnknownField; + if (u === "throw") throw new globalThis.Error(`Unknown field ${fieldNo}(wire type ${wireType})for ${this.typeName}`); + let d = reader.skip(wireType); + if (u !== false) (u === true ? UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d) + } + } + return message + } + + binaryReadMap6(map, reader, options) { + let len = reader.uint32(), end = reader.pos + len, key, val; + while (reader.pos < end) { + let [fieldNo, wireType] = reader.tag(); + switch (fieldNo) { + case 1: + key = reader.string(); + break; + case 2: + val = TIcon.internalBinaryRead(reader, reader.uint32(), options); + break; + default: + throw new globalThis.Error("unknown map entry field for field ViewReply.t_icon"); + } + } + map[key ?? ""] = val ?? TIcon.create() + } + + internalBinaryWrite(message, writer, options) { + for (let k of Object.keys(message.tIcon)) { + writer.tag(6, WireType.LengthDelimited).fork().tag(1, WireType.LengthDelimited).string(k); + writer.tag(2, WireType.LengthDelimited).fork(); + TIcon.internalBinaryWrite(message.tIcon[k], writer, options); + writer.join().join() + } + for (let i = 0; i < message.relates.length; i++) Relate.internalBinaryWrite(message.relates[i], writer.tag(10, WireType.LengthDelimited).fork(), options).join(); + for (let i = 0; i < message.cms.length; i++) CM.internalBinaryWrite(message.cms[i], writer.tag(30, WireType.LengthDelimited).fork(), options).join(); + if (message.cmConfig) CMConfig.internalBinaryWrite(message.cmConfig, writer.tag(31, WireType.LengthDelimited).fork(), options).join(); + if (message.cmIpad) CmIpad.internalBinaryWrite(message.cmIpad, writer.tag(41, WireType.LengthDelimited).fork(), options).join(); + let u = options.writeUnknownFields; + if (u !== false) (u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer); + return writer + } + } + + const ViewReply = new ViewReply$Type(); + + class CMConfig$Type extends MessageType { + constructor() { + super("CMConfig", [{ + no: 1, + name: "ads_control", + kind: "message", + T: () => Any + }]) + } + + create(value) { + const message = {}; + globalThis.Object.defineProperty(message, MESSAGE_TYPE, { + enumerable: false, + value: this + }); + if (value !== undefined) reflectionMergePartial(this, message, value); + return message + } + + internalBinaryRead(reader, length, options, target) { + let message = target ?? this.create(), + end = reader.pos + length; + while (reader.pos < end) { + let [fieldNo, wireType] = reader.tag(); + switch (fieldNo) { + case 1: + message.adsControl = Any.internalBinaryRead(reader, reader.uint32(), options, message.adsControl); + break; + default: + let u = options.readUnknownField; + if (u === "throw") throw new globalThis.Error(`Unknown field ${fieldNo}(wire type ${wireType})for ${this.typeName}`); + let d = reader.skip(wireType); + if (u !== false) (u === true ? UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d) + } + } + return message + } + + internalBinaryWrite(message, writer, options) { + if (message.adsControl) Any.internalBinaryWrite(message.adsControl, writer.tag(1, WireType.LengthDelimited).fork(), options).join(); + let u = options.writeUnknownFields; + if (u !== false) (u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer); + return writer + } + } + + const CMConfig = new CMConfig$Type(); + + class CmIpad$Type extends MessageType { + constructor() { + super("CmIpad", [{ + no: 5, + name: "aid", + kind: "scalar", + T: 3, + L: 0 + }]) + } + + create(value) { + const message = {aid: 0n}; + globalThis.Object.defineProperty(message, MESSAGE_TYPE, { + enumerable: false, + value: this + }); + if (value !== undefined) reflectionMergePartial(this, message, value); + return message + } + + internalBinaryRead(reader, length, options, target) { + let message = target ?? this.create(), + end = reader.pos + length; + while (reader.pos < end) { + let [fieldNo, wireType] = reader.tag(); + switch (fieldNo) { + case 5: + message.aid = reader.int64().toBigInt(); + break; + default: + let u = options.readUnknownField; + if (u === "throw") throw new globalThis.Error(`Unknown field ${fieldNo}(wire type ${wireType})for ${this.typeName}`); + let d = reader.skip(wireType); + if (u !== false) (u === true ? UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d) + } + } + return message + } + + internalBinaryWrite(message, writer, options) { + if (message.aid !== 0n) writer.tag(5, WireType.Varint).int64(message.aid); + let u = options.writeUnknownFields; + if (u !== false) (u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer); + return writer + } + } + + const CmIpad = new CmIpad$Type(); + + class TIcon$Type extends MessageType { + constructor() { + super("TIcon", [{no: 1, name: "icon", kind: "scalar", T: 9}]) + } + + create(value) { + const message = {icon: ""}; + globalThis.Object.defineProperty(message, MESSAGE_TYPE, { + enumerable: false, + value: this + }); + if (value !== undefined) reflectionMergePartial(this, message, value); + return message + } + + internalBinaryRead(reader, length, options, target) { + let message = target ?? this.create(), + end = reader.pos + length; + while (reader.pos < end) { + let [fieldNo, wireType] = reader.tag(); + switch (fieldNo) { + case 1: + message.icon = reader.string(); + break; + default: + let u = options.readUnknownField; + if (u === "throw") throw new globalThis.Error(`Unknown field ${fieldNo}(wire type ${wireType})for ${this.typeName}`); + let d = reader.skip(wireType); + if (u !== false) (u === true ? UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d) + } + } + return message + } + + internalBinaryWrite(message, writer, options) { + if (message.icon !== "") writer.tag(1, WireType.LengthDelimited).string(message.icon); + let u = options.writeUnknownFields; + if (u !== false) (u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer); + return writer + } + } + + const TIcon = new TIcon$Type(); + + class Relate$Type extends MessageType { + constructor() { + super("Relate", [{ + no: 28, + name: "cm", + kind: "message", + T: () => CM + }]) + } + + create(value) { + const message = {}; + globalThis.Object.defineProperty(message, MESSAGE_TYPE, { + enumerable: false, + value: this + }); + if (value !== undefined) reflectionMergePartial(this, message, value); + return message + } + + internalBinaryRead(reader, length, options, target) { + let message = target ?? this.create(), + end = reader.pos + length; + while (reader.pos < end) { + let [fieldNo, wireType] = reader.tag(); + switch (fieldNo) { + case 28: + message.cm = CM.internalBinaryRead(reader, reader.uint32(), options, message.cm); + break; + default: + let u = options.readUnknownField; + if (u === "throw") throw new globalThis.Error(`Unknown field ${fieldNo}(wire type ${wireType})for ${this.typeName}`); + let d = reader.skip(wireType); + if (u !== false) (u === true ? UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d) + } + } + return message + } + + internalBinaryWrite(message, writer, options) { + if (message.cm) CM.internalBinaryWrite(message.cm, writer.tag(28, WireType.LengthDelimited).fork(), options).join(); + let u = options.writeUnknownFields; + if (u !== false) (u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer); + return writer + } + } + + const Relate = new Relate$Type(); + /****************** initialization finish ******************/ + switch (Settings?.Detail?.view) { + case true: + default: + let data = ViewReply.fromBinary(body); + if (data.cms?.length) { + data.cms = []; + $.log(`🎉 ${$.name}`, "播放页广告卡片去除"); + } + if (data.relates?.length) { + data.relates = data.relates.filter((item) => { + if (item.cm) { + $.log(`🎉 ${$.name}`, "播放页关联推荐广告去除"); + return false; + } + return true; + }); + } + if (data.cmConfig || data.cmIpad) { + delete data.cmConfig; + delete data.cmIpad; + $.log(`🎉 ${$.name}`, "播放页定制tab去除"); + } + for (const i in data.tIcon) { + if (data.tIcon[i] === null) { + // 解决tIcon的null is not an object问题 + // console.log(`tIconMap:${i}`); + delete data.tIcon[i]; + } + } + body = ViewReply.toBinary(data); + break; + case false: + $.log(`🚧 ${$.name}`, "用户设置播放页广告不去除"); + break; + } + ; + break; + case "TFInfo": + + /****************** initialization start *******************/ + // protobuf/bilibili/app/view/view.proto + class TFInfoReply$Type extends MessageType { + constructor() { + super("TFInfoReply", [{ + no: 1, + name: "tipsId", + kind: "scalar", + T: 3, + L: 0 + }, { + no: 2, + name: "tfToast", + kind: "message", + T: () => TFToast + }, { + no: 3, + name: "tfPanelCustomized", + kind: "message", + T: () => TFPanelCustomized + }]) + } + + create(value) { + const message = {tipsId: 0n}; + globalThis.Object.defineProperty(message, MESSAGE_TYPE, { + enumerable: false, + value: this + }); + if (value !== undefined) reflectionMergePartial(this, message, value); + return message + } + + internalBinaryRead(reader, length, options, target) { + let message = target ?? this.create(), + end = reader.pos + length; + while (reader.pos < end) { + let [fieldNo, wireType] = reader.tag(); + switch (fieldNo) { + case 1: + message.tipsId = reader.int64().toBigInt(); + break; + case 2: + message.tfToast = TFToast.internalBinaryRead(reader, reader.uint32(), options, message.tfToast); + break; + case 3: + message.tfPanelCustomized = TFPanelCustomized.internalBinaryRead(reader, reader.uint32(), options, message.tfPanelCustomized); + break; + default: + let u = options.readUnknownField; + if (u === "throw") throw new globalThis.Error(`Unknown field ${fieldNo}(wire type ${wireType})for ${this.typeName}`); + let d = reader.skip(wireType); + if (u !== false) (u === true ? UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d) + } + } + return message + } + + internalBinaryWrite(message, writer, options) { + if (message.tipsId !== 0n) writer.tag(1, WireType.Varint).int64(message.tipsId); + if (message.tfToast) TFToast.internalBinaryWrite(message.tfToast, writer.tag(2, WireType.LengthDelimited).fork(), options).join(); + if (message.tfPanelCustomized) TFPanelCustomized.internalBinaryWrite(message.tfPanelCustomized, writer.tag(3, WireType.LengthDelimited).fork(), options).join(); + let u = options.writeUnknownFields; + if (u !== false) (u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer); + return writer + } + } + + const TFInfoReply = new TFInfoReply$Type(); + + class TFToast$Type extends MessageType { + constructor() { + super("TFToast", [{ + no: 1, + name: "btnText", + kind: "scalar", + T: 9 + }]) + } + + create(value) { + const message = {btnText: ""}; + globalThis.Object.defineProperty(message, MESSAGE_TYPE, { + enumerable: false, + value: this + }); + if (value !== undefined) reflectionMergePartial(this, message, value); + return message + } + + internalBinaryRead(reader, length, options, target) { + let message = target ?? this.create(), + end = reader.pos + length; + while (reader.pos < end) { + let [fieldNo, wireType] = reader.tag(); + switch (fieldNo) { + case 1: + message.btnText = reader.string(); + break; + default: + let u = options.readUnknownField; + if (u === "throw") throw new globalThis.Error(`Unknown field ${fieldNo}(wire type ${wireType})for ${this.typeName}`); + let d = reader.skip(wireType); + if (u !== false) (u === true ? UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d) + } + } + return message + } + + internalBinaryWrite(message, writer, options) { + if (message.btnText !== "") writer.tag(1, WireType.LengthDelimited).string(message.btnText); + let u = options.writeUnknownFields; + if (u !== false) (u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer); + return writer + } + } + + const TFToast = new TFToast$Type(); + + class TFPanelCustomized$Type extends MessageType { + constructor() { + super("TFPanelCustomized", [{ + no: 2, + name: "rightBtnText", + kind: "scalar", + T: 9 + }]) + } + + create(value) { + const message = {rightBtnText: ""}; + globalThis.Object.defineProperty(message, MESSAGE_TYPE, { + enumerable: false, + value: this + }); + if (value !== undefined) reflectionMergePartial(this, message, value); + return message + } + + internalBinaryRead(reader, length, options, target) { + let message = target ?? this.create(), + end = reader.pos + length; + while (reader.pos < end) { + let [fieldNo, wireType] = reader.tag(); + switch (fieldNo) { + case 2: + message.rightBtnText = reader.string(); + break; + default: + let u = options.readUnknownField; + if (u === "throw") throw new globalThis.Error(`Unknown field ${fieldNo}(wire type ${wireType})for ${this.typeName}`); + let d = reader.skip(wireType); + if (u !== false) (u === true ? UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d) + } + } + return message + } + + internalBinaryWrite(message, writer, options) { + if (message.rightBtnText !== "") writer.tag(2, WireType.LengthDelimited).string(message.rightBtnText); + let u = options.writeUnknownFields; + if (u !== false) (u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer); + return writer + } + } + + const TFPanelCustomized = new TFPanelCustomized$Type(); + /****************** initialization finish ******************/ + let data = TFInfoReply.fromBinary(body); + $.log(data.tipsId); + if (data?.tipsId) { + delete data.tfToast; + delete data.tfPanelCustomized; + $.log(`🎉 ${$.name}`, "播放页办卡免流广告去除"); + } + body = TFInfoReply.toBinary(data); + break; + } + break; + case "bilibili.app.viewunite.v1.View": // 视频(内测) + switch (PATHs?.[1]) { + case "View": // 视频播放页 + /****************** initialization start *******************/ + // protobuf/bilibili/app/viewunite/viewunite.proto + class ViewReply$Type extends MessageType { + constructor() { + super("bilibili.app.viewunite.v1.ViewReply", [{ + no: 5, + name: "tab", + kind: "message", + T: () => Tab + }, {no: 7, name: "cm", kind: "message", T: () => CM}]) + } + + create(value) { + const message = {}; + globalThis.Object.defineProperty(message, MESSAGE_TYPE, { + enumerable: false, + value: this + }); + if (value !== undefined) reflectionMergePartial(this, message, value); + return message + } + + internalBinaryRead(reader, length, options, target) { + let message = target ?? this.create(), + end = reader.pos + length; + while (reader.pos < end) { + let [fieldNo, wireType] = reader.tag(); + switch (fieldNo) { + case 5: + message.tab = Tab.internalBinaryRead(reader, reader.uint32(), options, message.tab); + break; + case 7: + message.cm = CM.internalBinaryRead(reader, reader.uint32(), options, message.cm); + break; + default: + let u = options.readUnknownField; + if (u === "throw") throw new globalThis.Error(`Unknown field ${fieldNo}(wire type ${wireType})for ${this.typeName}`); + let d = reader.skip(wireType); + if (u !== false) (u === true ? UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d) + } + } + return message + } + + internalBinaryWrite(message, writer, options) { + if (message.tab) Tab.internalBinaryWrite(message.tab, writer.tag(5, WireType.LengthDelimited).fork(), options).join(); + if (message.cm) CM.internalBinaryWrite(message.cm, writer.tag(7, WireType.LengthDelimited).fork(), options).join(); + let u = options.writeUnknownFields; + if (u !== false) (u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer); + return writer + } + } + + const ViewReply = new ViewReply$Type(); + + class Tab$Type extends MessageType { + constructor() { + super("bilibili.app.viewunite.v1.Tab", [{ + no: 1, + name: "tab_module", + kind: "message", + repeat: 1, + T: () => TabModule + }]) + } + + create(value) { + const message = {tabModule: []}; + globalThis.Object.defineProperty(message, MESSAGE_TYPE, { + enumerable: false, + value: this + }); + if (value !== undefined) reflectionMergePartial(this, message, value); + return message + } + + internalBinaryRead(reader, length, options, target) { + let message = target ?? this.create(), + end = reader.pos + length; + while (reader.pos < end) { + let [fieldNo, wireType] = reader.tag(); + switch (fieldNo) { + case 1: + message.tabModule.push(TabModule.internalBinaryRead(reader, reader.uint32(), options)); + break; + default: + let u = options.readUnknownField; + if (u === "throw") throw new globalThis.Error(`Unknown field ${fieldNo}(wire type ${wireType})for ${this.typeName}`); + let d = reader.skip(wireType); + if (u !== false) (u === true ? UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d) + } + } + return message + } + + internalBinaryWrite(message, writer, options) { + for (let i = 0; i < message.tabModule.length; i++) TabModule.internalBinaryWrite(message.tabModule[i], writer.tag(1, WireType.LengthDelimited).fork(), options).join(); + let u = options.writeUnknownFields; + if (u !== false) (u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer); + return writer + } + } + + const Tab = new Tab$Type(); + + class TabModule$Type extends MessageType { + constructor() { + super("bilibili.app.viewunite.v1.TabModule", [{ + no: 2, + name: "introduction", + kind: "message", + oneof: "tab", + T: () => IntroductionTab + }]) + } + + create(value) { + const message = {tab: {oneofKind: undefined}}; + globalThis.Object.defineProperty(message, MESSAGE_TYPE, { + enumerable: false, + value: this + }); + if (value !== undefined) reflectionMergePartial(this, message, value); + return message + } + + internalBinaryRead(reader, length, options, target) { + let message = target ?? this.create(), + end = reader.pos + length; + while (reader.pos < end) { + let [fieldNo, wireType] = reader.tag(); + switch (fieldNo) { + case 2: + message.tab = { + oneofKind: "introduction", + introduction: IntroductionTab.internalBinaryRead(reader, reader.uint32(), options, message.tab.introduction) + }; + break; + default: + let u = options.readUnknownField; + if (u === "throw") throw new globalThis.Error(`Unknown field ${fieldNo}(wire type ${wireType})for ${this.typeName}`); + let d = reader.skip(wireType); + if (u !== false) (u === true ? UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d) + } + } + return message + } + + internalBinaryWrite(message, writer, options) { + if (message.tab.oneofKind === "introduction") IntroductionTab.internalBinaryWrite(message.tab.introduction, writer.tag(2, WireType.LengthDelimited).fork(), options).join(); + let u = options.writeUnknownFields; + if (u !== false) (u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer); + return writer + } + } + + const TabModule = new TabModule$Type(); + + class IntroductionTab$Type extends MessageType { + constructor() { + super("bilibili.app.viewunite.v1.IntroductionTab", [{ + no: 2, + name: "modules", + kind: "message", + repeat: 1, + T: () => Module + }]) + } + + create(value) { + const message = {modules: []}; + globalThis.Object.defineProperty(message, MESSAGE_TYPE, { + enumerable: false, + value: this + }); + if (value !== undefined) reflectionMergePartial(this, message, value); + return message + } + + internalBinaryRead(reader, length, options, target) { + let message = target ?? this.create(), + end = reader.pos + length; + while (reader.pos < end) { + let [fieldNo, wireType] = reader.tag(); + switch (fieldNo) { + case 2: + message.modules.push(Module.internalBinaryRead(reader, reader.uint32(), options)); + break; + default: + let u = options.readUnknownField; + if (u === "throw") throw new globalThis.Error(`Unknown field ${fieldNo}(wire type ${wireType})for ${this.typeName}`); + let d = reader.skip(wireType); + if (u !== false) (u === true ? UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d) + } + } + return message + } + + internalBinaryWrite(message, writer, options) { + for (let i = 0; i < message.modules.length; i++) Module.internalBinaryWrite(message.modules[i], writer.tag(2, WireType.LengthDelimited).fork(), options).join(); + let u = options.writeUnknownFields; + if (u !== false) (u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer); + return writer + } + } + + const IntroductionTab = new IntroductionTab$Type(); + + class Module$Type extends MessageType { + constructor() { + super("bilibili.app.viewunite.v1.Module", [{ + no: 1, + name: "type", + kind: "scalar", + T: 5 + }, { + no: 22, + name: "relates", + kind: "message", + oneof: "data", + T: () => Relates + }]) + } + + create(value) { + const message = {type: 0, data: {oneofKind: undefined}}; + globalThis.Object.defineProperty(message, MESSAGE_TYPE, { + enumerable: false, + value: this + }); + if (value !== undefined) reflectionMergePartial(this, message, value); + return message + } + + internalBinaryRead(reader, length, options, target) { + let message = target ?? this.create(), + end = reader.pos + length; + while (reader.pos < end) { + let [fieldNo, wireType] = reader.tag(); + switch (fieldNo) { + case 1: + message.type = reader.int32(); + break; + case 22: + message.data = { + oneofKind: "relates", + relates: Relates.internalBinaryRead(reader, reader.uint32(), options, message.data.relates) + }; + break; + default: + let u = options.readUnknownField; + if (u === "throw") throw new globalThis.Error(`Unknown field ${fieldNo}(wire type ${wireType})for ${this.typeName}`); + let d = reader.skip(wireType); + if (u !== false) (u === true ? UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d) + } + } + return message + } + + internalBinaryWrite(message, writer, options) { + if (message.type !== 0) writer.tag(1, WireType.Varint).int32(message.type); + if (message.data.oneofKind === "relates") Relates.internalBinaryWrite(message.data.relates, writer.tag(22, WireType.LengthDelimited).fork(), options).join(); + let u = options.writeUnknownFields; + if (u !== false) (u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer); + return writer + } + } + + const Module = new Module$Type(); + + class Relates$Type extends MessageType { + constructor() { + super("bilibili.app.viewunite.v1.Relates", [{ + no: 1, + name: "cards", + kind: "message", + repeat: 1, + T: () => RelateCard + }]) + } + + create(value) { + const message = {cards: []}; + globalThis.Object.defineProperty(message, MESSAGE_TYPE, { + enumerable: false, + value: this + }); + if (value !== undefined) reflectionMergePartial(this, message, value); + return message + } + + internalBinaryRead(reader, length, options, target) { + let message = target ?? this.create(), + end = reader.pos + length; + while (reader.pos < end) { + let [fieldNo, wireType] = reader.tag(); + switch (fieldNo) { + case 1: + message.cards.push(RelateCard.internalBinaryRead(reader, reader.uint32(), options)); + break; + default: + let u = options.readUnknownField; + if (u === "throw") throw new globalThis.Error(`Unknown field ${fieldNo}(wire type ${wireType})for ${this.typeName}`); + let d = reader.skip(wireType); + if (u !== false) (u === true ? UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d) + } + } + return message + } + + internalBinaryWrite(message, writer, options) { + for (let i = 0; i < message.cards.length; i++) RelateCard.internalBinaryWrite(message.cards[i], writer.tag(1, WireType.LengthDelimited).fork(), options).join(); + let u = options.writeUnknownFields; + if (u !== false) (u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer); + return writer + } + } + + const Relates = new Relates$Type(); + + class RelateCard$Type extends MessageType { + constructor() { + super("bilibili.app.viewunite.v1.RelateCard", [{ + no: 1, + name: "relate_card_type", + kind: "scalar", + T: 5 + }]) + } + + create(value) { + const message = {relateCardType: 0}; + globalThis.Object.defineProperty(message, MESSAGE_TYPE, { + enumerable: false, + value: this + }); + if (value !== undefined) reflectionMergePartial(this, message, value); + return message + } + + internalBinaryRead(reader, length, options, target) { + let message = target ?? this.create(), + end = reader.pos + length; + while (reader.pos < end) { + let [fieldNo, wireType] = reader.tag(); + switch (fieldNo) { + case 1: + message.relateCardType = reader.int32(); + break; + default: + let u = options.readUnknownField; + if (u === "throw") throw new globalThis.Error(`Unknown field ${fieldNo}(wire type ${wireType})for ${this.typeName}`); + let d = reader.skip(wireType); + if (u !== false) (u === true ? UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d) + } + } + return message + } + + internalBinaryWrite(message, writer, options) { + if (message.relateCardType !== 0) writer.tag(1, WireType.Varint).int32(message.relateCardType); + let u = options.writeUnknownFields; + if (u !== false) (u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer); + return writer + } + } + + const RelateCard = new RelateCard$Type(); + + class CM$Type extends MessageType { + constructor() { + super("bilibili.app.viewunite.v1.CM", [{ + no: 3, + name: "source_content", + kind: "message", + repeat: 1, + T: () => Any + }]) + } + + create(value) { + const message = {sourceContent: []}; + globalThis.Object.defineProperty(message, MESSAGE_TYPE, { + enumerable: false, + value: this + }); + if (value !== undefined) reflectionMergePartial(this, message, value); + return message + } + + internalBinaryRead(reader, length, options, target) { + let message = target ?? this.create(), + end = reader.pos + length; + while (reader.pos < end) { + let [fieldNo, wireType] = reader.tag(); + switch (fieldNo) { + case 3: + message.sourceContent.push(Any.internalBinaryRead(reader, reader.uint32(), options)); + break; + default: + let u = options.readUnknownField; + if (u === "throw") throw new globalThis.Error(`Unknown field ${fieldNo}(wire type ${wireType})for ${this.typeName}`); + let d = reader.skip(wireType); + if (u !== false) (u === true ? UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d) + } + } + return message + } + + internalBinaryWrite(message, writer, options) { + for (let i = 0; i < message.sourceContent.length; i++) Any.internalBinaryWrite(message.sourceContent[i], writer.tag(3, WireType.LengthDelimited).fork(), options).join(); + let u = options.writeUnknownFields; + if (u !== false) (u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer); + return writer + } + } + + const CM = new CM$Type(); + /****************** initialization finish ******************/ + switch (Settings?.Detail?.view) { + case true: + default: + let data = ViewReply.fromBinary(body); + if (data.cm?.sourceContent?.length) { + data.cm.sourceContent = []; + $.log(`🎉 ${$.name}`, "up主推荐广告去除"); + } + data.tab.tabModule[0].tab.introduction.modules = data.tab.tabModule[0].tab.introduction.modules.map((i) => { + if (i.type === 28) { + i.data.relates.cards = i.data.relates.cards.filter((j) => j.relateCardType !== 5); + $.log(`🎉 ${$.name}`, "视频详情下方推荐卡广告去除"); + } + return i; + } + ); + body = ViewReply.toBinary(data); + break; + case false: + $.log(`🚧 ${$.name}`, "用户设置up主推荐广告不去除"); + break; + } + ; + break; + } + break; + case "bilibili.app.interface.v1.Teenagers": // 青少年模式 + switch (PATHs?.[1]) { + case "ModeStatus": // 青少年模式 + /****************** initialization start *******************/ + // protobuf/bilibili/app/interface/teenagers.proto + class ModeStatus$Type extends MessageType { + constructor() { + super("ModeStatus", [{ + no: 1, + name: "modes", + kind: "message", + repeat: 1, + T: () => Mode + }]) + } + + create(value) { + const message = {modes: []}; + globalThis.Object.defineProperty(message, MESSAGE_TYPE, { + enumerable: false, + value: this + }); + if (value !== undefined) reflectionMergePartial(this, message, value); + return message + } + + internalBinaryRead(reader, length, options, target) { + let message = target ?? this.create(), + end = reader.pos + length; + while (reader.pos < end) { + let [fieldNo, wireType] = reader.tag(); + switch (fieldNo) { + case 1: + message.modes.push(Mode.internalBinaryRead(reader, reader.uint32(), options)); + break; + default: + let u = options.readUnknownField; + if (u === "throw") throw new globalThis.Error(`Unknown field ${fieldNo}(wire type ${wireType})for ${this.typeName}`); + let d = reader.skip(wireType); + if (u !== false) (u === true ? UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d) + } + } + return message + } + + internalBinaryWrite(message, writer, options) { + for (let i = 0; i < message.modes.length; i++) Mode.internalBinaryWrite(message.modes[i], writer.tag(1, WireType.LengthDelimited).fork(), options).join(); + let u = options.writeUnknownFields; + if (u !== false) (u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer); + return writer + } + } + + const ModeStatus = new ModeStatus$Type(); + + class Mode$Type extends MessageType { + constructor() { + super("Mode", [{ + no: 2, + name: "name", + kind: "scalar", + T: 9 + }, {no: 5, name: "f5", kind: "message", T: () => F5}]) + } + + create(value) { + const message = {name: ""}; + globalThis.Object.defineProperty(message, MESSAGE_TYPE, { + enumerable: false, + value: this + }); + if (value !== undefined) reflectionMergePartial(this, message, value); + return message + } + + internalBinaryRead(reader, length, options, target) { + let message = target ?? this.create(), + end = reader.pos + length; + while (reader.pos < end) { + let [fieldNo, wireType] = reader.tag(); + switch (fieldNo) { + case 2: + message.name = reader.string(); + break; + case 5: + message.f5 = F5.internalBinaryRead(reader, reader.uint32(), options, message.f5); + break; + default: + let u = options.readUnknownField; + if (u === "throw") throw new globalThis.Error(`Unknown field ${fieldNo}(wire type ${wireType})for ${this.typeName}`); + let d = reader.skip(wireType); + if (u !== false) (u === true ? UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d) + } + } + return message + } + + internalBinaryWrite(message, writer, options) { + if (message.name !== "") writer.tag(2, WireType.LengthDelimited).string(message.name); + if (message.f5) F5.internalBinaryWrite(message.f5, writer.tag(5, WireType.LengthDelimited).fork(), options).join(); + let u = options.writeUnknownFields; + if (u !== false) (u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer); + return writer + } + } + + const Mode = new Mode$Type(); + + class F5$Type extends MessageType { + constructor() { + super("F5", [{no: 1, name: "f1", kind: "scalar", T: 5}]) + } + + create(value) { + const message = {f1: 0}; + globalThis.Object.defineProperty(message, MESSAGE_TYPE, { + enumerable: false, + value: this + }); + if (value !== undefined) reflectionMergePartial(this, message, value); + return message + } + + internalBinaryRead(reader, length, options, target) { + let message = target ?? this.create(), + end = reader.pos + length; + while (reader.pos < end) { + let [fieldNo, wireType] = reader.tag(); + switch (fieldNo) { + case 1: + message.f1 = reader.int32(); + break; + default: + let u = options.readUnknownField; + if (u === "throw") throw new globalThis.Error(`Unknown field ${fieldNo}(wire type ${wireType})for ${this.typeName}`); + let d = reader.skip(wireType); + if (u !== false) (u === true ? UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d) + } + } + return message + } + + internalBinaryWrite(message, writer, options) { + if (message.f1 !== 0) writer.tag(1, WireType.Varint).int32(message.f1); + let u = options.writeUnknownFields; + if (u !== false) (u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer); + return writer + } + } + + const F5 = new F5$Type(); + data = ModeStatus.fromBinary(body); + /****************** initialization finish ******************/ + data.modes = data.modes.map(mode => { + if (mode?.name === "teenagers") { + if (mode?.f5?.f1) { + mode.f5.f1 = 0; + $.log(`🎉 ${$.name}`, "青少年模式弹窗去除"); + } + } + return mode; + }); + body = ModeStatus.toBinary(data); + break; + } + ; + break; + case "bilibili.community.service.dm.v1.DM": //弹幕 + /****************** initialization start *******************/ + // protobuf/bilibili/community/service/dm/dm.proto + class CommandDm$Type extends MessageType { + constructor() { + super("CommandDm", [{no: 1, name: "id", kind: "scalar", T: 3, L: 0}]) + } + + create(value) { + const message = {id: 0n}; + globalThis.Object.defineProperty(message, MESSAGE_TYPE, { + enumerable: false, + value: this + }); + if (value !== undefined) reflectionMergePartial(this, message, value); + return message + } + + internalBinaryRead(reader, length, options, target) { + let message = target ?? this.create(), end = reader.pos + length; + while (reader.pos < end) { + let [fieldNo, wireType] = reader.tag(); + switch (fieldNo) { + case 1: + message.id = reader.int64().toBigInt(); + break; + default: + let u = options.readUnknownField; + if (u === "throw") throw new globalThis.Error(`Unknown field ${fieldNo}(wire type ${wireType})for ${this.typeName}`); + let d = reader.skip(wireType); + if (u !== false) (u === true ? UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d) + } + } + return message + } + + internalBinaryWrite(message, writer, options) { + if (message.id !== 0n) writer.tag(1, WireType.Varint).int64(message.id); + let u = options.writeUnknownFields; + if (u !== false) (u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer); + return writer + } + } + + const CommandDm = new CommandDm$Type(); + + class DmView$Type extends MessageType { + constructor() { + super("DmView", [{ + no: 1, + name: "commandDms", + kind: "message", + repeat: 1, + T: () => CommandDm + }]) + } + + create(value) { + const message = {commandDms: []}; + globalThis.Object.defineProperty(message, MESSAGE_TYPE, { + enumerable: false, + value: this + }); + if (value !== undefined) reflectionMergePartial(this, message, value); + return message + } + + internalBinaryRead(reader, length, options, target) { + let message = target ?? this.create(), end = reader.pos + length; + while (reader.pos < end) { + let [fieldNo, wireType] = reader.tag(); + switch (fieldNo) { + case 1: + message.commandDms.push(CommandDm.internalBinaryRead(reader, reader.uint32(), options)); + break; + default: + let u = options.readUnknownField; + if (u === "throw") throw new globalThis.Error(`Unknown field ${fieldNo}(wire type ${wireType})for ${this.typeName}`); + let d = reader.skip(wireType); + if (u !== false) (u === true ? UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d) + } + } + return message + } + + internalBinaryWrite(message, writer, options) { + for (let i = 0; i < message.commandDms.length; i++) CommandDm.internalBinaryWrite(message.commandDms[i], writer.tag(1, WireType.LengthDelimited).fork(), options).join(); + let u = options.writeUnknownFields; + if (u !== false) (u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer); + return writer + } + } + + const DmView = new DmView$Type(); + + class DmViewReply$Type extends MessageType { + constructor() { + super("DmViewReply", [{ + no: 22, + name: "dmView", + kind: "message", + T: () => DmView + }]) + } + + create(value) { + const message = {}; + globalThis.Object.defineProperty(message, MESSAGE_TYPE, { + enumerable: false, + value: this + }); + if (value !== undefined) reflectionMergePartial(this, message, value); + return message + } + + internalBinaryRead(reader, length, options, target) { + let message = target ?? this.create(), end = reader.pos + length; + while (reader.pos < end) { + let [fieldNo, wireType] = reader.tag(); + switch (fieldNo) { + case 22: + message.dmView = DmView.internalBinaryRead(reader, reader.uint32(), options, message.dmView); + break; + default: + let u = options.readUnknownField; + if (u === "throw") throw new globalThis.Error(`Unknown field ${fieldNo}(wire type ${wireType})for ${this.typeName}`); + let d = reader.skip(wireType); + if (u !== false) (u === true ? UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d) + } + } + return message + } + + internalBinaryWrite(message, writer, options) { + if (message.dmView) DmView.internalBinaryWrite(message.dmView, writer.tag(22, WireType.LengthDelimited).fork(), options).join(); + let u = options.writeUnknownFields; + if (u !== false) (u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer); + return writer + } + } + + const DmViewReply = new DmViewReply$Type(); + + class DmSegMobileReply$Type extends MessageType { + constructor() { + super("DmSegMobileReply", [{ + no: 1, + name: "elems", + kind: "message", + repeat: 1, + T: () => DanmakuElem + }]) + } + + create(value) { + const message = {elems: []}; + globalThis.Object.defineProperty(message, MESSAGE_TYPE, { + enumerable: false, + value: this + }); + if (value !== undefined) reflectionMergePartial(this, message, value); + return message + } + + internalBinaryRead(reader, length, options, target) { + let message = target ?? this.create(), end = reader.pos + length; + while (reader.pos < end) { + let [fieldNo, wireType] = reader.tag(); + switch (fieldNo) { + case 1: + message.elems.push(DanmakuElem.internalBinaryRead(reader, reader.uint32(), options)); + break; + default: + let u = options.readUnknownField; + if (u === "throw") throw new globalThis.Error(`Unknown field ${fieldNo}(wire type ${wireType})for ${this.typeName}`); + let d = reader.skip(wireType); + if (u !== false) (u === true ? UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d) + } + } + return message + } + + internalBinaryWrite(message, writer, options) { + for (let i = 0; i < message.elems.length; i++) DanmakuElem.internalBinaryWrite(message.elems[i], writer.tag(1, WireType.LengthDelimited).fork(), options).join(); + let u = options.writeUnknownFields; + if (u !== false) (u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer); + return writer + } + } + + const DmSegMobileReply = new DmSegMobileReply$Type(); + + class DanmakuElem$Type extends MessageType { + constructor() { + super("DanmakuElem", [{no: 24, name: "colorful", kind: "scalar", T: 5}]) + } + + create(value) { + const message = {colorful: 0}; + globalThis.Object.defineProperty(message, MESSAGE_TYPE, { + enumerable: false, + value: this + }); + if (value !== undefined) reflectionMergePartial(this, message, value); + return message + } + + internalBinaryRead(reader, length, options, target) { + let message = target ?? this.create(), end = reader.pos + length; + while (reader.pos < end) { + let [fieldNo, wireType] = reader.tag(); + switch (fieldNo) { + case 24: + message.colorful = reader.int32(); + break; + default: + let u = options.readUnknownField; + if (u === "throw") throw new globalThis.Error(`Unknown field ${fieldNo}(wire type ${wireType})for ${this.typeName}`); + let d = reader.skip(wireType); + if (u !== false) (u === true ? UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d) + } + } + return message + } + + internalBinaryWrite(message, writer, options) { + if (message.colorful !== 0) writer.tag(24, WireType.Varint).int32(message.colorful); + let u = options.writeUnknownFields; + if (u !== false) (u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer); + return writer + } + } + + const DanmakuElem = new DanmakuElem$Type(); + /****************** initialization finish ******************/ + switch (PATHs?.[1]) { + case "DmView": // 弹幕配置 + switch (Settings?.Detail?.commandDms) { + case true: + let data = DmViewReply.fromBinary(body); + if (data.dmView?.commandDms?.length) { + data.dmView.commandDms.length = 0; + $.log(`🎉 ${$.name}`, "交互式弹幕去除"); + } + body = DmViewReply.toBinary(data); + break; + case false: + default: + $.log(`🎉 ${$.name}`, "用户设置交互式弹幕不去除"); + break; + } + break; + case "DmSegMobile": // 弹幕列表 + switch (Settings?.Detail?.colorfulDms) { + case true: + let data = DmSegMobileReply.fromBinary(body); + data.elems = data.elems.map(ele => { + if (ele?.colorful === 60001) { + ele.colorful = 0; + } + return ele; + }); + $.log(`🎉 ${$.name}`, "会员弹幕已替换为普通弹幕"); + body = DmSegMobileReply.toBinary(data); + break; + case false: + default: + $.log(`🎉 ${$.name}`, "用户设置会员弹幕不修改"); + break; + } + break; + } + break; + case "bilibili.main.community.reply.v1.Reply": //评论区 + switch (PATHs?.[1]) { + case "MainList": + + /****************** initialization start *******************/ + // protobuf/bilibili/main/community/reply/reply.proto + class MainListReply$Type extends MessageType { + constructor() { + super("MainListReply", [{ + no: 11, + name: "cm", + kind: "message", + T: () => CM + }]) + } + + create(value) { + const message = {}; + globalThis.Object.defineProperty(message, MESSAGE_TYPE, { + enumerable: false, + value: this + }); + if (value !== undefined) reflectionMergePartial(this, message, value); + return message + } + + internalBinaryRead(reader, length, options, target) { + let message = target ?? this.create(), + end = reader.pos + length; + while (reader.pos < end) { + let [fieldNo, wireType] = reader.tag(); + switch (fieldNo) { + case 11: + message.cm = CM.internalBinaryRead(reader, reader.uint32(), options, message.cm); + break; + default: + let u = options.readUnknownField; + if (u === "throw") throw new globalThis.Error(`Unknown field ${fieldNo}(wire type ${wireType})for ${this.typeName}`); + let d = reader.skip(wireType); + if (u !== false) (u === true ? UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d) + } + } + return message + } + + internalBinaryWrite(message, writer, options) { + if (message.cm) CM.internalBinaryWrite(message.cm, writer.tag(11, WireType.LengthDelimited).fork(), options).join(); + let u = options.writeUnknownFields; + if (u !== false) (u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer); + return writer + } + } + + const MainListReply = new MainListReply$Type(); + /****************** initialization finish ******************/ + switch (Settings?.Detail?.MainList) { + case true: + default: + let data = MainListReply.fromBinary(body); + delete data.cm; + body = MainListReply.toBinary(data); + $.log(`🎉 ${$.name}`, "评论列表广告去除"); + break; + case false: + $.log(`🎉 ${$.name}`, "用户设置评论列表广告不去除"); + break; + } + ; + break; + } + ; + break; + case "bilibili.pgc.gateway.player.v2.PlayURL": // 番剧 + /****************** initialization start *******************/ + /****************** initialization finish *******************/ + switch (PATHs?.[1]) { + case "PlayView": // 播放地址 + /****************** initialization start *******************/ + /****************** initialization finish *******************/ + break; + case "PlayConf": // 播放配置 + break; + } + ; + break; + case "bilibili.app.nativeact.v1.NativeAct": // 活动-节目、动画、韩综(港澳台) + switch (PATHs?.[1]) { + case "Index": // 首页 + break; + } + ; + break; + case "bilibili.app.interface.v1.Search": // 搜索框 + switch (PATHs?.[1]) { + case "Suggest3": // 搜索建议 + break; + } + ; + break; + case "bilibili.polymer.app.search.v1.Search": // 搜索结果 + /****************** initialization start *******************/ + /****************** initialization finish *******************/ + switch (PATHs?.[1]) { + case "SearchAll": { // 全部结果(综合) + /****************** initialization start *******************/ + class SearchAllResponse$Type extends MessageType { + constructor() { + super("SearchAllResponse", [{ + no: 4, + name: "item", + kind: "message", + repeat: 1, + T: () => Item + }]) + } + + create(value) { + const message = {item: []}; + globalThis.Object.defineProperty(message, MESSAGE_TYPE, { + enumerable: false, + value: this + }); + if (value !== undefined) reflectionMergePartial(this, message, value); + return message + } + + internalBinaryRead(reader, length, options, target) { + let message = target ?? this.create(), + end = reader.pos + length; + while (reader.pos < end) { + let [fieldNo, wireType] = reader.tag(); + switch (fieldNo) { + case 4: + message.item.push(Item.internalBinaryRead(reader, reader.uint32(), options)); + break; + default: + let u = options.readUnknownField; + if (u === "throw") throw new globalThis.Error(`Unknown field ${fieldNo}(wire type ${wireType})for ${this.typeName}`); + let d = reader.skip(wireType); + if (u !== false) (u === true ? UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d) + } + } + return message + } + + internalBinaryWrite(message, writer, options) { + for (let i = 0; i < message.item.length; i++) Item.internalBinaryWrite(message.item[i], writer.tag(4, WireType.LengthDelimited).fork(), options).join(); + let u = options.writeUnknownFields; + if (u !== false) (u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer); + return writer + } + } + + const SearchAllResponse = new SearchAllResponse$Type(); + + class Item$Type extends MessageType { + constructor() { + super("Item", [{ + no: 25, + name: "cm", + kind: "message", + oneof: "cardItem", + T: () => SearchAdCard + }]) + } + + create(value) { + const message = {cardItem: {oneofKind: undefined}}; + globalThis.Object.defineProperty(message, MESSAGE_TYPE, { + enumerable: false, + value: this + }); + if (value !== undefined) reflectionMergePartial(this, message, value); + return message + } + + internalBinaryRead(reader, length, options, target) { + let message = target ?? this.create(), + end = reader.pos + length; + while (reader.pos < end) { + let [fieldNo, wireType] = reader.tag(); + switch (fieldNo) { + case 25: + message.cardItem = { + oneofKind: "cm", + cm: SearchAdCard.internalBinaryRead(reader, reader.uint32(), options, message.cardItem.cm) + }; + break; + default: + let u = options.readUnknownField; + if (u === "throw") throw new globalThis.Error(`Unknown field ${fieldNo}(wire type ${wireType})for ${this.typeName}`); + let d = reader.skip(wireType); + if (u !== false) (u === true ? UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d) + } + } + return message + } + + internalBinaryWrite(message, writer, options) { + if (message.cardItem.oneofKind === "cm") SearchAdCard.internalBinaryWrite(message.cardItem.cm, writer.tag(25, WireType.LengthDelimited).fork(), options).join(); + let u = options.writeUnknownFields; + if (u !== false) (u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer); + return writer + } + } + + const Item = new Item$Type(); + + class SearchAdCard$Type extends MessageType { + constructor() { + super("SearchAdCard", [{ + no: 1, + name: "json_str", + kind: "scalar", + T: 9 + }]) + } + + create(value) { + const message = {jsonStr: ""}; + globalThis.Object.defineProperty(message, MESSAGE_TYPE, { + enumerable: false, + value: this + }); + if (value !== undefined) reflectionMergePartial(this, message, value); + return message + } + + internalBinaryRead(reader, length, options, target) { + let message = target ?? this.create(), + end = reader.pos + length; + while (reader.pos < end) { + let [fieldNo, wireType] = reader.tag(); + switch (fieldNo) { + case 1: + message.jsonStr = reader.string(); + break; + default: + let u = options.readUnknownField; + if (u === "throw") throw new globalThis.Error(`Unknown field ${fieldNo}(wire type ${wireType})for ${this.typeName}`); + let d = reader.skip(wireType); + if (u !== false) (u === true ? UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d) + } + } + return message + } + + internalBinaryWrite(message, writer, options) { + if (message.jsonStr !== "") writer.tag(1, WireType.LengthDelimited).string(message.jsonStr); + let u = options.writeUnknownFields; + if (u !== false) (u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer); + return writer + } + } + + const SearchAdCard = new SearchAdCard$Type(); + /****************** initialization finish *******************/ + switch (Settings?.Detail?.search) { + case true: + default: + let data = SearchAllResponse.fromBinary(body); + data.item = data.item.filter((i) => !(i.cardItem?.oneofKind === "cm")); + $.log(`🎉 ${$.name}`, "搜索页广告去除"); + body = SearchAllResponse.toBinary(data); + break; + case false: + $.log(`🚧 ${$.name}`, "用户设置搜索页广告不去除"); + break; + } + break; + } + ; + case "SearchByType": { // 分类结果(番剧、用户、影视、专栏) + break; + } + ; + } + ; + break; + } + ; + break; } - } - const SearchAdCard = new SearchAdCard$Type(); - /****************** initialization finish *******************/ - switch (Settings?.Detail?.search) { - case true: - default: - let data = SearchAllResponse.fromBinary(body); - data.item = data.item.filter( - (i) => !(i.cardItem?.oneofKind === 'cm') - ); - $.log(`🎉 ${$.name}`, '搜索页广告去除'); - body = SearchAllResponse.toBinary(data); - break; - case false: - $.log(`🚧 ${$.name}`, '用户设置搜索页广告不去除'); - break; - } - break; - } - case 'SearchByType': { - // 分类结果(番剧、用户、影视、专栏) - break; - } - } - break; - } - break; - } - // protobuf部分处理完后,重新计算并添加B站gRPC校验头 - rawBody = newRawBody({ header, body }); // gzip压缩有问题,别用 - break; - } - // 写入二进制数据 - if ($.isQuanX()) $response.bodyBytes = rawBody; - else $response.body = rawBody; - break; - } - break; - case false: - break; - } -})() - .catch((e) => $.logErr(e)) - .finally(() => { - switch ($response) { - default: { - // 有回复数据,返回回复数据 - const FORMAT = ( - $response?.headers?.['Content-Type'] ?? - $response?.headers?.['content-type'] - )?.split(';')?.[0]; - $.log(`🎉 ${$.name}, finally`, `$response`, `FORMAT: ${FORMAT}`, ''); - //$.log(`🚧 ${$.name}, finally`, `$response: ${JSON.stringify($response)}`, ""); - if ($response?.headers?.['Content-Encoding']) - $response.headers['Content-Encoding'] = 'identity'; - if ($response?.headers?.['content-encoding']) - $response.headers['content-encoding'] = 'identity'; - if ($.isQuanX()) { - switch (FORMAT) { - case undefined: // 视为无body - // 返回普通数据 - $.done({ headers: $response.headers }); - break; - case 'application/x-www-form-urlencoded': - case 'text/plain': - case 'text/html': - case 'text/xml': - case 'text/plist': - case 'application/xml': - case 'application/plist': - case 'application/x-plist': - case 'text/json': - case 'application/json': - default: - // 返回普通数据 - $.done({ headers: $response.headers, body: $response.body }); - break; - case 'application/x-protobuf': - case 'application/grpc': - case 'application/grpc+proto': - case 'applecation/octet-stream': - // 返回二进制数据 - //$.log(`${$response.bodyBytes.byteLength}---${$response.bodyBytes.buffer.byteLength}`); - $.done({ - headers: $response.headers, - bodyBytes: $response.bodyBytes.buffer.slice( - $response.bodyBytes.byteOffset, - $response.bodyBytes.byteLength + - $response.bodyBytes.byteOffset - ), - }); - break; - } - } else $.done($response); - break; - } - case undefined: { - // 无回复数据 - break; - } + ; + // protobuf部分处理完后,重新计算并添加B站gRPC校验头 + rawBody = newRawBody({header, body}); // gzip压缩有问题,别用 + break; + } + ; + // 写入二进制数据 + if ($.isQuanX()) $response.bodyBytes = rawBody + else $response.body = rawBody; + break; + } + ; + break; + case false: + break; } - }); + ; +})() + .catch((e) => $.logErr(e)) + .finally(() => { + switch ($response) { + default: { // 有回复数据,返回回复数据 + const FORMAT = ($response?.headers?.["Content-Type"] ?? $response?.headers?.["content-type"])?.split(";")?.[0]; + $.log(`🎉 ${$.name}, finally`, `$response`, `FORMAT: ${FORMAT}`, ""); + //$.log(`🚧 ${$.name}, finally`, `$response: ${JSON.stringify($response)}`, ""); + if ($response?.headers?.["Content-Encoding"]) $response.headers["Content-Encoding"] = "identity"; + if ($response?.headers?.["content-encoding"]) $response.headers["content-encoding"] = "identity"; + if ($.isQuanX()) { + switch (FORMAT) { + case undefined: // 视为无body + // 返回普通数据 + $.done({headers: $response.headers}); + break; + default: + // 返回普通数据 + $.done({headers: $response.headers, body: $response.body}); + break; + case "application/x-protobuf": + case "application/grpc": + case "application/grpc+proto": + case "applecation/octet-stream": + // 返回二进制数据 + //$.log(`${$response.bodyBytes.byteLength}---${$response.bodyBytes.buffer.byteLength}`); + $.done({ + headers: $response.headers, + bodyBytes: $response.bodyBytes.buffer.slice($response.bodyBytes.byteOffset, $response.bodyBytes.byteLength + $response.bodyBytes.byteOffset) + }); + break; + } + ; + } else $.done($response); + break; + } + ; + case undefined: { // 无回复数据 + break; + } + ; + } + ; + }) /***************** Function *****************/ /** * Set Environment Variables * @author VirgilClyne * @param {String} name - Persistent Store Key - * @param {String} platform - Platform Name + * @param {Array} platforms - Platform Names * @param {Object} database - Default DataBase * @return {Object} { Settings, Caches, Configs } */ -function setENV(name, platform, database) { - //$.log(`☑️ ${$.name}, Set Environment Variables`, ""); - let { Settings, Caches, Configs } = getENV(name, platform, database); - /***************** Prase *****************/ - traverseObject(Settings, (key, value) => { - if (value === 'true' || value === 'false') - value = JSON.parse(value); // 字符串转Boolean - else if (typeof value === 'string') { - if (value?.includes(',')) value = value.split(','); // 字符串转数组 - else if (!isNaN(value)) value = parseInt(value, 10); // 字符串转数字 - } - return value; - }); - $.log( - `✅ ${$.name}, Set Environment Variables`, - `Settings: ${typeof Settings}`, - `Settings内容: ${JSON.stringify(Settings)}`, - '' - ); - /***************** Caches *****************/ - //$.log(`✅ ${$.name}, Set Environment Variables`, `Caches: ${typeof Caches}`, `Caches内容: ${JSON.stringify(Caches)}`, ""); - /***************** Configs *****************/ - return { Settings, Caches, Configs }; - - function traverseObject(o, c) { - for (var t in o) { - var n = o[t]; - o[t] = - 'object' == typeof n && null !== n ? traverseObject(n, c) : c(t, n); - } - return o; - } -} +function setENV(name, platforms, database) { + $.log(`☑️ ${$.name}, Set Environment Variables`, ""); + let {Settings, Caches, Configs} = getENV(name, platforms, database); + /***************** Settings *****************/ + $.log(`✅ ${$.name}, Set Environment Variables`, `Settings: ${typeof Settings}`, `Settings内容: ${JSON.stringify(Settings)}`, ""); + /***************** Caches *****************/ + //$.log(`✅ ${$.name}, Set Environment Variables`, `Caches: ${typeof Caches}`, `Caches内容: ${JSON.stringify(Caches)}`, ""); + /***************** Configs *****************/ + return {Settings, Caches, Configs}; +}; /** * Create New Raw Body @@ -10268,111 +6299,499 @@ function setENV(name, platform, database) { * @param {String} type - encoding type * @return {ArrayBuffer} new raw Body with Checksum Header */ -function newRawBody({ header, body }, encoding = undefined) { - //$.log(`⚠ ${$.name}, Create New Raw Body`, ""); - // Header: 1位:是否校验数据 (0或者1) + 4位:校验值(数据长度) - const flag = - encoding == 'gzip' - ? 1 - : encoding == 'identity' - ? 0 - : encoding == undefined - ? 0 - : header?.[0] ?? 0; // encoding flag - const checksum = Checksum(body.length); // 校验值为未压缩情况下的数据长度, 不是压缩后的长度 - if (encoding == 'gzip') body = pako.gzip(body); // gzip压缩(有问题,别压) - let rawBody = new Uint8Array(header.length + body.length); - rawBody.set([flag], 0); // 0位:Encoding类型,当为1的时候, app会校验1-4位的校验值是否正确 - rawBody.set(checksum, 1); // 1-4位: 校验值(4位) - rawBody.set(body, 5); // 5-end位:protobuf数据 - //$.log(`🎉 ${$.name}, Create New Raw Body`, ""); - return rawBody; +function newRawBody({header, body}, encoding = undefined) { + //$.log(`⚠ ${$.name}, Create New Raw Body`, ""); + // Header: 1位:是否校验数据 (0或者1) + 4位:校验值(数据长度) + const flag = (encoding == "gzip") ? 1 : (encoding == "identity") ? 0 : (encoding == undefined) ? 0 : header?.[0] ?? 0; // encoding flag + const checksum = Checksum(body.length); // 校验值为未压缩情况下的数据长度, 不是压缩后的长度 + if (encoding == "gzip") body = pako.gzip(body); // gzip压缩(有问题,别压) + let rawBody = new Uint8Array(header.length + body.length); + rawBody.set([flag], 0) // 0位:Encoding类型,当为1的时候, app会校验1-4位的校验值是否正确 + rawBody.set(checksum, 1) // 1-4位: 校验值(4位) + rawBody.set(body, 5); // 5-end位:protobuf数据 + //$.log(`🎉 ${$.name}, Create New Raw Body`, ""); + return rawBody; - // 计算校验和 (B站为数据本体字节数) - function Checksum(num) { - let arr = new ArrayBuffer(4); // an Int32 takes 4 bytes - let view = new DataView(arr); - // 首位填充计算过的新数据长度 - view.setUint32(0, num, false); // byteOffset = 0; litteEndian = false - return new Uint8Array(arr); - } -} + // 计算校验和 (B站为数据本体字节数) + function Checksum(num) { + let arr = new ArrayBuffer(4); // an Int32 takes 4 bytes + let view = new DataView(arr); + // 首位填充计算过的新数据长度 + view.setUint32(0, num, false); // byteOffset = 0; litteEndian = false + return new Uint8Array(arr); + }; +}; /***************** Env *****************/ // prettier-ignore // https://github.com/chavyleung/scripts/blob/master/Env.min.js -function Env(t,e){class s{constructor(t){this.env=t}send(t,e="GET"){t="string"==typeof t?{url:t}:t;let s=this.get;return"POST"===e&&(s=this.post),new Promise((e,a)=>{s.call(this,t,(t,s,r)=>{t?a(t):e(s)})})}get(t){return this.send.call(this.env,t)}post(t){return this.send.call(this.env,t,"POST")}}return new class{constructor(t,e){this.name=t,this.http=new s(this),this.data=null,this.dataFile="box.dat",this.logs=[],this.isMute=!1,this.isNeedRewrite=!1,this.logSeparator="\n",this.encoding="utf-8",this.startTime=(new Date).getTime(),Object.assign(this,e),this.log("",`\ud83d\udd14${this.name}, \u5f00\u59cb!`)}getEnv(){return"undefined"!=typeof $environment&&$environment["surge-version"]?"Surge":"undefined"!=typeof $environment&&$environment["stash-version"]?"Stash":"undefined"!=typeof module&&module.exports?"Node.js":"undefined"!=typeof $task?"Quantumult X":"undefined"!=typeof $loon?"Loon":"undefined"!=typeof $rocket?"Shadowrocket":void 0}isNode(){return"Node.js"===this.getEnv()}isQuanX(){return"Quantumult X"===this.getEnv()}isSurge(){return"Surge"===this.getEnv()}isLoon(){return"Loon"===this.getEnv()}isShadowrocket(){return"Shadowrocket"===this.getEnv()}isStash(){return"Stash"===this.getEnv()}toObj(t,e=null){try{return JSON.parse(t)}catch{return e}}toStr(t,e=null){try{return JSON.stringify(t)}catch{return e}}getjson(t,e){let s=e;const a=this.getdata(t);if(a)try{s=JSON.parse(this.getdata(t))}catch{}return s}setjson(t,e){try{return this.setdata(JSON.stringify(t),e)}catch{return!1}}getScript(t){return new Promise(e=>{this.get({url:t},(t,s,a)=>e(a))})}runScript(t,e){return new Promise(s=>{let a=this.getdata("@chavy_boxjs_userCfgs.httpapi");a=a?a.replace(/\n/g,"").trim():a;let r=this.getdata("@chavy_boxjs_userCfgs.httpapi_timeout");r=r?1*r:20,r=e&&e.timeout?e.timeout:r;const[i,o]=a.split("@"),n={url:`http://${o}/v1/scripting/evaluate`,body:{script_text:t,mock_type:"cron",timeout:r},headers:{"X-Key":i,Accept:"*/*"},timeout:r};this.post(n,(t,e,a)=>s(a))}).catch(t=>this.logErr(t))}loaddata(){if(!this.isNode())return{};{this.fs=this.fs?this.fs:require("fs"),this.path=this.path?this.path:require("path");const t=this.path.resolve(this.dataFile),e=this.path.resolve(process.cwd(),this.dataFile),s=this.fs.existsSync(t),a=!s&&this.fs.existsSync(e);if(!s&&!a)return{};{const a=s?t:e;try{return JSON.parse(this.fs.readFileSync(a))}catch(t){return{}}}}}writedata(){if(this.isNode()){this.fs=this.fs?this.fs:require("fs"),this.path=this.path?this.path:require("path");const t=this.path.resolve(this.dataFile),e=this.path.resolve(process.cwd(),this.dataFile),s=this.fs.existsSync(t),a=!s&&this.fs.existsSync(e),r=JSON.stringify(this.data);s?this.fs.writeFileSync(t,r):a?this.fs.writeFileSync(e,r):this.fs.writeFileSync(t,r)}}lodash_get(t,e,s){const a=e.replace(/\[(\d+)\]/g,".$1").split(".");let r=t;for(const t of a)if(r=Object(r)[t],void 0===r)return s;return r}lodash_set(t,e,s){return Object(t)!==t?t:(Array.isArray(e)||(e=e.toString().match(/[^.[\]]+/g)||[]),e.slice(0,-1).reduce((t,s,a)=>Object(t[s])===t[s]?t[s]:t[s]=Math.abs(e[a+1])>>0==+e[a+1]?[]:{},t)[e[e.length-1]]=s,t)}getdata(t){let e=this.getval(t);if(/^@/.test(t)){const[,s,a]=/^@(.*?)\.(.*?)$/.exec(t),r=s?this.getval(s):"";if(r)try{const t=JSON.parse(r);e=t?this.lodash_get(t,a,""):e}catch(t){e=""}}return e}setdata(t,e){let s=!1;if(/^@/.test(e)){const[,a,r]=/^@(.*?)\.(.*?)$/.exec(e),i=this.getval(a),o=a?"null"===i?null:i||"{}":"{}";try{const e=JSON.parse(o);this.lodash_set(e,r,t),s=this.setval(JSON.stringify(e),a)}catch(e){const i={};this.lodash_set(i,r,t),s=this.setval(JSON.stringify(i),a)}}else s=this.setval(t,e);return s}getval(t){switch(this.getEnv()){case"Surge":case"Loon":case"Stash":case"Shadowrocket":return $persistentStore.read(t);case"Quantumult X":return $prefs.valueForKey(t);case"Node.js":return this.data=this.loaddata(),this.data[t];default:return this.data&&this.data[t]||null}}setval(t,e){switch(this.getEnv()){case"Surge":case"Loon":case"Stash":case"Shadowrocket":return $persistentStore.write(t,e);case"Quantumult X":return $prefs.setValueForKey(t,e);case"Node.js":return this.data=this.loaddata(),this.data[e]=t,this.writedata(),!0;default:return this.data&&this.data[e]||null}}initGotEnv(t){this.got=this.got?this.got:require("got"),this.cktough=this.cktough?this.cktough:require("tough-cookie"),this.ckjar=this.ckjar?this.ckjar:new this.cktough.CookieJar,t&&(t.headers=t.headers?t.headers:{},void 0===t.headers.Cookie&&void 0===t.cookieJar&&(t.cookieJar=this.ckjar))}get(t,e=(()=>{})){switch(t.headers&&(delete t.headers["Content-Type"],delete t.headers["Content-Length"],delete t.headers["content-type"],delete t.headers["content-length"]),this.getEnv()){case"Surge":case"Loon":case"Stash":case"Shadowrocket":default:this.isSurge()&&this.isNeedRewrite&&(t.headers=t.headers||{},Object.assign(t.headers,{"X-Surge-Skip-Scripting":!1})),$httpClient.get(t,(t,s,a)=>{!t&&s&&(s.body=a,s.statusCode=s.status?s.status:s.statusCode,s.status=s.statusCode),e(t,s,a)});break;case"Quantumult X":this.isNeedRewrite&&(t.opts=t.opts||{},Object.assign(t.opts,{hints:!1})),$task.fetch(t).then(t=>{const{statusCode:s,statusCode:a,headers:r,body:i,bodyBytes:o}=t;e(null,{status:s,statusCode:a,headers:r,body:i,bodyBytes:o},i,o)},t=>e(t&&t.error||"UndefinedError"));break;case"Node.js":let s=require("iconv-lite");this.initGotEnv(t),this.got(t).on("redirect",(t,e)=>{try{if(t.headers["set-cookie"]){const s=t.headers["set-cookie"].map(this.cktough.Cookie.parse).toString();s&&this.ckjar.setCookieSync(s,null),e.cookieJar=this.ckjar}}catch(t){this.logErr(t)}}).then(t=>{const{statusCode:a,statusCode:r,headers:i,rawBody:o}=t,n=s.decode(o,this.encoding);e(null,{status:a,statusCode:r,headers:i,rawBody:o,body:n},n)},t=>{const{message:a,response:r}=t;e(a,r,r&&s.decode(r.rawBody,this.encoding))})}}post(t,e=(()=>{})){const s=t.method?t.method.toLocaleLowerCase():"post";switch(t.body&&t.headers&&!t.headers["Content-Type"]&&!t.headers["content-type"]&&(t.headers["content-type"]="application/x-www-form-urlencoded"),t.headers&&(delete t.headers["Content-Length"],delete t.headers["content-length"]),this.getEnv()){case"Surge":case"Loon":case"Stash":case"Shadowrocket":default:this.isSurge()&&this.isNeedRewrite&&(t.headers=t.headers||{},Object.assign(t.headers,{"X-Surge-Skip-Scripting":!1})),$httpClient[s](t,(t,s,a)=>{!t&&s&&(s.body=a,s.statusCode=s.status?s.status:s.statusCode,s.status=s.statusCode),e(t,s,a)});break;case"Quantumult X":t.method=s,this.isNeedRewrite&&(t.opts=t.opts||{},Object.assign(t.opts,{hints:!1})),$task.fetch(t).then(t=>{const{statusCode:s,statusCode:a,headers:r,body:i,bodyBytes:o}=t;e(null,{status:s,statusCode:a,headers:r,body:i,bodyBytes:o},i,o)},t=>e(t&&t.error||"UndefinedError"));break;case"Node.js":let a=require("iconv-lite");this.initGotEnv(t);const{url:r,...i}=t;this.got[s](r,i).then(t=>{const{statusCode:s,statusCode:r,headers:i,rawBody:o}=t,n=a.decode(o,this.encoding);e(null,{status:s,statusCode:r,headers:i,rawBody:o,body:n},n)},t=>{const{message:s,response:r}=t;e(s,r,r&&a.decode(r.rawBody,this.encoding))})}}time(t,e=null){const s=e?new Date(e):new Date;let a={"M+":s.getMonth()+1,"d+":s.getDate(),"H+":s.getHours(),"m+":s.getMinutes(),"s+":s.getSeconds(),"q+":Math.floor((s.getMonth()+3)/3),S:s.getMilliseconds()};/(y+)/.test(t)&&(t=t.replace(RegExp.$1,(s.getFullYear()+"").substr(4-RegExp.$1.length)));for(let e in a)new RegExp("("+e+")").test(t)&&(t=t.replace(RegExp.$1,1==RegExp.$1.length?a[e]:("00"+a[e]).substr((""+a[e]).length)));return t}queryStr(t){let e="";for(const s in t){let a=t[s];null!=a&&""!==a&&("object"==typeof a&&(a=JSON.stringify(a)),e+=`${s}=${a}&`)}return e=e.substring(0,e.length-1),e}msg(e=t,s="",a="",r){const i=t=>{switch(typeof t){case void 0:return t;case"string":switch(this.getEnv()){case"Surge":case"Stash":default:return{url:t};case"Loon":case"Shadowrocket":return t;case"Quantumult X":return{"open-url":t};case"Node.js":return}case"object":switch(this.getEnv()){case"Surge":case"Stash":case"Shadowrocket":default:{let e=t.url||t.openUrl||t["open-url"];return{url:e}}case"Loon":{let e=t.openUrl||t.url||t["open-url"],s=t.mediaUrl||t["media-url"];return{openUrl:e,mediaUrl:s}}case"Quantumult X":{let e=t["open-url"]||t.url||t.openUrl,s=t["media-url"]||t.mediaUrl,a=t["update-pasteboard"]||t.updatePasteboard;return{"open-url":e,"media-url":s,"update-pasteboard":a}}case"Node.js":return}default:return}};if(!this.isMute)switch(this.getEnv()){case"Surge":case"Loon":case"Stash":case"Shadowrocket":default:$notification.post(e,s,a,i(r));break;case"Quantumult X":$notify(e,s,a,i(r));break;case"Node.js":}if(!this.isMuteLog){let t=["","==============\ud83d\udce3\u7cfb\u7edf\u901a\u77e5\ud83d\udce3=============="];t.push(e),s&&t.push(s),a&&t.push(a),console.log(t.join("\n")),this.logs=this.logs.concat(t)}}log(...t){t.length>0&&(this.logs=[...this.logs,...t]),console.log(t.join(this.logSeparator))}logErr(t,e){switch(this.getEnv()){case"Surge":case"Loon":case"Stash":case"Shadowrocket":case"Quantumult X":default:this.log("",`\u2757\ufe0f${this.name}, \u9519\u8bef!`,t);break;case"Node.js":this.log("",`\u2757\ufe0f${this.name}, \u9519\u8bef!`,t.stack)}}wait(t){return new Promise(e=>setTimeout(e,t))}done(t={}){const e=(new Date).getTime(),s=(e-this.startTime)/1e3;switch(this.log("",`\ud83d\udd14${this.name}, \u7ed3\u675f! \ud83d\udd5b ${s} \u79d2`),this.log(),this.getEnv()){case"Surge":case"Loon":case"Stash":case"Shadowrocket":case"Quantumult X":default:$done(t);break;case"Node.js":process.exit(1)}}}(t,e)} +function Env(t, e) { + class s { + constructor(t) { + this.env = t + } -// https://github.com/DualSubs/URL/blob/main/URLs.embedded.min.js -function URLs(s) { - return new (class { - constructor(s = []) { - (this.name = 'URL v1.0.2'), - (this.opts = s), - (this.json = { scheme: '', host: '', path: '', params: {} }); + send(t, e = "GET") { + t = "string" == typeof t ? {url: t} : t; + let s = this.get; + return "POST" === e && (s = this.post), new Promise((e, a) => { + s.call(this, t, (t, s, r) => { + t ? a(t) : e(s) + }) + }) + } + + get(t) { + return this.send.call(this.env, t) + } + + post(t) { + return this.send.call(this.env, t, "POST") + } } - parse(s) { - let t = - s.match( - /(?.+):\/\/(?[^/]+)\/?(?[^?]+)?\??(?.*)?/ - )?.groups ?? null; - return ( - t?.path || (t.path = ''), - t?.params && - (t.params = Object.fromEntries( - t.params.split('&').map((s) => s.split('=')) - )), - t - ); - } - stringify(s = this.json) { - return s?.params - ? s.scheme + - '://' + - s.host + - '/' + - s.path + - '?' + - Object.entries(s.params) - .map((s) => s.join('=')) - .join('&') - : s.scheme + '://' + s.host + '/' + s.path; - } - })(s); + + return new class { + constructor(t, e) { + this.name = t, this.http = new s(this), this.data = null, this.dataFile = "box.dat", this.logs = [], this.isMute = !1, this.isNeedRewrite = !1, this.logSeparator = "\n", this.encoding = "utf-8", this.startTime = (new Date).getTime(), Object.assign(this, e), this.log("", `\ud83d\udd14${this.name}, \u5f00\u59cb!`) + } + + getEnv() { + return "undefined" != typeof $environment && $environment["surge-version"] ? "Surge" : "undefined" != typeof $environment && $environment["stash-version"] ? "Stash" : "undefined" != typeof module && module.exports ? "Node.js" : "undefined" != typeof $task ? "Quantumult X" : "undefined" != typeof $loon ? "Loon" : "undefined" != typeof $rocket ? "Shadowrocket" : void 0 + } + + isNode() { + return "Node.js" === this.getEnv() + } + + isQuanX() { + return "Quantumult X" === this.getEnv() + } + + isSurge() { + return "Surge" === this.getEnv() + } + + isLoon() { + return "Loon" === this.getEnv() + } + + isShadowrocket() { + return "Shadowrocket" === this.getEnv() + } + + isStash() { + return "Stash" === this.getEnv() + } + + toObj(t, e = null) { + try { + return JSON.parse(t) + } catch { + return e + } + } + + toStr(t, e = null) { + try { + return JSON.stringify(t) + } catch { + return e + } + } + + getjson(t, e) { + let s = e; + const a = this.getdata(t); + if (a) try { + s = JSON.parse(this.getdata(t)) + } catch { + } + return s + } + + setjson(t, e) { + try { + return this.setdata(JSON.stringify(t), e) + } catch { + return !1 + } + } + + getScript(t) { + return new Promise(e => { + this.get({url: t}, (t, s, a) => e(a)) + }) + } + + runScript(t, e) { + return new Promise(s => { + let a = this.getdata("@chavy_boxjs_userCfgs.httpapi"); + a = a ? a.replace(/\n/g, "").trim() : a; + let r = this.getdata("@chavy_boxjs_userCfgs.httpapi_timeout"); + r = r ? 1 * r : 20, r = e && e.timeout ? e.timeout : r; + const [i, o] = a.split("@"), n = { + url: `http://${o}/v1/scripting/evaluate`, + body: {script_text: t, mock_type: "cron", timeout: r}, + headers: {"X-Key": i, Accept: "*/*"}, + timeout: r + }; + this.post(n, (t, e, a) => s(a)) + }).catch(t => this.logErr(t)) + } + + loaddata() { + if (!this.isNode()) return {}; + { + this.fs = this.fs ? this.fs : require("fs"), this.path = this.path ? this.path : require("path"); + const t = this.path.resolve(this.dataFile), e = this.path.resolve(process.cwd(), this.dataFile), + s = this.fs.existsSync(t), a = !s && this.fs.existsSync(e); + if (!s && !a) return {}; + { + const a = s ? t : e; + try { + return JSON.parse(this.fs.readFileSync(a)) + } catch (t) { + return {} + } + } + } + } + + writedata() { + if (this.isNode()) { + this.fs = this.fs ? this.fs : require("fs"), this.path = this.path ? this.path : require("path"); + const t = this.path.resolve(this.dataFile), e = this.path.resolve(process.cwd(), this.dataFile), + s = this.fs.existsSync(t), a = !s && this.fs.existsSync(e), r = JSON.stringify(this.data); + s ? this.fs.writeFileSync(t, r) : a ? this.fs.writeFileSync(e, r) : this.fs.writeFileSync(t, r) + } + } + + lodash_get(t, e, s) { + const a = e.replace(/\[(\d+)\]/g, ".$1").split("."); + let r = t; + for (const t of a) if (r = Object(r)[t], void 0 === r) return s; + return r + } + + lodash_set(t, e, s) { + return Object(t) !== t ? t : (Array.isArray(e) || (e = e.toString().match(/[^.[\]]+/g) || []), e.slice(0, -1).reduce((t, s, a) => Object(t[s]) === t[s] ? t[s] : t[s] = Math.abs(e[a + 1]) >> 0 == +e[a + 1] ? [] : {}, t)[e[e.length - 1]] = s, t) + } + + getdata(t) { + let e = this.getval(t); + if (/^@/.test(t)) { + const [, s, a] = /^@(.*?)\.(.*?)$/.exec(t), r = s ? this.getval(s) : ""; + if (r) try { + const t = JSON.parse(r); + e = t ? this.lodash_get(t, a, "") : e + } catch (t) { + e = "" + } + } + return e + } + + setdata(t, e) { + let s = !1; + if (/^@/.test(e)) { + const [, a, r] = /^@(.*?)\.(.*?)$/.exec(e), i = this.getval(a), + o = a ? "null" === i ? null : i || "{}" : "{}"; + try { + const e = JSON.parse(o); + this.lodash_set(e, r, t), s = this.setval(JSON.stringify(e), a) + } catch (e) { + const i = {}; + this.lodash_set(i, r, t), s = this.setval(JSON.stringify(i), a) + } + } else s = this.setval(t, e); + return s + } + + getval(t) { + switch (this.getEnv()) { + case"Surge": + case"Loon": + case"Stash": + case"Shadowrocket": + return $persistentStore.read(t); + case"Quantumult X": + return $prefs.valueForKey(t); + case"Node.js": + return this.data = this.loaddata(), this.data[t]; + default: + return this.data && this.data[t] || null + } + } + + setval(t, e) { + switch (this.getEnv()) { + case"Surge": + case"Loon": + case"Stash": + case"Shadowrocket": + return $persistentStore.write(t, e); + case"Quantumult X": + return $prefs.setValueForKey(t, e); + case"Node.js": + return this.data = this.loaddata(), this.data[e] = t, this.writedata(), !0; + default: + return this.data && this.data[e] || null + } + } + + initGotEnv(t) { + this.got = this.got ? this.got : require("got"), this.cktough = this.cktough ? this.cktough : require("tough-cookie"), this.ckjar = this.ckjar ? this.ckjar : new this.cktough.CookieJar, t && (t.headers = t.headers ? t.headers : {}, void 0 === t.headers.Cookie && void 0 === t.cookieJar && (t.cookieJar = this.ckjar)) + } + + get(t, e = (() => { + })) { + switch (t.headers && (delete t.headers["Content-Type"], delete t.headers["Content-Length"], delete t.headers["content-type"], delete t.headers["content-length"]), this.getEnv()) { + case"Surge": + case"Loon": + case"Stash": + case"Shadowrocket": + default: + this.isSurge() && this.isNeedRewrite && (t.headers = t.headers || {}, Object.assign(t.headers, {"X-Surge-Skip-Scripting": !1})), $httpClient.get(t, (t, s, a) => { + !t && s && (s.body = a, s.statusCode = s.status ? s.status : s.statusCode, s.status = s.statusCode), e(t, s, a) + }); + break; + case"Quantumult X": + this.isNeedRewrite && (t.opts = t.opts || {}, Object.assign(t.opts, {hints: !1})), $task.fetch(t).then(t => { + const {statusCode: s, statusCode: a, headers: r, body: i, bodyBytes: o} = t; + e(null, {status: s, statusCode: a, headers: r, body: i, bodyBytes: o}, i, o) + }, t => e(t && t.error || "UndefinedError")); + break; + case"Node.js": + let s = require("iconv-lite"); + this.initGotEnv(t), this.got(t).on("redirect", (t, e) => { + try { + if (t.headers["set-cookie"]) { + const s = t.headers["set-cookie"].map(this.cktough.Cookie.parse).toString(); + s && this.ckjar.setCookieSync(s, null), e.cookieJar = this.ckjar + } + } catch (t) { + this.logErr(t) + } + }).then(t => { + const {statusCode: a, statusCode: r, headers: i, rawBody: o} = t, + n = s.decode(o, this.encoding); + e(null, {status: a, statusCode: r, headers: i, rawBody: o, body: n}, n) + }, t => { + const {message: a, response: r} = t; + e(a, r, r && s.decode(r.rawBody, this.encoding)) + }) + } + } + + post(t, e = (() => { + })) { + const s = t.method ? t.method.toLocaleLowerCase() : "post"; + switch (t.body && t.headers && !t.headers["Content-Type"] && !t.headers["content-type"] && (t.headers["content-type"] = "application/x-www-form-urlencoded"), t.headers && (delete t.headers["Content-Length"], delete t.headers["content-length"]), this.getEnv()) { + case"Surge": + case"Loon": + case"Stash": + case"Shadowrocket": + default: + this.isSurge() && this.isNeedRewrite && (t.headers = t.headers || {}, Object.assign(t.headers, {"X-Surge-Skip-Scripting": !1})), $httpClient[s](t, (t, s, a) => { + !t && s && (s.body = a, s.statusCode = s.status ? s.status : s.statusCode, s.status = s.statusCode), e(t, s, a) + }); + break; + case"Quantumult X": + t.method = s, this.isNeedRewrite && (t.opts = t.opts || {}, Object.assign(t.opts, {hints: !1})), $task.fetch(t).then(t => { + const {statusCode: s, statusCode: a, headers: r, body: i, bodyBytes: o} = t; + e(null, {status: s, statusCode: a, headers: r, body: i, bodyBytes: o}, i, o) + }, t => e(t && t.error || "UndefinedError")); + break; + case"Node.js": + let a = require("iconv-lite"); + this.initGotEnv(t); + const {url: r, ...i} = t; + this.got[s](r, i).then(t => { + const {statusCode: s, statusCode: r, headers: i, rawBody: o} = t, + n = a.decode(o, this.encoding); + e(null, {status: s, statusCode: r, headers: i, rawBody: o, body: n}, n) + }, t => { + const {message: s, response: r} = t; + e(s, r, r && a.decode(r.rawBody, this.encoding)) + }) + } + } + + time(t, e = null) { + const s = e ? new Date(e) : new Date; + let a = { + "M+": s.getMonth() + 1, + "d+": s.getDate(), + "H+": s.getHours(), + "m+": s.getMinutes(), + "s+": s.getSeconds(), + "q+": Math.floor((s.getMonth() + 3) / 3), + S: s.getMilliseconds() + }; + /(y+)/.test(t) && (t = t.replace(RegExp.$1, (s.getFullYear() + "").substr(4 - RegExp.$1.length))); + for (let e in a) new RegExp("(" + e + ")").test(t) && (t = t.replace(RegExp.$1, 1 == RegExp.$1.length ? a[e] : ("00" + a[e]).substr(("" + a[e]).length))); + return t + } + + queryStr(t) { + let e = ""; + for (const s in t) { + let a = t[s]; + null != a && "" !== a && ("object" == typeof a && (a = JSON.stringify(a)), e += `${s}=${a}&`) + } + return e = e.substring(0, e.length - 1), e + } + + msg(e = t, s = "", a = "", r) { + const i = t => { + switch (typeof t) { + case void 0: + return t; + case"string": + switch (this.getEnv()) { + case"Surge": + case"Stash": + default: + return {url: t}; + case"Loon": + case"Shadowrocket": + return t; + case"Quantumult X": + return {"open-url": t}; + case"Node.js": + return + } + case"object": + switch (this.getEnv()) { + case"Surge": + case"Stash": + case"Shadowrocket": + default: { + let e = t.url || t.openUrl || t["open-url"]; + return {url: e} + } + case"Loon": { + let e = t.openUrl || t.url || t["open-url"], s = t.mediaUrl || t["media-url"]; + return {openUrl: e, mediaUrl: s} + } + case"Quantumult X": { + let e = t["open-url"] || t.url || t.openUrl, s = t["media-url"] || t.mediaUrl, + a = t["update-pasteboard"] || t.updatePasteboard; + return {"open-url": e, "media-url": s, "update-pasteboard": a} + } + case"Node.js": + return + } + default: + return + } + }; + if (!this.isMute) switch (this.getEnv()) { + case"Surge": + case"Loon": + case"Stash": + case"Shadowrocket": + default: + $notification.post(e, s, a, i(r)); + break; + case"Quantumult X": + $notify(e, s, a, i(r)); + break; + case"Node.js": + } + if (!this.isMuteLog) { + let t = ["", "==============\ud83d\udce3\u7cfb\u7edf\u901a\u77e5\ud83d\udce3=============="]; + t.push(e), s && t.push(s), a && t.push(a), console.log(t.join("\n")), this.logs = this.logs.concat(t) + } + } + + log(...t) { + t.length > 0 && (this.logs = [...this.logs, ...t]), console.log(t.join(this.logSeparator)) + } + + logErr(t, e) { + switch (this.getEnv()) { + case"Surge": + case"Loon": + case"Stash": + case"Shadowrocket": + case"Quantumult X": + default: + this.log("", `\u2757\ufe0f${this.name}, \u9519\u8bef!`, t); + break; + case"Node.js": + this.log("", `\u2757\ufe0f${this.name}, \u9519\u8bef!`, t.stack) + } + } + + wait(t) { + return new Promise(e => setTimeout(e, t)) + } + + done(t = {}) { + const e = (new Date).getTime(), s = (e - this.startTime) / 1e3; + switch (this.log("", `\ud83d\udd14${this.name}, \u7ed3\u675f! \ud83d\udd5b ${s} \u79d2`), this.log(), this.getEnv()) { + case"Surge": + case"Loon": + case"Stash": + case"Shadowrocket": + case"Quantumult X": + default: + $done(t); + break; + case"Node.js": + process.exit(1) + } + } + }(t, e) } /** * Get Environment Variables - * @link https://github.com/VirgilClyne/VirgilClyne/blob/main/function/getENV/getENV.min.js + * @link https://github.com/VirgilClyne/GetSomeFries/blob/main/function/getENV/getENV.min.js * @author VirgilClyne - * @param {String} t - Persistent Store Key - * @param {String} e - Platform Name - * @param {Object} n - Default Database + * @param {String} key - Persistent Store Key + * @param {Array} names - Platform Names + * @param {Object} database - Default Database * @return {Object} { Settings, Caches, Configs } */ -function getENV(t, e, n) { - let i = $.getjson(t, n), - s = {}; - if ('undefined' != typeof $argument && Boolean($argument)) { - let t = Object.fromEntries($argument.split('&').map((t) => t.split('='))); - for (let e in t) l(s, e, t[e]); - } - let g = { - ...n?.Default?.Settings, - ...n?.[e]?.Settings, - ...i?.[e]?.Settings, - ...s, - }, - f = { ...n?.Default?.Configs, ...n?.[e]?.Configs, ...i?.[e]?.Configs }, - o = i?.[e]?.Caches || {}; - return ( - 'string' == typeof o && (o = JSON.parse(o)), - { Settings: g, Caches: o, Configs: f } - ); - function l(t, e, n) { - e.split('.').reduce( - (t, i, s) => (t[i] = e.split('.').length === ++s ? n : t[i] || {}), - t - ); - } +function getENV(key, names, database) { + let BoxJs = $.getjson(key, database), Argument = {}; + if ("undefined" != typeof $argument && Boolean($argument)) { + let arg = Object.fromEntries($argument.split("&").map((item => item.split("=")))); + for (let item in arg) setPath(Argument, item, arg[item]) + } + const Store = {Settings: database?.Default?.Settings || {}, Configs: database?.Default?.Configs || {}, Caches: {}}; + Array.isArray(names) || (names = [names]); + for (let name of names) Store.Settings = {...Store.Settings, ...database?.[name]?.Settings, ...BoxJs?.[name]?.Settings, ...Argument}, Store.Configs = {...Store.Configs, ...database?.[name]?.Configs}, BoxJs?.[name]?.Caches && "string" == typeof BoxJs?.[name]?.Caches && (BoxJs[name].Caches = JSON.parse(BoxJs?.[name]?.Caches)), Store.Caches = {...Store.Caches, ...BoxJs?.[name]?.Caches}; + return function traverseObject(o, c) { + for (var t in o) { + var n = o[t]; + o[t] = "object" == typeof n && null !== n ? traverseObject(n, c) : c(t, n) + } + return o + }(Store.Settings, ((key, value) => ("true" === value || "false" === value ? value = JSON.parse(value) : "string" == typeof value && (value?.includes(",") ? value = value.split(",") : value && !isNaN(value) && (value = parseInt(value, 10))), value))), Store; + + function setPath(object, path, value) { + path.split(".").reduce(((o, p, i) => o[p] = path.split(".").length === ++i ? value : o[p] || {}), object) + } } + +// https://github.com/VirgilClyne/GetSomeFries/blob/main/function/URL/URLs.embedded.min.js +function URLs(t) { + return new class { + constructor(t = []) { + this.name = "URL v1.2.2", this.opts = t, this.json = {scheme: "", host: "", path: "", type: "", query: {}} + } + + parse(t) { + let s = t.match(/(?:(?.+):\/\/(?[^/]+))?\/?(?[^?]+)?\??(?[^?]+)?/)?.groups ?? null; + return s?.path ? s.paths = s?.path?.split("/") : s.path = "", s?.paths && (s.type = s?.paths?.[s?.paths?.length - 1]?.split(".")?.[1]), s?.query && (s.query = Object.fromEntries(s.query.split("&").map((t => t.split("="))))), s + } + + stringify(t = this.json) { + let s = ""; + return t?.scheme && t?.host && (s += t.scheme + "://" + t.host), t?.path && (s += t?.host ? "/" + t.path : t.path), t?.query && (s += "?" + Object.entries(t.query).map((t => t.join("="))).join("&")), s + } + }(t) +} \ No newline at end of file diff --git a/Scripts/AdBlock/Bilibili/BiliBili.response.min.js b/Scripts/AdBlock/Bilibili/BiliBili.response.min.js index 9c58c91..cab7a04 100644 --- a/Scripts/AdBlock/Bilibili/BiliBili.response.min.js +++ b/Scripts/AdBlock/Bilibili/BiliBili.response.min.js @@ -2,7 +2,7 @@ WEBSITE: https://biliuniverse.io README: https://github.com/BiliUniverse */ -const $ = new Env("📺 BiliBili: 🛡️ ADBlock v0.3.1(2) response"); +const $ = new Env("📺 BiliBili: 🛡️ ADBlock v0.4.0(2) response"); const URL = new URLs(); const DataBase = { "ADBlock":{ @@ -19,11 +19,12 @@ const DataBase = { /***************** Processing *****************/ (async () => { const { Settings, Caches, Configs } = setENV("BiliBili", "ADBlock", DataBase); - switch (Settings?.Switch) { + $.log(`⚠ ${$.name}`, `Settings.Switch: ${Settings?.Switch}`, ""); + switch (Settings.Switch) { case true: default: let url = URL.parse($request?.url); - const METHOD = $request?.method, HOST = url?.host, PATH = url?.path, PATHs = PATH.split("/"); + const METHOD = $request?.method, HOST = url?.host, PATH = url?.path, PATHs = url?.paths; // 解析格式 const FORMAT = ($response?.headers?.["Content-Type"] ?? $response?.headers?.["content-type"])?.split(";")?.[0]; $.log(`⚠ ${$.name}`, `METHOD: ${METHOD}`, `HOST: ${HOST}`, `PATH: ${PATH}`, `PATHs: ${PATHs}`, `FORMAT: ${FORMAT}`, ""); @@ -38,6 +39,10 @@ const DataBase = { case "text/html": default: break; + case "application/x-mpegURL": + case "application/x-mpegurl": + case "application/vnd.apple.mpegurl": + break; case "text/xml": case "text/plist": case "application/xml": @@ -79,7 +84,7 @@ const DataBase = { case true: default: if (body.data.items?.length) { - let params = url?.params;//区分pad与phone + //区分pad与phone body.data.items = await Promise.all(body.data.items.map(async item => { const { card_type: cardType, card_goto: cardGoto } = item; if (cardType && cardGoto) { @@ -106,7 +111,7 @@ const DataBase = { } else if (['cm_v2', 'cm_v1'].includes(cardType) && ['ad_web_s', 'ad_av', 'ad_web_gif'].includes(cardGoto)) { // ad_player大视频广告 ad_web_gif大gif广告 ad_web_s普通小广告 ad_av创作推广广告 ad_inline_3d 上方大的视频3d广告 ad_inline_eggs 上方大的视频广告 $.log(`🎉 ${$.name}`, `${cardGoto}广告去除`); - if (params.device !== "phone") { + if (url?.query?.device !== "phone") { return undefined;//pad直接去除 } else { await fixPosition().then(result => item = result);//小广告补位 @@ -125,7 +130,7 @@ const DataBase = { return undefined;//大广告直接去除 } else if (cardType === 'small_cover_v10' && cardGoto === 'game') { $.log(`🎉 ${$.name}`, "游戏广告去除"); - if (params.device !== "phone") { + if (url?.query?.device !== "phone") { return undefined;//pad直接去除 } else { await fixPosition().then(result => item = result);//小广告补位 @@ -139,56 +144,56 @@ const DataBase = { })); body.data.items = body.data.items.filter(fix => fix !== undefined); } - async function fixPosition() { - let itemsCache = $.getdata("@BiliBili.Index.Caches",""); - let singleItem = {}; - if (itemsCache && itemsCache.length > 0) { + async function fixPosition() { + let itemsCache = $.getdata("@BiliBili.Index.Caches",""); + let singleItem = {}; + if (itemsCache && itemsCache.length > 0) { + singleItem = itemsCache.pop(); + $.log(`🎉 ${$.name}`, "推荐页空缺位填充成功"); + } else {//重新获取填充位 + const myRequest = { + url: $request.url, + headers: $request.heders + } + await $.http.get(myRequest).then(response => { + try { + const body = $.toObj(response.body) + if (body?.code === 0 && body?.message === "0") { + body.data.items = body.data.items.map(item => { + const { card_type: cardType, card_goto: cardGoto } = item; + if (cardType && cardGoto) { + if (cardType === 'banner_v8' && cardGoto === 'banner') { + return undefined; + } else if (cardType === 'cm_v2' && ['ad_web_s', 'ad_av', 'ad_web_gif', 'ad_player', 'ad_inline_3d', 'ad_inline_eggs'].includes(cardGoto)) { + return undefined; + } else if (cardType === 'small_cover_v10' && cardGoto === 'game') { + return undefined; + } else if (cardType === 'cm_double_v9' && cardGoto === 'ad_inline_av') { + return undefined; + } else if (cardType === 'large_cover_v9' && cardGoto === 'inline_av_v2') {//补位不需要大视频 + return undefined; + } + } + return item; + }).filter(fix => fix !== undefined); + $.setdata(body.data.items, "@BiliBili.Index.Caches"); + $.log(`🎉 ${$.name}`, "推荐页缓存数组补充成功"); + } else { + $.log(`🚧 ${$.name}`, "访问推荐页尝试填补失败"); + } + } catch (e) { + $.logErr(e, response) + } + }) + itemsCache = $.getdata("@BiliBili.Index.Caches",""); + if (itemsCache.length > 0) { singleItem = itemsCache.pop(); $.log(`🎉 ${$.name}`, "推荐页空缺位填充成功"); - } else {//重新获取填充位 - const myRequest = { - url: $request.url, - headers: $request.heders - } - await $.http.get(myRequest).then(response => { - try { - const body = $.toObj(response.body) - if (body?.code === 0 && body?.message === "0") { - body.data.items = body.data.items.map(item => { - const { card_type: cardType, card_goto: cardGoto } = item; - if (cardType && cardGoto) { - if (cardType === 'banner_v8' && cardGoto === 'banner') { - return undefined; - } else if (cardType === 'cm_v2' && ['ad_web_s', 'ad_av', 'ad_web_gif', 'ad_player', 'ad_inline_3d', 'ad_inline_eggs'].includes(cardGoto)) { - return undefined; - } else if (cardType === 'small_cover_v10' && cardGoto === 'game') { - return undefined; - } else if (cardType === 'cm_double_v9' && cardGoto === 'ad_inline_av') { - return undefined; - } else if (cardType === 'large_cover_v9' && cardGoto === 'inline_av_v2') {//补位不需要大视频 - return undefined; - } - } - return item; - }).filter(fix => fix !== undefined); - $.setdata(body.data.items, "@BiliBili.Index.Caches"); - $.log(`🎉 ${$.name}`, "推荐页缓存数组补充成功"); - } else { - $.log(`🚧 ${$.name}`, "访问推荐页尝试填补失败"); - } - } catch (e) { - $.logErr(e, response) - } - }) - itemsCache = $.getdata("@BiliBili.Index.Caches",""); - if (itemsCache.length > 0) { - singleItem = itemsCache.pop(); - $.log(`🎉 ${$.name}`, "推荐页空缺位填充成功"); - } } - $.setdata(itemsCache, "@BiliBili.Index.Caches"); - return singleItem; } + $.setdata(itemsCache, "@BiliBili.Index.Caches"); + return singleItem; + } break; case false: $.log(`🚧 ${$.name}`, "用户设置推荐页广告不去除"); @@ -282,7 +287,7 @@ const DataBase = { break; case "x/space/acc/info": // 用户空间-账号信息-pc case "x/space/wbi/acc/info": // 用户空间-账号信息-wbi - switch (url.params?.vmid || url.params?.mid) { + switch (url.query?.vmid || url.query?.mid) { case "11783021": // 哔哩哔哩番剧出差 case "1988098633": // b站_戲劇咖 case "2042149112": // b站_綜藝咖 @@ -345,7 +350,7 @@ const DataBase = { // pako 2.0.4 !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).pako={})}(this,(function(t){"use strict";function e(t){let e=t.length;for(;--e>=0;)t[e]=0}const a=256,i=286,n=30,s=15,r=new Uint8Array([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0]),l=new Uint8Array([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13]),o=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7]),h=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),d=new Array(576);e(d);const _=new Array(60);e(_);const f=new Array(512);e(f);const c=new Array(256);e(c);const u=new Array(29);e(u);const w=new Array(n);function b(t,e,a,i,n){this.static_tree=t,this.extra_bits=e,this.extra_base=a,this.elems=i,this.max_length=n,this.has_stree=t&&t.length}let g,p,m;function k(t,e){this.dyn_tree=t,this.max_code=0,this.stat_desc=e}e(w);const v=t=>t<256?f[t]:f[256+(t>>>7)],y=(t,e)=>{t.pending_buf[t.pending++]=255&e,t.pending_buf[t.pending++]=e>>>8&255},x=(t,e,a)=>{t.bi_valid>16-a?(t.bi_buf|=e<>16-t.bi_valid,t.bi_valid+=a-16):(t.bi_buf|=e<{x(t,a[2*e],a[2*e+1])},A=(t,e)=>{let a=0;do{a|=1&t,t>>>=1,a<<=1}while(--e>0);return a>>>1},E=(t,e,a)=>{const i=new Array(16);let n,r,l=0;for(n=1;n<=s;n++)i[n]=l=l+a[n-1]<<1;for(r=0;r<=e;r++){let e=t[2*r+1];0!==e&&(t[2*r]=A(i[e]++,e))}},R=t=>{let e;for(e=0;e{t.bi_valid>8?y(t,t.bi_buf):t.bi_valid>0&&(t.pending_buf[t.pending++]=t.bi_buf),t.bi_buf=0,t.bi_valid=0},U=(t,e,a,i)=>{const n=2*e,s=2*a;return t[n]{const i=t.heap[a];let n=a<<1;for(;n<=t.heap_len&&(n{let n,s,o,h,d=0;if(0!==t.last_lit)do{n=t.pending_buf[t.d_buf+2*d]<<8|t.pending_buf[t.d_buf+2*d+1],s=t.pending_buf[t.l_buf+d],d++,0===n?z(t,s,e):(o=c[s],z(t,o+a+1,e),h=r[o],0!==h&&(s-=u[o],x(t,s,h)),n--,o=v(n),z(t,o,i),h=l[o],0!==h&&(n-=w[o],x(t,n,h)))}while(d{const a=e.dyn_tree,i=e.stat_desc.static_tree,n=e.stat_desc.has_stree,r=e.stat_desc.elems;let l,o,h,d=-1;for(t.heap_len=0,t.heap_max=573,l=0;l>1;l>=1;l--)S(t,a,l);h=r;do{l=t.heap[1],t.heap[1]=t.heap[t.heap_len--],S(t,a,1),o=t.heap[1],t.heap[--t.heap_max]=l,t.heap[--t.heap_max]=o,a[2*h]=a[2*l]+a[2*o],t.depth[h]=(t.depth[l]>=t.depth[o]?t.depth[l]:t.depth[o])+1,a[2*l+1]=a[2*o+1]=h,t.heap[1]=h++,S(t,a,1)}while(t.heap_len>=2);t.heap[--t.heap_max]=t.heap[1],((t,e)=>{const a=e.dyn_tree,i=e.max_code,n=e.stat_desc.static_tree,r=e.stat_desc.has_stree,l=e.stat_desc.extra_bits,o=e.stat_desc.extra_base,h=e.stat_desc.max_length;let d,_,f,c,u,w,b=0;for(c=0;c<=s;c++)t.bl_count[c]=0;for(a[2*t.heap[t.heap_max]+1]=0,d=t.heap_max+1;d<573;d++)_=t.heap[d],c=a[2*a[2*_+1]+1]+1,c>h&&(c=h,b++),a[2*_+1]=c,_>i||(t.bl_count[c]++,u=0,_>=o&&(u=l[_-o]),w=a[2*_],t.opt_len+=w*(c+u),r&&(t.static_len+=w*(n[2*_+1]+u)));if(0!==b){do{for(c=h-1;0===t.bl_count[c];)c--;t.bl_count[c]--,t.bl_count[c+1]+=2,t.bl_count[h]--,b-=2}while(b>0);for(c=h;0!==c;c--)for(_=t.bl_count[c];0!==_;)f=t.heap[--d],f>i||(a[2*f+1]!==c&&(t.opt_len+=(c-a[2*f+1])*a[2*f],a[2*f+1]=c),_--)}})(t,e),E(a,d,t.bl_count)},O=(t,e,a)=>{let i,n,s=-1,r=e[1],l=0,o=7,h=4;for(0===r&&(o=138,h=3),e[2*(a+1)+1]=65535,i=0;i<=a;i++)n=r,r=e[2*(i+1)+1],++l{let i,n,s=-1,r=e[1],l=0,o=7,h=4;for(0===r&&(o=138,h=3),i=0;i<=a;i++)if(n=r,r=e[2*(i+1)+1],!(++l{x(t,0+(i?1:0),3),((t,e,a,i)=>{Z(t),i&&(y(t,a),y(t,~a)),t.pending_buf.set(t.window.subarray(e,e+a),t.pending),t.pending+=a})(t,e,a,!0)};var N={_tr_init:t=>{F||((()=>{let t,e,a,h,k;const v=new Array(16);for(a=0,h=0;h<28;h++)for(u[h]=a,t=0;t<1<>=7;h{let s,r,l=0;t.level>0?(2===t.strm.data_type&&(t.strm.data_type=(t=>{let e,i=4093624447;for(e=0;e<=31;e++,i>>>=1)if(1&i&&0!==t.dyn_ltree[2*e])return 0;if(0!==t.dyn_ltree[18]||0!==t.dyn_ltree[20]||0!==t.dyn_ltree[26])return 1;for(e=32;e{let e;for(O(t,t.dyn_ltree,t.l_desc.max_code),O(t,t.dyn_dtree,t.d_desc.max_code),T(t,t.bl_desc),e=18;e>=3&&0===t.bl_tree[2*h[e]+1];e--);return t.opt_len+=3*(e+1)+5+5+4,e})(t),s=t.opt_len+3+7>>>3,r=t.static_len+3+7>>>3,r<=s&&(s=r)):s=r=i+5,i+4<=s&&-1!==e?L(t,e,i,n):4===t.strategy||r===s?(x(t,2+(n?1:0),3),D(t,d,_)):(x(t,4+(n?1:0),3),((t,e,a,i)=>{let n;for(x(t,e-257,5),x(t,a-1,5),x(t,i-4,4),n=0;n(t.pending_buf[t.d_buf+2*t.last_lit]=e>>>8&255,t.pending_buf[t.d_buf+2*t.last_lit+1]=255&e,t.pending_buf[t.l_buf+t.last_lit]=255&i,t.last_lit++,0===e?t.dyn_ltree[2*i]++:(t.matches++,e--,t.dyn_ltree[2*(c[i]+a+1)]++,t.dyn_dtree[2*v(e)]++),t.last_lit===t.lit_bufsize-1),_tr_align:t=>{x(t,2,3),z(t,256,d),(t=>{16===t.bi_valid?(y(t,t.bi_buf),t.bi_buf=0,t.bi_valid=0):t.bi_valid>=8&&(t.pending_buf[t.pending++]=255&t.bi_buf,t.bi_buf>>=8,t.bi_valid-=8)})(t)}};var B=(t,e,a,i)=>{let n=65535&t|0,s=t>>>16&65535|0,r=0;for(;0!==a;){r=a>2e3?2e3:a,a-=r;do{n=n+e[i++]|0,s=s+n|0}while(--r);n%=65521,s%=65521}return n|s<<16|0};const C=new Uint32Array((()=>{let t,e=[];for(var a=0;a<256;a++){t=a;for(var i=0;i<8;i++)t=1&t?3988292384^t>>>1:t>>>1;e[a]=t}return e})());var M=(t,e,a,i)=>{const n=C,s=i+a;t^=-1;for(let a=i;a>>8^n[255&(t^e[a])];return-1^t},H={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"},j={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_MEM_ERROR:-4,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8};const{_tr_init:K,_tr_stored_block:P,_tr_flush_block:Y,_tr_tally:G,_tr_align:X}=N,{Z_NO_FLUSH:W,Z_PARTIAL_FLUSH:q,Z_FULL_FLUSH:J,Z_FINISH:Q,Z_BLOCK:V,Z_OK:$,Z_STREAM_END:tt,Z_STREAM_ERROR:et,Z_DATA_ERROR:at,Z_BUF_ERROR:it,Z_DEFAULT_COMPRESSION:nt,Z_FILTERED:st,Z_HUFFMAN_ONLY:rt,Z_RLE:lt,Z_FIXED:ot,Z_DEFAULT_STRATEGY:ht,Z_UNKNOWN:dt,Z_DEFLATED:_t}=j,ft=258,ct=262,ut=103,wt=113,bt=666,gt=(t,e)=>(t.msg=H[e],e),pt=t=>(t<<1)-(t>4?9:0),mt=t=>{let e=t.length;for(;--e>=0;)t[e]=0};let kt=(t,e,a)=>(e<{const e=t.state;let a=e.pending;a>t.avail_out&&(a=t.avail_out),0!==a&&(t.output.set(e.pending_buf.subarray(e.pending_out,e.pending_out+a),t.next_out),t.next_out+=a,e.pending_out+=a,t.total_out+=a,t.avail_out-=a,e.pending-=a,0===e.pending&&(e.pending_out=0))},yt=(t,e)=>{Y(t,t.block_start>=0?t.block_start:-1,t.strstart-t.block_start,e),t.block_start=t.strstart,vt(t.strm)},xt=(t,e)=>{t.pending_buf[t.pending++]=e},zt=(t,e)=>{t.pending_buf[t.pending++]=e>>>8&255,t.pending_buf[t.pending++]=255&e},At=(t,e,a,i)=>{let n=t.avail_in;return n>i&&(n=i),0===n?0:(t.avail_in-=n,e.set(t.input.subarray(t.next_in,t.next_in+n),a),1===t.state.wrap?t.adler=B(t.adler,e,n,a):2===t.state.wrap&&(t.adler=M(t.adler,e,n,a)),t.next_in+=n,t.total_in+=n,n)},Et=(t,e)=>{let a,i,n=t.max_chain_length,s=t.strstart,r=t.prev_length,l=t.nice_match;const o=t.strstart>t.w_size-ct?t.strstart-(t.w_size-ct):0,h=t.window,d=t.w_mask,_=t.prev,f=t.strstart+ft;let c=h[s+r-1],u=h[s+r];t.prev_length>=t.good_match&&(n>>=2),l>t.lookahead&&(l=t.lookahead);do{if(a=e,h[a+r]===u&&h[a+r-1]===c&&h[a]===h[s]&&h[++a]===h[s+1]){s+=2,a++;do{}while(h[++s]===h[++a]&&h[++s]===h[++a]&&h[++s]===h[++a]&&h[++s]===h[++a]&&h[++s]===h[++a]&&h[++s]===h[++a]&&h[++s]===h[++a]&&h[++s]===h[++a]&&sr){if(t.match_start=e,r=i,i>=l)break;c=h[s+r-1],u=h[s+r]}}}while((e=_[e&d])>o&&0!=--n);return r<=t.lookahead?r:t.lookahead},Rt=t=>{const e=t.w_size;let a,i,n,s,r;do{if(s=t.window_size-t.lookahead-t.strstart,t.strstart>=e+(e-ct)){t.window.set(t.window.subarray(e,e+e),0),t.match_start-=e,t.strstart-=e,t.block_start-=e,i=t.hash_size,a=i;do{n=t.head[--a],t.head[a]=n>=e?n-e:0}while(--i);i=e,a=i;do{n=t.prev[--a],t.prev[a]=n>=e?n-e:0}while(--i);s+=e}if(0===t.strm.avail_in)break;if(i=At(t.strm,t.window,t.strstart+t.lookahead,s),t.lookahead+=i,t.lookahead+t.insert>=3)for(r=t.strstart-t.insert,t.ins_h=t.window[r],t.ins_h=kt(t,t.ins_h,t.window[r+1]);t.insert&&(t.ins_h=kt(t,t.ins_h,t.window[r+3-1]),t.prev[r&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=r,r++,t.insert--,!(t.lookahead+t.insert<3)););}while(t.lookahead{let a,i;for(;;){if(t.lookahead=3&&(t.ins_h=kt(t,t.ins_h,t.window[t.strstart+3-1]),a=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart),0!==a&&t.strstart-a<=t.w_size-ct&&(t.match_length=Et(t,a)),t.match_length>=3)if(i=G(t,t.strstart-t.match_start,t.match_length-3),t.lookahead-=t.match_length,t.match_length<=t.max_lazy_match&&t.lookahead>=3){t.match_length--;do{t.strstart++,t.ins_h=kt(t,t.ins_h,t.window[t.strstart+3-1]),a=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart}while(0!=--t.match_length);t.strstart++}else t.strstart+=t.match_length,t.match_length=0,t.ins_h=t.window[t.strstart],t.ins_h=kt(t,t.ins_h,t.window[t.strstart+1]);else i=G(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++;if(i&&(yt(t,!1),0===t.strm.avail_out))return 1}return t.insert=t.strstart<2?t.strstart:2,e===Q?(yt(t,!0),0===t.strm.avail_out?3:4):t.last_lit&&(yt(t,!1),0===t.strm.avail_out)?1:2},Ut=(t,e)=>{let a,i,n;for(;;){if(t.lookahead=3&&(t.ins_h=kt(t,t.ins_h,t.window[t.strstart+3-1]),a=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart),t.prev_length=t.match_length,t.prev_match=t.match_start,t.match_length=2,0!==a&&t.prev_length4096)&&(t.match_length=2)),t.prev_length>=3&&t.match_length<=t.prev_length){n=t.strstart+t.lookahead-3,i=G(t,t.strstart-1-t.prev_match,t.prev_length-3),t.lookahead-=t.prev_length-1,t.prev_length-=2;do{++t.strstart<=n&&(t.ins_h=kt(t,t.ins_h,t.window[t.strstart+3-1]),a=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart)}while(0!=--t.prev_length);if(t.match_available=0,t.match_length=2,t.strstart++,i&&(yt(t,!1),0===t.strm.avail_out))return 1}else if(t.match_available){if(i=G(t,0,t.window[t.strstart-1]),i&&yt(t,!1),t.strstart++,t.lookahead--,0===t.strm.avail_out)return 1}else t.match_available=1,t.strstart++,t.lookahead--}return t.match_available&&(i=G(t,0,t.window[t.strstart-1]),t.match_available=0),t.insert=t.strstart<2?t.strstart:2,e===Q?(yt(t,!0),0===t.strm.avail_out?3:4):t.last_lit&&(yt(t,!1),0===t.strm.avail_out)?1:2};function St(t,e,a,i,n){this.good_length=t,this.max_lazy=e,this.nice_length=a,this.max_chain=i,this.func=n}const Dt=[new St(0,0,0,0,((t,e)=>{let a=65535;for(a>t.pending_buf_size-5&&(a=t.pending_buf_size-5);;){if(t.lookahead<=1){if(Rt(t),0===t.lookahead&&e===W)return 1;if(0===t.lookahead)break}t.strstart+=t.lookahead,t.lookahead=0;const i=t.block_start+a;if((0===t.strstart||t.strstart>=i)&&(t.lookahead=t.strstart-i,t.strstart=i,yt(t,!1),0===t.strm.avail_out))return 1;if(t.strstart-t.block_start>=t.w_size-ct&&(yt(t,!1),0===t.strm.avail_out))return 1}return t.insert=0,e===Q?(yt(t,!0),0===t.strm.avail_out?3:4):(t.strstart>t.block_start&&(yt(t,!1),t.strm.avail_out),1)})),new St(4,4,8,4,Zt),new St(4,5,16,8,Zt),new St(4,6,32,32,Zt),new St(4,4,16,16,Ut),new St(8,16,32,32,Ut),new St(8,16,128,128,Ut),new St(8,32,128,256,Ut),new St(32,128,258,1024,Ut),new St(32,258,258,4096,Ut)];function Tt(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=_t,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new Uint16Array(1146),this.dyn_dtree=new Uint16Array(122),this.bl_tree=new Uint16Array(78),mt(this.dyn_ltree),mt(this.dyn_dtree),mt(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new Uint16Array(16),this.heap=new Uint16Array(573),mt(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new Uint16Array(573),mt(this.depth),this.l_buf=0,this.lit_bufsize=0,this.last_lit=0,this.d_buf=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}const Ot=t=>{if(!t||!t.state)return gt(t,et);t.total_in=t.total_out=0,t.data_type=dt;const e=t.state;return e.pending=0,e.pending_out=0,e.wrap<0&&(e.wrap=-e.wrap),e.status=e.wrap?42:wt,t.adler=2===e.wrap?0:1,e.last_flush=W,K(e),$},It=t=>{const e=Ot(t);var a;return e===$&&((a=t.state).window_size=2*a.w_size,mt(a.head),a.max_lazy_match=Dt[a.level].max_lazy,a.good_match=Dt[a.level].good_length,a.nice_match=Dt[a.level].nice_length,a.max_chain_length=Dt[a.level].max_chain,a.strstart=0,a.block_start=0,a.lookahead=0,a.insert=0,a.match_length=a.prev_length=2,a.match_available=0,a.ins_h=0),e},Ft=(t,e,a,i,n,s)=>{if(!t)return et;let r=1;if(e===nt&&(e=6),i<0?(r=0,i=-i):i>15&&(r=2,i-=16),n<1||n>9||a!==_t||i<8||i>15||e<0||e>9||s<0||s>ot)return gt(t,et);8===i&&(i=9);const l=new Tt;return t.state=l,l.strm=t,l.wrap=r,l.gzhead=null,l.w_bits=i,l.w_size=1<Ft(t,e,_t,15,8,ht),deflateInit2:Ft,deflateReset:It,deflateResetKeep:Ot,deflateSetHeader:(t,e)=>t&&t.state?2!==t.state.wrap?et:(t.state.gzhead=e,$):et,deflate:(t,e)=>{let a,i;if(!t||!t.state||e>V||e<0)return t?gt(t,et):et;const n=t.state;if(!t.output||!t.input&&0!==t.avail_in||n.status===bt&&e!==Q)return gt(t,0===t.avail_out?it:et);n.strm=t;const s=n.last_flush;if(n.last_flush=e,42===n.status)if(2===n.wrap)t.adler=0,xt(n,31),xt(n,139),xt(n,8),n.gzhead?(xt(n,(n.gzhead.text?1:0)+(n.gzhead.hcrc?2:0)+(n.gzhead.extra?4:0)+(n.gzhead.name?8:0)+(n.gzhead.comment?16:0)),xt(n,255&n.gzhead.time),xt(n,n.gzhead.time>>8&255),xt(n,n.gzhead.time>>16&255),xt(n,n.gzhead.time>>24&255),xt(n,9===n.level?2:n.strategy>=rt||n.level<2?4:0),xt(n,255&n.gzhead.os),n.gzhead.extra&&n.gzhead.extra.length&&(xt(n,255&n.gzhead.extra.length),xt(n,n.gzhead.extra.length>>8&255)),n.gzhead.hcrc&&(t.adler=M(t.adler,n.pending_buf,n.pending,0)),n.gzindex=0,n.status=69):(xt(n,0),xt(n,0),xt(n,0),xt(n,0),xt(n,0),xt(n,9===n.level?2:n.strategy>=rt||n.level<2?4:0),xt(n,3),n.status=wt);else{let e=_t+(n.w_bits-8<<4)<<8,a=-1;a=n.strategy>=rt||n.level<2?0:n.level<6?1:6===n.level?2:3,e|=a<<6,0!==n.strstart&&(e|=32),e+=31-e%31,n.status=wt,zt(n,e),0!==n.strstart&&(zt(n,t.adler>>>16),zt(n,65535&t.adler)),t.adler=1}if(69===n.status)if(n.gzhead.extra){for(a=n.pending;n.gzindex<(65535&n.gzhead.extra.length)&&(n.pending!==n.pending_buf_size||(n.gzhead.hcrc&&n.pending>a&&(t.adler=M(t.adler,n.pending_buf,n.pending-a,a)),vt(t),a=n.pending,n.pending!==n.pending_buf_size));)xt(n,255&n.gzhead.extra[n.gzindex]),n.gzindex++;n.gzhead.hcrc&&n.pending>a&&(t.adler=M(t.adler,n.pending_buf,n.pending-a,a)),n.gzindex===n.gzhead.extra.length&&(n.gzindex=0,n.status=73)}else n.status=73;if(73===n.status)if(n.gzhead.name){a=n.pending;do{if(n.pending===n.pending_buf_size&&(n.gzhead.hcrc&&n.pending>a&&(t.adler=M(t.adler,n.pending_buf,n.pending-a,a)),vt(t),a=n.pending,n.pending===n.pending_buf_size)){i=1;break}i=n.gzindexa&&(t.adler=M(t.adler,n.pending_buf,n.pending-a,a)),0===i&&(n.gzindex=0,n.status=91)}else n.status=91;if(91===n.status)if(n.gzhead.comment){a=n.pending;do{if(n.pending===n.pending_buf_size&&(n.gzhead.hcrc&&n.pending>a&&(t.adler=M(t.adler,n.pending_buf,n.pending-a,a)),vt(t),a=n.pending,n.pending===n.pending_buf_size)){i=1;break}i=n.gzindexa&&(t.adler=M(t.adler,n.pending_buf,n.pending-a,a)),0===i&&(n.status=ut)}else n.status=ut;if(n.status===ut&&(n.gzhead.hcrc?(n.pending+2>n.pending_buf_size&&vt(t),n.pending+2<=n.pending_buf_size&&(xt(n,255&t.adler),xt(n,t.adler>>8&255),t.adler=0,n.status=wt)):n.status=wt),0!==n.pending){if(vt(t),0===t.avail_out)return n.last_flush=-1,$}else if(0===t.avail_in&&pt(e)<=pt(s)&&e!==Q)return gt(t,it);if(n.status===bt&&0!==t.avail_in)return gt(t,it);if(0!==t.avail_in||0!==n.lookahead||e!==W&&n.status!==bt){let a=n.strategy===rt?((t,e)=>{let a;for(;;){if(0===t.lookahead&&(Rt(t),0===t.lookahead)){if(e===W)return 1;break}if(t.match_length=0,a=G(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++,a&&(yt(t,!1),0===t.strm.avail_out))return 1}return t.insert=0,e===Q?(yt(t,!0),0===t.strm.avail_out?3:4):t.last_lit&&(yt(t,!1),0===t.strm.avail_out)?1:2})(n,e):n.strategy===lt?((t,e)=>{let a,i,n,s;const r=t.window;for(;;){if(t.lookahead<=ft){if(Rt(t),t.lookahead<=ft&&e===W)return 1;if(0===t.lookahead)break}if(t.match_length=0,t.lookahead>=3&&t.strstart>0&&(n=t.strstart-1,i=r[n],i===r[++n]&&i===r[++n]&&i===r[++n])){s=t.strstart+ft;do{}while(i===r[++n]&&i===r[++n]&&i===r[++n]&&i===r[++n]&&i===r[++n]&&i===r[++n]&&i===r[++n]&&i===r[++n]&&nt.lookahead&&(t.match_length=t.lookahead)}if(t.match_length>=3?(a=G(t,1,t.match_length-3),t.lookahead-=t.match_length,t.strstart+=t.match_length,t.match_length=0):(a=G(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++),a&&(yt(t,!1),0===t.strm.avail_out))return 1}return t.insert=0,e===Q?(yt(t,!0),0===t.strm.avail_out?3:4):t.last_lit&&(yt(t,!1),0===t.strm.avail_out)?1:2})(n,e):Dt[n.level].func(n,e);if(3!==a&&4!==a||(n.status=bt),1===a||3===a)return 0===t.avail_out&&(n.last_flush=-1),$;if(2===a&&(e===q?X(n):e!==V&&(P(n,0,0,!1),e===J&&(mt(n.head),0===n.lookahead&&(n.strstart=0,n.block_start=0,n.insert=0))),vt(t),0===t.avail_out))return n.last_flush=-1,$}return e!==Q?$:n.wrap<=0?tt:(2===n.wrap?(xt(n,255&t.adler),xt(n,t.adler>>8&255),xt(n,t.adler>>16&255),xt(n,t.adler>>24&255),xt(n,255&t.total_in),xt(n,t.total_in>>8&255),xt(n,t.total_in>>16&255),xt(n,t.total_in>>24&255)):(zt(n,t.adler>>>16),zt(n,65535&t.adler)),vt(t),n.wrap>0&&(n.wrap=-n.wrap),0!==n.pending?$:tt)},deflateEnd:t=>{if(!t||!t.state)return et;const e=t.state.status;return 42!==e&&69!==e&&73!==e&&91!==e&&e!==ut&&e!==wt&&e!==bt?gt(t,et):(t.state=null,e===wt?gt(t,at):$)},deflateSetDictionary:(t,e)=>{let a=e.length;if(!t||!t.state)return et;const i=t.state,n=i.wrap;if(2===n||1===n&&42!==i.status||i.lookahead)return et;if(1===n&&(t.adler=B(t.adler,e,a,0)),i.wrap=0,a>=i.w_size){0===n&&(mt(i.head),i.strstart=0,i.block_start=0,i.insert=0);let t=new Uint8Array(i.w_size);t.set(e.subarray(a-i.w_size,a),0),e=t,a=i.w_size}const s=t.avail_in,r=t.next_in,l=t.input;for(t.avail_in=a,t.next_in=0,t.input=e,Rt(i);i.lookahead>=3;){let t=i.strstart,e=i.lookahead-2;do{i.ins_h=kt(i,i.ins_h,i.window[t+3-1]),i.prev[t&i.w_mask]=i.head[i.ins_h],i.head[i.ins_h]=t,t++}while(--e);i.strstart=t,i.lookahead=2,Rt(i)}return i.strstart+=i.lookahead,i.block_start=i.strstart,i.insert=i.lookahead,i.lookahead=0,i.match_length=i.prev_length=2,i.match_available=0,t.next_in=r,t.input=l,t.avail_in=s,i.wrap=n,$},deflateInfo:"pako deflate (from Nodeca project)"};const Nt=(t,e)=>Object.prototype.hasOwnProperty.call(t,e);var Bt=function(t){const e=Array.prototype.slice.call(arguments,1);for(;e.length;){const a=e.shift();if(a){if("object"!=typeof a)throw new TypeError(a+"must be non-object");for(const e in a)Nt(a,e)&&(t[e]=a[e])}}return t},Ct=t=>{let e=0;for(let a=0,i=t.length;a=252?6:t>=248?5:t>=240?4:t>=224?3:t>=192?2:1;Ht[254]=Ht[254]=1;var jt=t=>{if("function"==typeof TextEncoder&&TextEncoder.prototype.encode)return(new TextEncoder).encode(t);let e,a,i,n,s,r=t.length,l=0;for(n=0;n>>6,e[s++]=128|63&a):a<65536?(e[s++]=224|a>>>12,e[s++]=128|a>>>6&63,e[s++]=128|63&a):(e[s++]=240|a>>>18,e[s++]=128|a>>>12&63,e[s++]=128|a>>>6&63,e[s++]=128|63&a);return e},Kt=(t,e)=>{const a=e||t.length;if("function"==typeof TextDecoder&&TextDecoder.prototype.decode)return(new TextDecoder).decode(t.subarray(0,e));let i,n;const s=new Array(2*a);for(n=0,i=0;i4)s[n++]=65533,i+=r-1;else{for(e&=2===r?31:3===r?15:7;r>1&&i1?s[n++]=65533:e<65536?s[n++]=e:(e-=65536,s[n++]=55296|e>>10&1023,s[n++]=56320|1023&e)}}return((t,e)=>{if(e<65534&&t.subarray&&Mt)return String.fromCharCode.apply(null,t.length===e?t:t.subarray(0,e));let a="";for(let i=0;i{(e=e||t.length)>t.length&&(e=t.length);let a=e-1;for(;a>=0&&128==(192&t[a]);)a--;return a<0||0===a?e:a+Ht[t[a]]>e?a:e};var Yt=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0};const Gt=Object.prototype.toString,{Z_NO_FLUSH:Xt,Z_SYNC_FLUSH:Wt,Z_FULL_FLUSH:qt,Z_FINISH:Jt,Z_OK:Qt,Z_STREAM_END:Vt,Z_DEFAULT_COMPRESSION:$t,Z_DEFAULT_STRATEGY:te,Z_DEFLATED:ee}=j;function ae(t){this.options=Bt({level:$t,method:ee,chunkSize:16384,windowBits:15,memLevel:8,strategy:te},t||{});let e=this.options;e.raw&&e.windowBits>0?e.windowBits=-e.windowBits:e.gzip&&e.windowBits>0&&e.windowBits<16&&(e.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new Yt,this.strm.avail_out=0;let a=Lt.deflateInit2(this.strm,e.level,e.method,e.windowBits,e.memLevel,e.strategy);if(a!==Qt)throw new Error(H[a]);if(e.header&&Lt.deflateSetHeader(this.strm,e.header),e.dictionary){let t;if(t="string"==typeof e.dictionary?jt(e.dictionary):"[object ArrayBuffer]"===Gt.call(e.dictionary)?new Uint8Array(e.dictionary):e.dictionary,a=Lt.deflateSetDictionary(this.strm,t),a!==Qt)throw new Error(H[a]);this._dict_set=!0}}function ie(t,e){const a=new ae(e);if(a.push(t,!0),a.err)throw a.msg||H[a.err];return a.result}ae.prototype.push=function(t,e){const a=this.strm,i=this.options.chunkSize;let n,s;if(this.ended)return!1;for(s=e===~~e?e:!0===e?Jt:Xt,"string"==typeof t?a.input=jt(t):"[object ArrayBuffer]"===Gt.call(t)?a.input=new Uint8Array(t):a.input=t,a.next_in=0,a.avail_in=a.input.length;;)if(0===a.avail_out&&(a.output=new Uint8Array(i),a.next_out=0,a.avail_out=i),(s===Wt||s===qt)&&a.avail_out<=6)this.onData(a.output.subarray(0,a.next_out)),a.avail_out=0;else{if(n=Lt.deflate(a,s),n===Vt)return a.next_out>0&&this.onData(a.output.subarray(0,a.next_out)),n=Lt.deflateEnd(this.strm),this.onEnd(n),this.ended=!0,n===Qt;if(0!==a.avail_out){if(s>0&&a.next_out>0)this.onData(a.output.subarray(0,a.next_out)),a.avail_out=0;else if(0===a.avail_in)break}else this.onData(a.output)}return!0},ae.prototype.onData=function(t){this.chunks.push(t)},ae.prototype.onEnd=function(t){t===Qt&&(this.result=Ct(this.chunks)),this.chunks=[],this.err=t,this.msg=this.strm.msg};var ne={Deflate:ae,deflate:ie,deflateRaw:function(t,e){return(e=e||{}).raw=!0,ie(t,e)},gzip:function(t,e){return(e=e||{}).gzip=!0,ie(t,e)},constants:j};var se=function(t,e){let a,i,n,s,r,l,o,h,d,_,f,c,u,w,b,g,p,m,k,v,y,x,z,A;const E=t.state;a=t.next_in,z=t.input,i=a+(t.avail_in-5),n=t.next_out,A=t.output,s=n-(e-t.avail_out),r=n+(t.avail_out-257),l=E.dmax,o=E.wsize,h=E.whave,d=E.wnext,_=E.window,f=E.hold,c=E.bits,u=E.lencode,w=E.distcode,b=(1<>>24,f>>>=m,c-=m,m=p>>>16&255,0===m)A[n++]=65535&p;else{if(!(16&m)){if(0==(64&m)){p=u[(65535&p)+(f&(1<>>=m,c-=m),c<15&&(f+=z[a++]<>>24,f>>>=m,c-=m,m=p>>>16&255,!(16&m)){if(0==(64&m)){p=w[(65535&p)+(f&(1<l){t.msg="invalid distance too far back",E.mode=30;break t}if(f>>>=m,c-=m,m=n-s,v>m){if(m=v-m,m>h&&E.sane){t.msg="invalid distance too far back",E.mode=30;break t}if(y=0,x=_,0===d){if(y+=o-m,m2;)A[n++]=x[y++],A[n++]=x[y++],A[n++]=x[y++],k-=3;k&&(A[n++]=x[y++],k>1&&(A[n++]=x[y++]))}else{y=n-v;do{A[n++]=A[y++],A[n++]=A[y++],A[n++]=A[y++],k-=3}while(k>2);k&&(A[n++]=A[y++],k>1&&(A[n++]=A[y++]))}break}}break}}while(a>3,a-=k,c-=k<<3,f&=(1<{const o=l.bits;let h,d,_,f,c,u,w=0,b=0,g=0,p=0,m=0,k=0,v=0,y=0,x=0,z=0,A=null,E=0;const R=new Uint16Array(16),Z=new Uint16Array(16);let U,S,D,T=null,O=0;for(w=0;w<=re;w++)R[w]=0;for(b=0;b=1&&0===R[p];p--);if(m>p&&(m=p),0===p)return n[s++]=20971520,n[s++]=20971520,l.bits=1,0;for(g=1;g0&&(0===t||1!==p))return-1;for(Z[1]=0,w=1;w852||2===t&&x>592)return 1;for(;;){U=w-v,r[b]u?(S=T[O+r[b]],D=A[E+r[b]]):(S=96,D=0),h=1<>v)+d]=U<<24|S<<16|D|0}while(0!==d);for(h=1<>=1;if(0!==h?(z&=h-1,z+=h):z=0,b++,0==--R[w]){if(w===p)break;w=e[a+r[b]]}if(w>m&&(z&f)!==_){for(0===v&&(v=m),c+=g,k=w-v,y=1<852||2===t&&x>592)return 1;_=z&f,n[_]=m<<24|k<<16|c-s|0}}return 0!==z&&(n[c+z]=w-v<<24|64<<16|0),l.bits=m,0};const{Z_FINISH:fe,Z_BLOCK:ce,Z_TREES:ue,Z_OK:we,Z_STREAM_END:be,Z_NEED_DICT:ge,Z_STREAM_ERROR:pe,Z_DATA_ERROR:me,Z_MEM_ERROR:ke,Z_BUF_ERROR:ve,Z_DEFLATED:ye}=j,xe=12,ze=30,Ae=t=>(t>>>24&255)+(t>>>8&65280)+((65280&t)<<8)+((255&t)<<24);function Ee(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new Uint16Array(320),this.work=new Uint16Array(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}const Re=t=>{if(!t||!t.state)return pe;const e=t.state;return t.total_in=t.total_out=e.total=0,t.msg="",e.wrap&&(t.adler=1&e.wrap),e.mode=1,e.last=0,e.havedict=0,e.dmax=32768,e.head=null,e.hold=0,e.bits=0,e.lencode=e.lendyn=new Int32Array(852),e.distcode=e.distdyn=new Int32Array(592),e.sane=1,e.back=-1,we},Ze=t=>{if(!t||!t.state)return pe;const e=t.state;return e.wsize=0,e.whave=0,e.wnext=0,Re(t)},Ue=(t,e)=>{let a;if(!t||!t.state)return pe;const i=t.state;return e<0?(a=0,e=-e):(a=1+(e>>4),e<48&&(e&=15)),e&&(e<8||e>15)?pe:(null!==i.window&&i.wbits!==e&&(i.window=null),i.wrap=a,i.wbits=e,Ze(t))},Se=(t,e)=>{if(!t)return pe;const a=new Ee;t.state=a,a.window=null;const i=Ue(t,e);return i!==we&&(t.state=null),i};let De,Te,Oe=!0;const Ie=t=>{if(Oe){De=new Int32Array(512),Te=new Int32Array(32);let e=0;for(;e<144;)t.lens[e++]=8;for(;e<256;)t.lens[e++]=9;for(;e<280;)t.lens[e++]=7;for(;e<288;)t.lens[e++]=8;for(_e(1,t.lens,0,288,De,0,t.work,{bits:9}),e=0;e<32;)t.lens[e++]=5;_e(2,t.lens,0,32,Te,0,t.work,{bits:5}),Oe=!1}t.lencode=De,t.lenbits=9,t.distcode=Te,t.distbits=5},Fe=(t,e,a,i)=>{let n;const s=t.state;return null===s.window&&(s.wsize=1<=s.wsize?(s.window.set(e.subarray(a-s.wsize,a),0),s.wnext=0,s.whave=s.wsize):(n=s.wsize-s.wnext,n>i&&(n=i),s.window.set(e.subarray(a-i,a-i+n),s.wnext),(i-=n)?(s.window.set(e.subarray(a-i,a),0),s.wnext=i,s.whave=s.wsize):(s.wnext+=n,s.wnext===s.wsize&&(s.wnext=0),s.whaveSe(t,15),inflateInit2:Se,inflate:(t,e)=>{let a,i,n,s,r,l,o,h,d,_,f,c,u,w,b,g,p,m,k,v,y,x,z=0;const A=new Uint8Array(4);let E,R;const Z=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]);if(!t||!t.state||!t.output||!t.input&&0!==t.avail_in)return pe;a=t.state,a.mode===xe&&(a.mode=13),r=t.next_out,n=t.output,o=t.avail_out,s=t.next_in,i=t.input,l=t.avail_in,h=a.hold,d=a.bits,_=l,f=o,x=we;t:for(;;)switch(a.mode){case 1:if(0===a.wrap){a.mode=13;break}for(;d<16;){if(0===l)break t;l--,h+=i[s++]<>>8&255,a.check=M(a.check,A,2,0),h=0,d=0,a.mode=2;break}if(a.flags=0,a.head&&(a.head.done=!1),!(1&a.wrap)||(((255&h)<<8)+(h>>8))%31){t.msg="incorrect header check",a.mode=ze;break}if((15&h)!==ye){t.msg="unknown compression method",a.mode=ze;break}if(h>>>=4,d-=4,y=8+(15&h),0===a.wbits)a.wbits=y;else if(y>a.wbits){t.msg="invalid window size",a.mode=ze;break}a.dmax=1<>8&1),512&a.flags&&(A[0]=255&h,A[1]=h>>>8&255,a.check=M(a.check,A,2,0)),h=0,d=0,a.mode=3;case 3:for(;d<32;){if(0===l)break t;l--,h+=i[s++]<>>8&255,A[2]=h>>>16&255,A[3]=h>>>24&255,a.check=M(a.check,A,4,0)),h=0,d=0,a.mode=4;case 4:for(;d<16;){if(0===l)break t;l--,h+=i[s++]<>8),512&a.flags&&(A[0]=255&h,A[1]=h>>>8&255,a.check=M(a.check,A,2,0)),h=0,d=0,a.mode=5;case 5:if(1024&a.flags){for(;d<16;){if(0===l)break t;l--,h+=i[s++]<>>8&255,a.check=M(a.check,A,2,0)),h=0,d=0}else a.head&&(a.head.extra=null);a.mode=6;case 6:if(1024&a.flags&&(c=a.length,c>l&&(c=l),c&&(a.head&&(y=a.head.extra_len-a.length,a.head.extra||(a.head.extra=new Uint8Array(a.head.extra_len)),a.head.extra.set(i.subarray(s,s+c),y)),512&a.flags&&(a.check=M(a.check,i,c,s)),l-=c,s+=c,a.length-=c),a.length))break t;a.length=0,a.mode=7;case 7:if(2048&a.flags){if(0===l)break t;c=0;do{y=i[s+c++],a.head&&y&&a.length<65536&&(a.head.name+=String.fromCharCode(y))}while(y&&c>9&1,a.head.done=!0),t.adler=a.check=0,a.mode=xe;break;case 10:for(;d<32;){if(0===l)break t;l--,h+=i[s++]<>>=7&d,d-=7&d,a.mode=27;break}for(;d<3;){if(0===l)break t;l--,h+=i[s++]<>>=1,d-=1,3&h){case 0:a.mode=14;break;case 1:if(Ie(a),a.mode=20,e===ue){h>>>=2,d-=2;break t}break;case 2:a.mode=17;break;case 3:t.msg="invalid block type",a.mode=ze}h>>>=2,d-=2;break;case 14:for(h>>>=7&d,d-=7&d;d<32;){if(0===l)break t;l--,h+=i[s++]<>>16^65535)){t.msg="invalid stored block lengths",a.mode=ze;break}if(a.length=65535&h,h=0,d=0,a.mode=15,e===ue)break t;case 15:a.mode=16;case 16:if(c=a.length,c){if(c>l&&(c=l),c>o&&(c=o),0===c)break t;n.set(i.subarray(s,s+c),r),l-=c,s+=c,o-=c,r+=c,a.length-=c;break}a.mode=xe;break;case 17:for(;d<14;){if(0===l)break t;l--,h+=i[s++]<>>=5,d-=5,a.ndist=1+(31&h),h>>>=5,d-=5,a.ncode=4+(15&h),h>>>=4,d-=4,a.nlen>286||a.ndist>30){t.msg="too many length or distance symbols",a.mode=ze;break}a.have=0,a.mode=18;case 18:for(;a.have>>=3,d-=3}for(;a.have<19;)a.lens[Z[a.have++]]=0;if(a.lencode=a.lendyn,a.lenbits=7,E={bits:a.lenbits},x=_e(0,a.lens,0,19,a.lencode,0,a.work,E),a.lenbits=E.bits,x){t.msg="invalid code lengths set",a.mode=ze;break}a.have=0,a.mode=19;case 19:for(;a.have>>24,g=z>>>16&255,p=65535&z,!(b<=d);){if(0===l)break t;l--,h+=i[s++]<>>=b,d-=b,a.lens[a.have++]=p;else{if(16===p){for(R=b+2;d>>=b,d-=b,0===a.have){t.msg="invalid bit length repeat",a.mode=ze;break}y=a.lens[a.have-1],c=3+(3&h),h>>>=2,d-=2}else if(17===p){for(R=b+3;d>>=b,d-=b,y=0,c=3+(7&h),h>>>=3,d-=3}else{for(R=b+7;d>>=b,d-=b,y=0,c=11+(127&h),h>>>=7,d-=7}if(a.have+c>a.nlen+a.ndist){t.msg="invalid bit length repeat",a.mode=ze;break}for(;c--;)a.lens[a.have++]=y}}if(a.mode===ze)break;if(0===a.lens[256]){t.msg="invalid code -- missing end-of-block",a.mode=ze;break}if(a.lenbits=9,E={bits:a.lenbits},x=_e(1,a.lens,0,a.nlen,a.lencode,0,a.work,E),a.lenbits=E.bits,x){t.msg="invalid literal/lengths set",a.mode=ze;break}if(a.distbits=6,a.distcode=a.distdyn,E={bits:a.distbits},x=_e(2,a.lens,a.nlen,a.ndist,a.distcode,0,a.work,E),a.distbits=E.bits,x){t.msg="invalid distances set",a.mode=ze;break}if(a.mode=20,e===ue)break t;case 20:a.mode=21;case 21:if(l>=6&&o>=258){t.next_out=r,t.avail_out=o,t.next_in=s,t.avail_in=l,a.hold=h,a.bits=d,se(t,f),r=t.next_out,n=t.output,o=t.avail_out,s=t.next_in,i=t.input,l=t.avail_in,h=a.hold,d=a.bits,a.mode===xe&&(a.back=-1);break}for(a.back=0;z=a.lencode[h&(1<>>24,g=z>>>16&255,p=65535&z,!(b<=d);){if(0===l)break t;l--,h+=i[s++]<>m)],b=z>>>24,g=z>>>16&255,p=65535&z,!(m+b<=d);){if(0===l)break t;l--,h+=i[s++]<>>=m,d-=m,a.back+=m}if(h>>>=b,d-=b,a.back+=b,a.length=p,0===g){a.mode=26;break}if(32&g){a.back=-1,a.mode=xe;break}if(64&g){t.msg="invalid literal/length code",a.mode=ze;break}a.extra=15&g,a.mode=22;case 22:if(a.extra){for(R=a.extra;d>>=a.extra,d-=a.extra,a.back+=a.extra}a.was=a.length,a.mode=23;case 23:for(;z=a.distcode[h&(1<>>24,g=z>>>16&255,p=65535&z,!(b<=d);){if(0===l)break t;l--,h+=i[s++]<>m)],b=z>>>24,g=z>>>16&255,p=65535&z,!(m+b<=d);){if(0===l)break t;l--,h+=i[s++]<>>=m,d-=m,a.back+=m}if(h>>>=b,d-=b,a.back+=b,64&g){t.msg="invalid distance code",a.mode=ze;break}a.offset=p,a.extra=15&g,a.mode=24;case 24:if(a.extra){for(R=a.extra;d>>=a.extra,d-=a.extra,a.back+=a.extra}if(a.offset>a.dmax){t.msg="invalid distance too far back",a.mode=ze;break}a.mode=25;case 25:if(0===o)break t;if(c=f-o,a.offset>c){if(c=a.offset-c,c>a.whave&&a.sane){t.msg="invalid distance too far back",a.mode=ze;break}c>a.wnext?(c-=a.wnext,u=a.wsize-c):u=a.wnext-c,c>a.length&&(c=a.length),w=a.window}else w=n,u=r-a.offset,c=a.length;c>o&&(c=o),o-=c,a.length-=c;do{n[r++]=w[u++]}while(--c);0===a.length&&(a.mode=21);break;case 26:if(0===o)break t;n[r++]=a.length,o--,a.mode=21;break;case 27:if(a.wrap){for(;d<32;){if(0===l)break t;l--,h|=i[s++]<{if(!t||!t.state)return pe;let e=t.state;return e.window&&(e.window=null),t.state=null,we},inflateGetHeader:(t,e)=>{if(!t||!t.state)return pe;const a=t.state;return 0==(2&a.wrap)?pe:(a.head=e,e.done=!1,we)},inflateSetDictionary:(t,e)=>{const a=e.length;let i,n,s;return t&&t.state?(i=t.state,0!==i.wrap&&11!==i.mode?pe:11===i.mode&&(n=1,n=B(n,e,a,0),n!==i.check)?me:(s=Fe(t,e,a,a),s?(i.mode=31,ke):(i.havedict=1,we))):pe},inflateInfo:"pako inflate (from Nodeca project)"};var Ne=function(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1};const Be=Object.prototype.toString,{Z_NO_FLUSH:Ce,Z_FINISH:Me,Z_OK:He,Z_STREAM_END:je,Z_NEED_DICT:Ke,Z_STREAM_ERROR:Pe,Z_DATA_ERROR:Ye,Z_MEM_ERROR:Ge}=j;function Xe(t){this.options=Bt({chunkSize:65536,windowBits:15,to:""},t||{});const e=this.options;e.raw&&e.windowBits>=0&&e.windowBits<16&&(e.windowBits=-e.windowBits,0===e.windowBits&&(e.windowBits=-15)),!(e.windowBits>=0&&e.windowBits<16)||t&&t.windowBits||(e.windowBits+=32),e.windowBits>15&&e.windowBits<48&&0==(15&e.windowBits)&&(e.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new Yt,this.strm.avail_out=0;let a=Le.inflateInit2(this.strm,e.windowBits);if(a!==He)throw new Error(H[a]);if(this.header=new Ne,Le.inflateGetHeader(this.strm,this.header),e.dictionary&&("string"==typeof e.dictionary?e.dictionary=jt(e.dictionary):"[object ArrayBuffer]"===Be.call(e.dictionary)&&(e.dictionary=new Uint8Array(e.dictionary)),e.raw&&(a=Le.inflateSetDictionary(this.strm,e.dictionary),a!==He)))throw new Error(H[a])}function We(t,e){const a=new Xe(e);if(a.push(t),a.err)throw a.msg||H[a.err];return a.result}Xe.prototype.push=function(t,e){const a=this.strm,i=this.options.chunkSize,n=this.options.dictionary;let s,r,l;if(this.ended)return!1;for(r=e===~~e?e:!0===e?Me:Ce,"[object ArrayBuffer]"===Be.call(t)?a.input=new Uint8Array(t):a.input=t,a.next_in=0,a.avail_in=a.input.length;;){for(0===a.avail_out&&(a.output=new Uint8Array(i),a.next_out=0,a.avail_out=i),s=Le.inflate(a,r),s===Ke&&n&&(s=Le.inflateSetDictionary(a,n),s===He?s=Le.inflate(a,r):s===Ye&&(s=Ke));a.avail_in>0&&s===je&&a.state.wrap>0&&0!==t[a.next_in];)Le.inflateReset(a),s=Le.inflate(a,r);switch(s){case Pe:case Ye:case Ke:case Ge:return this.onEnd(s),this.ended=!0,!1}if(l=a.avail_out,a.next_out&&(0===a.avail_out||s===je))if("string"===this.options.to){let t=Pt(a.output,a.next_out),e=a.next_out-t,n=Kt(a.output,t);a.next_out=e,a.avail_out=i-e,e&&a.output.set(a.output.subarray(t,t+e),0),this.onData(n)}else this.onData(a.output.length===a.next_out?a.output:a.output.subarray(0,a.next_out));if(s!==He||0!==l){if(s===je)return s=Le.inflateEnd(this.strm),this.onEnd(s),this.ended=!0,!0;if(0===a.avail_in)break}}return!0},Xe.prototype.onData=function(t){this.chunks.push(t)},Xe.prototype.onEnd=function(t){t===He&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=Ct(this.chunks)),this.chunks=[],this.err=t,this.msg=this.strm.msg};var qe={Inflate:Xe,inflate:We,inflateRaw:function(t,e){return(e=e||{}).raw=!0,We(t,e)},ungzip:We,constants:j};const{Deflate:Je,deflate:Qe,deflateRaw:Ve,gzip:$e}=ne,{Inflate:ta,inflate:ea,inflateRaw:aa,ungzip:ia}=qe;var na=Je,sa=Qe,ra=Ve,la=$e,oa=ta,ha=ea,da=aa,_a=ia,fa=j,ca={Deflate:na,deflate:sa,deflateRaw:ra,gzip:la,Inflate:oa,inflate:ha,inflateRaw:da,ungzip:_a,constants:fa};t.Deflate=na,t.Inflate=oa,t.constants=fa,t.default=ca,t.deflate=sa,t.deflateRaw=ra,t.gzip=la,t.inflate=ha,t.inflateRaw=da,t.ungzip=_a,Object.defineProperty(t,"__esModule",{value:!0})})); /****************** initialization finish ******************/ - // 先拆分B站gRPC校验头和protobuf数据体 + // 先拆分B站gRPC校验头和protobuf数据体 let header = rawBody.slice(0, 5); body = rawBody.slice(5); // 处理response压缩protobuf数据体 @@ -361,19 +366,19 @@ const DataBase = { switch (HOST) { case "grpc.biliapi.net": // HTTP/2 case "app.bilibili.com": // HTTP/1.1 - /****************** initialization start *******************/ + /****************** initialization start *******************/ // google.protobuf.Any - class Any$Type extends MessageType{constructor(){super("google.protobuf.Any",[{no:1,name:"type_url",kind:"scalar",T:9},{no:2,name:"value",kind:"scalar",T:12}])}pack(message,type){return{typeUrl:this.typeNameToUrl(type.typeName),value:type.toBinary(message),}}unpack(any,type,options){if(!this.contains(any,type))throw new Error("Cannot unpack google.protobuf.Any with typeUrl '"+any.typeUrl+"' as "+type.typeName+".");return type.fromBinary(any.value,options)}contains(any,type){if(!any.typeUrl.length)return false;let wants=typeof type=="string"?type:type.typeName;let has=this.typeUrlToName(any.typeUrl);return wants===has}internalJsonWrite(any,options){if(any.typeUrl==="")return{};let typeName=this.typeUrlToName(any.typeUrl);let opt=jsonWriteOptions(options);let type=opt.typeRegistry?.find(t=>t.typeName===typeName);if(!type)throw new globalThis.Error("Unable to convert google.protobuf.Any with typeUrl '"+any.typeUrl+"' to JSON. The specified type "+typeName+" is not available in the type registry.");let value=type.fromBinary(any.value,{readUnknownField:false});let json=type.internalJsonWrite(value,opt);if(typeName.startsWith("google.protobuf.")||!isJsonObject(json))json={value:json};json["@type"]=any.typeUrl;return json}internalJsonRead(json,options,target){if(!isJsonObject(json))throw new globalThis.Error("Unable to parse google.protobuf.Any from JSON "+typeofJsonValue(json)+".");if(typeof json["@type"]!="string"||json["@type"]=="")return this.create();let typeName=this.typeUrlToName(json["@type"]);let type=options?.typeRegistry?.find(t=>t.typeName==typeName);if(!type)throw new globalThis.Error("Unable to parse google.protobuf.Any from JSON. The specified type "+typeName+" is not available in the type registry.");let value;if(typeName.startsWith("google.protobuf.")&&json.hasOwnProperty("value"))value=type.fromJson(json["value"],options);else{let copy=Object.assign({},json);delete copy["@type"];value=type.fromJson(copy,options)}if(target===undefined)target=this.create();target.typeUrl=json["@type"];target.value=type.toBinary(value);return target}typeNameToUrl(name){if(!name.length)throw new Error("invalid type name: "+name);return"type.googleapis.com/"+name}typeUrlToName(url){if(!url.length)throw new Error("invalid type url: "+url);let slash=url.lastIndexOf("/");let name=slash>0?url.substring(slash+1):url;if(!name.length)throw new Error("invalid type url: "+url);return name}create(value){const message={typeUrl:"",value:new Uint8Array(0)};globalThis.Object.defineProperty(message,MESSAGE_TYPE,{enumerable:false,value:this});if(value!==undefined)reflectionMergePartial(this,message,value);return message}internalBinaryRead(reader,length,options,target){let message=target??this.create(),end=reader.pos+length;while(reader.post.typeName===typeName);if(!type)throw new globalThis.Error("Unable to convert google.protobuf.Any with typeUrl '"+any.typeUrl+"' to JSON. The specified type "+typeName+" is not available in the type registry.");let value=type.fromBinary(any.value,{readUnknownField:false});let json=type.internalJsonWrite(value,opt);if(typeName.startsWith("google.protobuf.")||!isJsonObject(json))json={value:json};json["@type"]=any.typeUrl;return json}internalJsonRead(json,options,target){if(!isJsonObject(json))throw new globalThis.Error("Unable to parse google.protobuf.Any from JSON "+typeofJsonValue(json)+".");if(typeof json["@type"]!="string"||json["@type"]=="")return this.create();let typeName=this.typeUrlToName(json["@type"]);let type=options?.typeRegistry?.find(t=>t.typeName==typeName);if(!type)throw new globalThis.Error("Unable to parse google.protobuf.Any from JSON. The specified type "+typeName+" is not available in the type registry.");let value;if(typeName.startsWith("google.protobuf.")&&json.hasOwnProperty("value"))value=type.fromJson(json["value"],options);else{let copy=Object.assign({},json);delete copy["@type"];value=type.fromJson(copy,options)}if(target===undefined)target=this.create();target.typeUrl=json["@type"];target.value=type.toBinary(value);return target}typeNameToUrl(name){if(!name.length)throw new Error("invalid type name: "+name);return"type.googleapis.com/"+name}typeUrlToName(url){if(!url.length)throw new Error("invalid type url: "+url);let slash=url.lastIndexOf("/");let name=slash>0?url.substring(slash+1):url;if(!name.length)throw new Error("invalid type url: "+url);return name}create(value){const message={typeUrl:"",value:new Uint8Array(0)};globalThis.Object.defineProperty(message,MESSAGE_TYPE,{enumerable:false,value:this});if(value!==undefined)reflectionMergePartial(this,message,value);return message}internalBinaryRead(reader,length,options,target){let message=target??this.create(),end=reader.pos+length;while(reader.posAny}])}create(value){const message={};globalThis.Object.defineProperty(message,MESSAGE_TYPE,{enumerable:false,value:this});if(value!==undefined)reflectionMergePartial(this,message,value);return message}internalBinaryRead(reader,length,options,target){let message=target??this.create(),end=reader.pos+length;while(reader.posAny}])}create(value){const message={};globalThis.Object.defineProperty(message,MESSAGE_TYPE,{enumerable:false,value:this});if(value!==undefined)reflectionMergePartial(this,message,value);return message}internalBinaryRead(reader,length,options,target){let message=target??this.create(),end=reader.pos+length;while(reader.posPlayArcConf}])}create(value){const message={};globalThis.Object.defineProperty(message,MESSAGE_TYPE,{enumerable:false,value:this});if(value!==undefined)reflectionMergePartial(this,message,value);return message}internalBinaryRead(reader,length,options,target){let message=target??this.create(),end=reader.pos+length;while(reader.posArcConf}])}create(value){const message={};globalThis.Object.defineProperty(message,MESSAGE_TYPE,{enumerable:false,value:this});if(value!==undefined)reflectionMergePartial(this,message,value);return message}internalBinaryRead(reader,length,options,target){let message=target??this.create(),end=reader.pos+length;while(reader.posExtraContent}])}create(value){const message={isSupport:false,disabled:false};globalThis.Object.defineProperty(message,MESSAGE_TYPE,{enumerable:false,value:this});if(value!==undefined)reflectionMergePartial(this,message,value);return message}internalBinaryRead(reader,length,options,target){let message=target??this.create(),end=reader.pos+length;while(reader.posPlayArcConf}])}create(value){const message={};globalThis.Object.defineProperty(message,MESSAGE_TYPE,{enumerable:false,value:this});if(value!==undefined)reflectionMergePartial(this,message,value);return message}internalBinaryRead(reader,length,options,target){let message=target??this.create(),end=reader.pos+length;while(reader.posArcConf}])}create(value){const message={};globalThis.Object.defineProperty(message,MESSAGE_TYPE,{enumerable:false,value:this});if(value!==undefined)reflectionMergePartial(this,message,value);return message}internalBinaryRead(reader,length,options,target){let message=target??this.create(),end=reader.pos+length;while(reader.posExtraContent}])}create(value){const message={isSupport:false,disabled:false};globalThis.Object.defineProperty(message,MESSAGE_TYPE,{enumerable:false,value:this});if(value!==undefined)reflectionMergePartial(this,message,value);return message}internalBinaryRead(reader,length,options,target){let message=target??this.create(),end=reader.pos+length;while(reader.posDynamicList},{no:2,name:"up_list",kind:"message",T:()=>CardVideoUpList},{no:3,name:"topic_list",kind:"message",T:()=>TopicList}])}create(value){const message={};globalThis.Object.defineProperty(message,MESSAGE_TYPE,{enumerable:false,value:this});if(value!==undefined)reflectionMergePartial(this,message,value);return message}internalBinaryRead(reader,length,options,target){let message=target??this.create(),end=reader.pos+length;while(reader.posCardVideoUpList}])}create(value){const message={};globalThis.Object.defineProperty(message,MESSAGE_TYPE,{enumerable:false,value:this});if(value!==undefined)reflectionMergePartial(this,message,value);return message}internalBinaryRead(reader,length,options,target){let message=target??this.create(),end=reader.pos+length;while(reader.posDynamicItem}])}create(value){const message={list:[]};globalThis.Object.defineProperty(message,MESSAGE_TYPE,{enumerable:false,value:this});if(value!==undefined)reflectionMergePartial(this,message,value);return message}internalBinaryRead(reader,length,options,target){let message=target??this.create(),end=reader.pos+length;while(reader.pos["DynamicType",DynamicType]}])}create(value){const message={cardType:0};globalThis.Object.defineProperty(message,MESSAGE_TYPE,{enumerable:false,value:this});if(value!==undefined)reflectionMergePartial(this,message,value);return message}internalBinaryRead(reader,length,options,target){let message=target??this.create(),end=reader.pos+length;while(reader.posTIcon}},{no:10,name:"relates",kind:"message",repeat:1,T:()=>Relate},{no:30,name:"cms",kind:"message",repeat:1,T:()=>CM},{no:31,name:"cm_config",kind:"message",T:()=>CMConfig},{no:41,name:"cm_ipad",kind:"message",T:()=>CmIpad}])}create(value){const message={tIcon:{},relates:[],cms:[]};globalThis.Object.defineProperty(message,MESSAGE_TYPE,{enumerable:false,value:this});if(value!==undefined)reflectionMergePartial(this,message,value);return message}internalBinaryRead(reader,length,options,target){let message=target??this.create(),end=reader.pos+length;while(reader.posAny}])}create(value){const message={};globalThis.Object.defineProperty(message,MESSAGE_TYPE,{enumerable:false,value:this});if(value!==undefined)reflectionMergePartial(this,message,value);return message}internalBinaryRead(reader,length,options,target){let message=target??this.create(),end=reader.pos+length;while(reader.posAny}])}create(value){const message={};globalThis.Object.defineProperty(message,MESSAGE_TYPE,{enumerable:false,value:this});if(value!==undefined)reflectionMergePartial(this,message,value);return message}internalBinaryRead(reader,length,options,target){let message=target??this.create(),end=reader.pos+length;while(reader.posCM}])}create(value){const message={};globalThis.Object.defineProperty(message,MESSAGE_TYPE,{enumerable:false,value:this});if(value!==undefined)reflectionMergePartial(this,message,value);return message}internalBinaryRead(reader,length,options,target){let message=target??this.create(),end=reader.pos+length;while(reader.posTIcon}},{no:10,name:"relates",kind:"message",repeat:1,T:()=>Relate},{no:30,name:"cms",kind:"message",repeat:1,T:()=>CM},{no:31,name:"cm_config",kind:"message",T:()=>CMConfig},{no:41,name:"cm_ipad",kind:"message",T:()=>CmIpad}])}create(value){const message={tIcon:{},relates:[],cms:[]};globalThis.Object.defineProperty(message,MESSAGE_TYPE,{enumerable:false,value:this});if(value!==undefined)reflectionMergePartial(this,message,value);return message}internalBinaryRead(reader,length,options,target){let message=target??this.create(),end=reader.pos+length;while(reader.posAny}])}create(value){const message={};globalThis.Object.defineProperty(message,MESSAGE_TYPE,{enumerable:false,value:this});if(value!==undefined)reflectionMergePartial(this,message,value);return message}internalBinaryRead(reader,length,options,target){let message=target??this.create(),end=reader.pos+length;while(reader.posCM}])}create(value){const message={};globalThis.Object.defineProperty(message,MESSAGE_TYPE,{enumerable:false,value:this});if(value!==undefined)reflectionMergePartial(this,message,value);return message}internalBinaryRead(reader,length,options,target){let message=target??this.create(),end=reader.pos+length;while(reader.posTFToast},{no:3,name:"tfPanelCustomized",kind:"message",T:()=>TFPanelCustomized}])}create(value){const message={tipsId:0n};globalThis.Object.defineProperty(message,MESSAGE_TYPE,{enumerable:false,value:this});if(value!==undefined)reflectionMergePartial(this,message,value);return message}internalBinaryRead(reader,length,options,target){let message=target??this.create(),end=reader.pos+length;while(reader.posTFToast},{no:3,name:"tfPanelCustomized",kind:"message",T:()=>TFPanelCustomized}])}create(value){const message={tipsId:0n};globalThis.Object.defineProperty(message,MESSAGE_TYPE,{enumerable:false,value:this});if(value!==undefined)reflectionMergePartial(this,message,value);return message}internalBinaryRead(reader,length,options,target){let message=target??this.create(),end=reader.pos+length;while(reader.posTab},{no:7,name:"cm",kind:"message",T:()=>CM}])}create(value){const message={};globalThis.Object.defineProperty(message,MESSAGE_TYPE,{enumerable:false,value:this});if(value!==undefined)reflectionMergePartial(this,message,value);return message}internalBinaryRead(reader,length,options,target){let message=target??this.create(),end=reader.pos+length;while(reader.posTabModule}])}create(value){const message={tabModule:[]};globalThis.Object.defineProperty(message,MESSAGE_TYPE,{enumerable:false,value:this});if(value!==undefined)reflectionMergePartial(this,message,value);return message}internalBinaryRead(reader,length,options,target){let message=target??this.create(),end=reader.pos+length;while(reader.posIntroductionTab}])}create(value){const message={tab:{oneofKind:undefined}};globalThis.Object.defineProperty(message,MESSAGE_TYPE,{enumerable:false,value:this});if(value!==undefined)reflectionMergePartial(this,message,value);return message}internalBinaryRead(reader,length,options,target){let message=target??this.create(),end=reader.pos+length;while(reader.posModule}])}create(value){const message={modules:[]};globalThis.Object.defineProperty(message,MESSAGE_TYPE,{enumerable:false,value:this});if(value!==undefined)reflectionMergePartial(this,message,value);return message}internalBinaryRead(reader,length,options,target){let message=target??this.create(),end=reader.pos+length;while(reader.posRelates}])}create(value){const message={type:0,data:{oneofKind:undefined}};globalThis.Object.defineProperty(message,MESSAGE_TYPE,{enumerable:false,value:this});if(value!==undefined)reflectionMergePartial(this,message,value);return message}internalBinaryRead(reader,length,options,target){let message=target??this.create(),end=reader.pos+length;while(reader.posRelateCard}])}create(value){const message={cards:[]};globalThis.Object.defineProperty(message,MESSAGE_TYPE,{enumerable:false,value:this});if(value!==undefined)reflectionMergePartial(this,message,value);return message}internalBinaryRead(reader,length,options,target){let message=target??this.create(),end=reader.pos+length;while(reader.posAny}])}create(value){const message={sourceContent:[]};globalThis.Object.defineProperty(message,MESSAGE_TYPE,{enumerable:false,value:this});if(value!==undefined)reflectionMergePartial(this,message,value);return message}internalBinaryRead(reader,length,options,target){let message=target??this.create(),end=reader.pos+length;while(reader.pos { + if (i.type === 28){ + i.data.relates.cards = i.data.relates.cards.filter((j) => j.relateCardType !== 5); + $.log(`🎉 ${$.name}`, "视频详情下方推荐卡广告去除"); + } + return i; + } + ); + body = ViewReply.toBinary(data); + break; + case false: + $.log(`🚧 ${$.name}`, "用户设置up主推荐广告不去除"); + break; + }; + break; + } + break; case "bilibili.app.interface.v1.Teenagers": // 青少年模式 - class ModeStatus$Type extends MessageType{constructor(){super("ModeStatus",[{no:1,name:"modes",kind:"message",repeat:1,T:()=>Mode}])}create(value){const message={modes:[]};globalThis.Object.defineProperty(message,MESSAGE_TYPE,{enumerable:false,value:this});if(value!==undefined)reflectionMergePartial(this,message,value);return message}internalBinaryRead(reader,length,options,target){let message=target??this.create(),end=reader.pos+length;while(reader.posF5}])}create(value){const message={name:""};globalThis.Object.defineProperty(message,MESSAGE_TYPE,{enumerable:false,value:this});if(value!==undefined)reflectionMergePartial(this,message,value);return message}internalBinaryRead(reader,length,options,target){let message=target??this.create(),end=reader.pos+length;while(reader.posMode}])}create(value){const message={modes:[]};globalThis.Object.defineProperty(message,MESSAGE_TYPE,{enumerable:false,value:this});if(value!==undefined)reflectionMergePartial(this,message,value);return message}internalBinaryRead(reader,length,options,target){let message=target??this.create(),end=reader.pos+length;while(reader.posF5}])}create(value){const message={name:""};globalThis.Object.defineProperty(message,MESSAGE_TYPE,{enumerable:false,value:this});if(value!==undefined)reflectionMergePartial(this,message,value);return message}internalBinaryRead(reader,length,options,target){let message=target??this.create(),end=reader.pos+length;while(reader.pos { if (mode?.name === "teenagers") { if (mode?.f5?.f1) { @@ -540,7 +580,10 @@ const DataBase = { }; break; case "bilibili.community.service.dm.v1.DM": //弹幕 - class CommandDm$Type extends MessageType{constructor(){super("CommandDm",[{no:1,name:"id",kind:"scalar",T:3,L:0}])}create(value){const message={id:0n};globalThis.Object.defineProperty(message,MESSAGE_TYPE,{enumerable:false,value:this});if(value!==undefined)reflectionMergePartial(this,message,value);return message}internalBinaryRead(reader,length,options,target){let message=target??this.create(),end=reader.pos+length;while(reader.posCommandDm}])}create(value){const message={commandDms:[]};globalThis.Object.defineProperty(message,MESSAGE_TYPE,{enumerable:false,value:this});if(value!==undefined)reflectionMergePartial(this,message,value);return message}internalBinaryRead(reader,length,options,target){let message=target??this.create(),end=reader.pos+length;while(reader.posDmView}])}create(value){const message={};globalThis.Object.defineProperty(message,MESSAGE_TYPE,{enumerable:false,value:this});if(value!==undefined)reflectionMergePartial(this,message,value);return message}internalBinaryRead(reader,length,options,target){let message=target??this.create(),end=reader.pos+length;while(reader.posDanmakuElem}])}create(value){const message={elems:[]};globalThis.Object.defineProperty(message,MESSAGE_TYPE,{enumerable:false,value:this});if(value!==undefined)reflectionMergePartial(this,message,value);return message}internalBinaryRead(reader,length,options,target){let message=target??this.create(),end=reader.pos+length;while(reader.posCommandDm}])}create(value){const message={commandDms:[]};globalThis.Object.defineProperty(message,MESSAGE_TYPE,{enumerable:false,value:this});if(value!==undefined)reflectionMergePartial(this,message,value);return message}internalBinaryRead(reader,length,options,target){let message=target??this.create(),end=reader.pos+length;while(reader.posDmView}])}create(value){const message={};globalThis.Object.defineProperty(message,MESSAGE_TYPE,{enumerable:false,value:this});if(value!==undefined)reflectionMergePartial(this,message,value);return message}internalBinaryRead(reader,length,options,target){let message=target??this.create(),end=reader.pos+length;while(reader.posDanmakuElem}])}create(value){const message={elems:[]};globalThis.Object.defineProperty(message,MESSAGE_TYPE,{enumerable:false,value:this});if(value!==undefined)reflectionMergePartial(this,message,value);return message}internalBinaryRead(reader,length,options,target){let message=target??this.create(),end=reader.pos+length;while(reader.posCM}])}create(value){const message={};globalThis.Object.defineProperty(message,MESSAGE_TYPE,{enumerable:false,value:this});if(value!==undefined)reflectionMergePartial(this,message,value);return message}internalBinaryRead(reader,length,options,target){let message=target??this.create(),end=reader.pos+length;while(reader.posCM}])}create(value){const message={};globalThis.Object.defineProperty(message,MESSAGE_TYPE,{enumerable:false,value:this});if(value!==undefined)reflectionMergePartial(this,message,value);return message}internalBinaryRead(reader,length,options,target){let message=target??this.create(),end=reader.pos+length;while(reader.pos { - if (value === "true" || value === "false") value = JSON.parse(value); // 字符串转Boolean - else if (typeof value === "string") { - if (value?.includes(",")) value = value.split(","); // 字符串转数组 - else if (!isNaN(value)) value = parseInt(value, 10) // 字符串转数字 - }; - return value; - }); +function setENV(name, platforms, database) { + $.log(`☑️ ${$.name}, Set Environment Variables`, ""); + let { Settings, Caches, Configs } = getENV(name, platforms, database); + /***************** Settings *****************/ $.log(`✅ ${$.name}, Set Environment Variables`, `Settings: ${typeof Settings}`, `Settings内容: ${JSON.stringify(Settings)}`, ""); /***************** Caches *****************/ //$.log(`✅ ${$.name}, Set Environment Variables`, `Caches: ${typeof Caches}`, `Caches内容: ${JSON.stringify(Caches)}`, ""); /***************** Configs *****************/ return { Settings, Caches, Configs }; - - function traverseObject(o,c){for(var t in o){var n=o[t];o[t]="object"==typeof n&&null!==n?traverseObject(n,c):c(t,n)}return o} }; /** @@ -779,16 +805,16 @@ function newRawBody({ header, body }, encoding = undefined) { // https://github.com/chavyleung/scripts/blob/master/Env.min.js function Env(t,e){class s{constructor(t){this.env=t}send(t,e="GET"){t="string"==typeof t?{url:t}:t;let s=this.get;return"POST"===e&&(s=this.post),new Promise((e,a)=>{s.call(this,t,(t,s,r)=>{t?a(t):e(s)})})}get(t){return this.send.call(this.env,t)}post(t){return this.send.call(this.env,t,"POST")}}return new class{constructor(t,e){this.name=t,this.http=new s(this),this.data=null,this.dataFile="box.dat",this.logs=[],this.isMute=!1,this.isNeedRewrite=!1,this.logSeparator="\n",this.encoding="utf-8",this.startTime=(new Date).getTime(),Object.assign(this,e),this.log("",`\ud83d\udd14${this.name}, \u5f00\u59cb!`)}getEnv(){return"undefined"!=typeof $environment&&$environment["surge-version"]?"Surge":"undefined"!=typeof $environment&&$environment["stash-version"]?"Stash":"undefined"!=typeof module&&module.exports?"Node.js":"undefined"!=typeof $task?"Quantumult X":"undefined"!=typeof $loon?"Loon":"undefined"!=typeof $rocket?"Shadowrocket":void 0}isNode(){return"Node.js"===this.getEnv()}isQuanX(){return"Quantumult X"===this.getEnv()}isSurge(){return"Surge"===this.getEnv()}isLoon(){return"Loon"===this.getEnv()}isShadowrocket(){return"Shadowrocket"===this.getEnv()}isStash(){return"Stash"===this.getEnv()}toObj(t,e=null){try{return JSON.parse(t)}catch{return e}}toStr(t,e=null){try{return JSON.stringify(t)}catch{return e}}getjson(t,e){let s=e;const a=this.getdata(t);if(a)try{s=JSON.parse(this.getdata(t))}catch{}return s}setjson(t,e){try{return this.setdata(JSON.stringify(t),e)}catch{return!1}}getScript(t){return new Promise(e=>{this.get({url:t},(t,s,a)=>e(a))})}runScript(t,e){return new Promise(s=>{let a=this.getdata("@chavy_boxjs_userCfgs.httpapi");a=a?a.replace(/\n/g,"").trim():a;let r=this.getdata("@chavy_boxjs_userCfgs.httpapi_timeout");r=r?1*r:20,r=e&&e.timeout?e.timeout:r;const[i,o]=a.split("@"),n={url:`http://${o}/v1/scripting/evaluate`,body:{script_text:t,mock_type:"cron",timeout:r},headers:{"X-Key":i,Accept:"*/*"},timeout:r};this.post(n,(t,e,a)=>s(a))}).catch(t=>this.logErr(t))}loaddata(){if(!this.isNode())return{};{this.fs=this.fs?this.fs:require("fs"),this.path=this.path?this.path:require("path");const t=this.path.resolve(this.dataFile),e=this.path.resolve(process.cwd(),this.dataFile),s=this.fs.existsSync(t),a=!s&&this.fs.existsSync(e);if(!s&&!a)return{};{const a=s?t:e;try{return JSON.parse(this.fs.readFileSync(a))}catch(t){return{}}}}}writedata(){if(this.isNode()){this.fs=this.fs?this.fs:require("fs"),this.path=this.path?this.path:require("path");const t=this.path.resolve(this.dataFile),e=this.path.resolve(process.cwd(),this.dataFile),s=this.fs.existsSync(t),a=!s&&this.fs.existsSync(e),r=JSON.stringify(this.data);s?this.fs.writeFileSync(t,r):a?this.fs.writeFileSync(e,r):this.fs.writeFileSync(t,r)}}lodash_get(t,e,s){const a=e.replace(/\[(\d+)\]/g,".$1").split(".");let r=t;for(const t of a)if(r=Object(r)[t],void 0===r)return s;return r}lodash_set(t,e,s){return Object(t)!==t?t:(Array.isArray(e)||(e=e.toString().match(/[^.[\]]+/g)||[]),e.slice(0,-1).reduce((t,s,a)=>Object(t[s])===t[s]?t[s]:t[s]=Math.abs(e[a+1])>>0==+e[a+1]?[]:{},t)[e[e.length-1]]=s,t)}getdata(t){let e=this.getval(t);if(/^@/.test(t)){const[,s,a]=/^@(.*?)\.(.*?)$/.exec(t),r=s?this.getval(s):"";if(r)try{const t=JSON.parse(r);e=t?this.lodash_get(t,a,""):e}catch(t){e=""}}return e}setdata(t,e){let s=!1;if(/^@/.test(e)){const[,a,r]=/^@(.*?)\.(.*?)$/.exec(e),i=this.getval(a),o=a?"null"===i?null:i||"{}":"{}";try{const e=JSON.parse(o);this.lodash_set(e,r,t),s=this.setval(JSON.stringify(e),a)}catch(e){const i={};this.lodash_set(i,r,t),s=this.setval(JSON.stringify(i),a)}}else s=this.setval(t,e);return s}getval(t){switch(this.getEnv()){case"Surge":case"Loon":case"Stash":case"Shadowrocket":return $persistentStore.read(t);case"Quantumult X":return $prefs.valueForKey(t);case"Node.js":return this.data=this.loaddata(),this.data[t];default:return this.data&&this.data[t]||null}}setval(t,e){switch(this.getEnv()){case"Surge":case"Loon":case"Stash":case"Shadowrocket":return $persistentStore.write(t,e);case"Quantumult X":return $prefs.setValueForKey(t,e);case"Node.js":return this.data=this.loaddata(),this.data[e]=t,this.writedata(),!0;default:return this.data&&this.data[e]||null}}initGotEnv(t){this.got=this.got?this.got:require("got"),this.cktough=this.cktough?this.cktough:require("tough-cookie"),this.ckjar=this.ckjar?this.ckjar:new this.cktough.CookieJar,t&&(t.headers=t.headers?t.headers:{},void 0===t.headers.Cookie&&void 0===t.cookieJar&&(t.cookieJar=this.ckjar))}get(t,e=(()=>{})){switch(t.headers&&(delete t.headers["Content-Type"],delete t.headers["Content-Length"],delete t.headers["content-type"],delete t.headers["content-length"]),this.getEnv()){case"Surge":case"Loon":case"Stash":case"Shadowrocket":default:this.isSurge()&&this.isNeedRewrite&&(t.headers=t.headers||{},Object.assign(t.headers,{"X-Surge-Skip-Scripting":!1})),$httpClient.get(t,(t,s,a)=>{!t&&s&&(s.body=a,s.statusCode=s.status?s.status:s.statusCode,s.status=s.statusCode),e(t,s,a)});break;case"Quantumult X":this.isNeedRewrite&&(t.opts=t.opts||{},Object.assign(t.opts,{hints:!1})),$task.fetch(t).then(t=>{const{statusCode:s,statusCode:a,headers:r,body:i,bodyBytes:o}=t;e(null,{status:s,statusCode:a,headers:r,body:i,bodyBytes:o},i,o)},t=>e(t&&t.error||"UndefinedError"));break;case"Node.js":let s=require("iconv-lite");this.initGotEnv(t),this.got(t).on("redirect",(t,e)=>{try{if(t.headers["set-cookie"]){const s=t.headers["set-cookie"].map(this.cktough.Cookie.parse).toString();s&&this.ckjar.setCookieSync(s,null),e.cookieJar=this.ckjar}}catch(t){this.logErr(t)}}).then(t=>{const{statusCode:a,statusCode:r,headers:i,rawBody:o}=t,n=s.decode(o,this.encoding);e(null,{status:a,statusCode:r,headers:i,rawBody:o,body:n},n)},t=>{const{message:a,response:r}=t;e(a,r,r&&s.decode(r.rawBody,this.encoding))})}}post(t,e=(()=>{})){const s=t.method?t.method.toLocaleLowerCase():"post";switch(t.body&&t.headers&&!t.headers["Content-Type"]&&!t.headers["content-type"]&&(t.headers["content-type"]="application/x-www-form-urlencoded"),t.headers&&(delete t.headers["Content-Length"],delete t.headers["content-length"]),this.getEnv()){case"Surge":case"Loon":case"Stash":case"Shadowrocket":default:this.isSurge()&&this.isNeedRewrite&&(t.headers=t.headers||{},Object.assign(t.headers,{"X-Surge-Skip-Scripting":!1})),$httpClient[s](t,(t,s,a)=>{!t&&s&&(s.body=a,s.statusCode=s.status?s.status:s.statusCode,s.status=s.statusCode),e(t,s,a)});break;case"Quantumult X":t.method=s,this.isNeedRewrite&&(t.opts=t.opts||{},Object.assign(t.opts,{hints:!1})),$task.fetch(t).then(t=>{const{statusCode:s,statusCode:a,headers:r,body:i,bodyBytes:o}=t;e(null,{status:s,statusCode:a,headers:r,body:i,bodyBytes:o},i,o)},t=>e(t&&t.error||"UndefinedError"));break;case"Node.js":let a=require("iconv-lite");this.initGotEnv(t);const{url:r,...i}=t;this.got[s](r,i).then(t=>{const{statusCode:s,statusCode:r,headers:i,rawBody:o}=t,n=a.decode(o,this.encoding);e(null,{status:s,statusCode:r,headers:i,rawBody:o,body:n},n)},t=>{const{message:s,response:r}=t;e(s,r,r&&a.decode(r.rawBody,this.encoding))})}}time(t,e=null){const s=e?new Date(e):new Date;let a={"M+":s.getMonth()+1,"d+":s.getDate(),"H+":s.getHours(),"m+":s.getMinutes(),"s+":s.getSeconds(),"q+":Math.floor((s.getMonth()+3)/3),S:s.getMilliseconds()};/(y+)/.test(t)&&(t=t.replace(RegExp.$1,(s.getFullYear()+"").substr(4-RegExp.$1.length)));for(let e in a)new RegExp("("+e+")").test(t)&&(t=t.replace(RegExp.$1,1==RegExp.$1.length?a[e]:("00"+a[e]).substr((""+a[e]).length)));return t}queryStr(t){let e="";for(const s in t){let a=t[s];null!=a&&""!==a&&("object"==typeof a&&(a=JSON.stringify(a)),e+=`${s}=${a}&`)}return e=e.substring(0,e.length-1),e}msg(e=t,s="",a="",r){const i=t=>{switch(typeof t){case void 0:return t;case"string":switch(this.getEnv()){case"Surge":case"Stash":default:return{url:t};case"Loon":case"Shadowrocket":return t;case"Quantumult X":return{"open-url":t};case"Node.js":return}case"object":switch(this.getEnv()){case"Surge":case"Stash":case"Shadowrocket":default:{let e=t.url||t.openUrl||t["open-url"];return{url:e}}case"Loon":{let e=t.openUrl||t.url||t["open-url"],s=t.mediaUrl||t["media-url"];return{openUrl:e,mediaUrl:s}}case"Quantumult X":{let e=t["open-url"]||t.url||t.openUrl,s=t["media-url"]||t.mediaUrl,a=t["update-pasteboard"]||t.updatePasteboard;return{"open-url":e,"media-url":s,"update-pasteboard":a}}case"Node.js":return}default:return}};if(!this.isMute)switch(this.getEnv()){case"Surge":case"Loon":case"Stash":case"Shadowrocket":default:$notification.post(e,s,a,i(r));break;case"Quantumult X":$notify(e,s,a,i(r));break;case"Node.js":}if(!this.isMuteLog){let t=["","==============\ud83d\udce3\u7cfb\u7edf\u901a\u77e5\ud83d\udce3=============="];t.push(e),s&&t.push(s),a&&t.push(a),console.log(t.join("\n")),this.logs=this.logs.concat(t)}}log(...t){t.length>0&&(this.logs=[...this.logs,...t]),console.log(t.join(this.logSeparator))}logErr(t,e){switch(this.getEnv()){case"Surge":case"Loon":case"Stash":case"Shadowrocket":case"Quantumult X":default:this.log("",`\u2757\ufe0f${this.name}, \u9519\u8bef!`,t);break;case"Node.js":this.log("",`\u2757\ufe0f${this.name}, \u9519\u8bef!`,t.stack)}}wait(t){return new Promise(e=>setTimeout(e,t))}done(t={}){const e=(new Date).getTime(),s=(e-this.startTime)/1e3;switch(this.log("",`\ud83d\udd14${this.name}, \u7ed3\u675f! \ud83d\udd5b ${s} \u79d2`),this.log(),this.getEnv()){case"Surge":case"Loon":case"Stash":case"Shadowrocket":case"Quantumult X":default:$done(t);break;case"Node.js":process.exit(1)}}}(t,e)} -// https://github.com/DualSubs/URL/blob/main/URLs.embedded.min.js -function URLs(s){return new class{constructor(s=[]){this.name="URL v1.0.2",this.opts=s,this.json={scheme:"",host:"",path:"",params:{}}}parse(s){let t=s.match(/(?.+):\/\/(?[^/]+)\/?(?[^?]+)?\??(?.*)?/)?.groups??null;return t?.path||(t.path=""),t?.params&&(t.params=Object.fromEntries(t.params.split("&").map((s=>s.split("="))))),t}stringify(s=this.json){return s?.params?s.scheme+"://"+s.host+"/"+s.path+"?"+Object.entries(s.params).map((s=>s.join("="))).join("&"):s.scheme+"://"+s.host+"/"+s.path}}(s)} - /** * Get Environment Variables - * @link https://github.com/VirgilClyne/VirgilClyne/blob/main/function/getENV/getENV.min.js + * @link https://github.com/VirgilClyne/GetSomeFries/blob/main/function/getENV/getENV.min.js * @author VirgilClyne - * @param {String} t - Persistent Store Key - * @param {String} e - Platform Name - * @param {Object} n - Default Database + * @param {String} key - Persistent Store Key + * @param {Array} names - Platform Names + * @param {Object} database - Default Database * @return {Object} { Settings, Caches, Configs } */ -function getENV(t,e,n){let i=$.getjson(t,n),s={};if("undefined"!=typeof $argument&&Boolean($argument)){let t=Object.fromEntries($argument.split("&").map((t=>t.split("="))));for(let e in t)l(s,e,t[e])}let g={...n?.Default?.Settings,...n?.[e]?.Settings,...i?.[e]?.Settings,...s},f={...n?.Default?.Configs,...n?.[e]?.Configs,...i?.[e]?.Configs},o=i?.[e]?.Caches||{};return"string"==typeof o&&(o=JSON.parse(o)),{Settings:g,Caches:o,Configs:f};function l(t,e,n){e.split(".").reduce(((t,i,s)=>t[i]=e.split(".").length===++s?n:t[i]||{}),t)}} \ No newline at end of file +function getENV(key,names,database){let BoxJs=$.getjson(key,database),Argument={};if("undefined"!=typeof $argument&&Boolean($argument)){let arg=Object.fromEntries($argument.split("&").map((item=>item.split("="))));for(let item in arg)setPath(Argument,item,arg[item])}const Store={Settings:database?.Default?.Settings||{},Configs:database?.Default?.Configs||{},Caches:{}};Array.isArray(names)||(names=[names]);for(let name of names)Store.Settings={...Store.Settings,...database?.[name]?.Settings,...BoxJs?.[name]?.Settings,...Argument},Store.Configs={...Store.Configs,...database?.[name]?.Configs},BoxJs?.[name]?.Caches&&"string"==typeof BoxJs?.[name]?.Caches&&(BoxJs[name].Caches=JSON.parse(BoxJs?.[name]?.Caches)),Store.Caches={...Store.Caches,...BoxJs?.[name]?.Caches};return function traverseObject(o,c){for(var t in o){var n=o[t];o[t]="object"==typeof n&&null!==n?traverseObject(n,c):c(t,n)}return o}(Store.Settings,((key,value)=>("true"===value||"false"===value?value=JSON.parse(value):"string"==typeof value&&(value?.includes(",")?value=value.split(","):value&&!isNaN(value)&&(value=parseInt(value,10))),value))),Store;function setPath(object,path,value){path.split(".").reduce(((o,p,i)=>o[p]=path.split(".").length===++i?value:o[p]||{}),object)}} + +// https://github.com/VirgilClyne/GetSomeFries/blob/main/function/URL/URLs.embedded.min.js +function URLs(t){return new class{constructor(t=[]){this.name="URL v1.2.2",this.opts=t,this.json={scheme:"",host:"",path:"",type:"",query:{}}}parse(t){let s=t.match(/(?:(?.+):\/\/(?[^/]+))?\/?(?[^?]+)?\??(?[^?]+)?/)?.groups??null;return s?.path?s.paths=s?.path?.split("/"):s.path="",s?.paths&&(s.type=s?.paths?.[s?.paths?.length-1]?.split(".")?.[1]),s?.query&&(s.query=Object.fromEntries(s.query.split("&").map((t=>t.split("="))))),s}stringify(t=this.json){let s="";return t?.scheme&&t?.host&&(s+=t.scheme+"://"+t.host),t?.path&&(s+=t?.host?"/"+t.path:t.path),t?.query&&(s+="?"+Object.entries(t.query).map((t=>t.join("="))).join("&")),s}}(t)} \ No newline at end of file diff --git a/Scripts/AdBlock/Other/Tieba-2.js b/Scripts/AdBlock/Other/Tieba-2.js new file mode 100644 index 0000000..f30180c --- /dev/null +++ b/Scripts/AdBlock/Other/Tieba-2.js @@ -0,0 +1,107 @@ +// protobuf.jsv7.2.3(做了部分修改 i.util.global.protobuf=i -> protobuf=i.util.global.protobuf=i) +let protobuf;!function(g){"use strict";!function(r,e,t){var i=function t(i){var n=e[i];return n||r[i][0].call(n=e[i]={exports:{}},t,n,n.exports),n.exports}(t[0]);protobuf=i.util.global.protobuf=i,"function"==typeof define&&define.amd&&define(["long"],function(t){return t&&t.isLong&&(i.util.Long=t,i.configure()),i}),"object"==typeof module&&module&&module.exports&&(module.exports=i)}({1:[function(t,i,n){i.exports=function(t,i){var n=Array(arguments.length-1),s=0,r=2,u=!0;for(;r>2],r=(3&h)<<4,o=1;break;case 1:s[u++]=f[r|h>>4],r=(15&h)<<2,o=2;break;case 2:s[u++]=f[r|h>>6],s[u++]=f[63&h],o=0}8191>4,r=o,s=2;break;case 2:i[n++]=(15&r)<<4|(60&o)>>2,r=o,s=3;break;case 3:i[n++]=(3&r)<<6|o,s=0}}if(1===s)throw Error(c);return n-e},n.test=function(t){return/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(t)}},{}],3:[function(t,i,n){function a(i,n){"string"==typeof i&&(n=i,i=g);var h=[];function f(t){if("string"!=typeof t){var i=c();if(a.verbose&&console.log("codegen: "+i),i="return "+i,t){for(var n=Object.keys(t),r=Array(n.length+1),e=Array(n.length),s=0;s>>0:i<11754943508222875e-54?(e<<31|Math.round(i/1401298464324817e-60))>>>0:(e<<31|127+(t=Math.floor(Math.log(i)/Math.LN2))<<23|8388607&Math.round(i*Math.pow(2,-t)*8388608))>>>0,n,r)}function n(t,i,n){t=t(i,n),i=2*(t>>31)+1,n=t>>>23&255,t&=8388607;return 255==n?t?NaN:1/0*i:0==n?1401298464324817e-60*i*t:i*Math.pow(2,n-150)*(8388608+t)}function r(t,i,n){o[0]=t,i[n]=h[0],i[n+1]=h[1],i[n+2]=h[2],i[n+3]=h[3]}function e(t,i,n){o[0]=t,i[n]=h[3],i[n+1]=h[2],i[n+2]=h[1],i[n+3]=h[0]}function s(t,i){return h[0]=t[i],h[1]=t[i+1],h[2]=t[i+2],h[3]=t[i+3],o[0]}function u(t,i){return h[3]=t[i],h[2]=t[i+1],h[1]=t[i+2],h[0]=t[i+3],o[0]}var o,h,f,c,a;function l(t,i,n,r,e,s){var u,o=r<0?1:0;0===(r=o?-r:r)?(t(0,e,s+i),t(0<1/r?0:2147483648,e,s+n)):isNaN(r)?(t(0,e,s+i),t(2146959360,e,s+n)):17976931348623157e292>>0,e,s+n)):r<22250738585072014e-324?(t((u=r/5e-324)>>>0,e,s+i),t((o<<31|u/4294967296)>>>0,e,s+n)):(t(4503599627370496*(u=r*Math.pow(2,-(r=1024===(r=Math.floor(Math.log(r)/Math.LN2))?1023:r)))>>>0,e,s+i),t((o<<31|r+1023<<20|1048576*u&1048575)>>>0,e,s+n))}function d(t,i,n,r,e){i=t(r,e+i),t=t(r,e+n),r=2*(t>>31)+1,e=t>>>20&2047,n=4294967296*(1048575&t)+i;return 2047==e?n?NaN:1/0*r:0==e?5e-324*r*n:r*Math.pow(2,e-1075)*(n+4503599627370496)}function v(t,i,n){f[0]=t,i[n]=c[0],i[n+1]=c[1],i[n+2]=c[2],i[n+3]=c[3],i[n+4]=c[4],i[n+5]=c[5],i[n+6]=c[6],i[n+7]=c[7]}function b(t,i,n){f[0]=t,i[n]=c[7],i[n+1]=c[6],i[n+2]=c[5],i[n+3]=c[4],i[n+4]=c[3],i[n+5]=c[2],i[n+6]=c[1],i[n+7]=c[0]}function p(t,i){return c[0]=t[i],c[1]=t[i+1],c[2]=t[i+2],c[3]=t[i+3],c[4]=t[i+4],c[5]=t[i+5],c[6]=t[i+6],c[7]=t[i+7],f[0]}function y(t,i){return c[7]=t[i],c[6]=t[i+1],c[5]=t[i+2],c[4]=t[i+3],c[3]=t[i+4],c[2]=t[i+5],c[1]=t[i+6],c[0]=t[i+7],f[0]}return"undefined"!=typeof Float32Array?(o=new Float32Array([-0]),h=new Uint8Array(o.buffer),a=128===h[3],t.writeFloatLE=a?r:e,t.writeFloatBE=a?e:r,t.readFloatLE=a?s:u,t.readFloatBE=a?u:s):(t.writeFloatLE=i.bind(null,m),t.writeFloatBE=i.bind(null,w),t.readFloatLE=n.bind(null,g),t.readFloatBE=n.bind(null,j)),"undefined"!=typeof Float64Array?(f=new Float64Array([-0]),c=new Uint8Array(f.buffer),a=128===c[7],t.writeDoubleLE=a?v:b,t.writeDoubleBE=a?b:v,t.readDoubleLE=a?p:y,t.readDoubleBE=a?y:p):(t.writeDoubleLE=l.bind(null,m,0,4),t.writeDoubleBE=l.bind(null,w,4,0),t.readDoubleLE=d.bind(null,g,0,4),t.readDoubleBE=d.bind(null,j,4,0)),t}function m(t,i,n){i[n]=255&t,i[n+1]=t>>>8&255,i[n+2]=t>>>16&255,i[n+3]=t>>>24}function w(t,i,n){i[n]=t>>>24,i[n+1]=t>>>16&255,i[n+2]=t>>>8&255,i[n+3]=255&t}function g(t,i){return(t[i]|t[i+1]<<8|t[i+2]<<16|t[i+3]<<24)>>>0}function j(t,i){return(t[i]<<24|t[i+1]<<16|t[i+2]<<8|t[i+3])>>>0}i.exports=r(r)},{}],7:[function(t,i,n){function r(t){try{var i=eval("require")(t);if(i&&(i.length||Object.keys(i).length))return i}catch(t){}return null}i.exports=r},{}],8:[function(t,i,n){var e=n.isAbsolute=function(t){return/^(?:\/|\w+:)/.test(t)},r=n.normalize=function(t){var i=(t=t.replace(/\\/g,"/").replace(/\/{2,}/g,"/")).split("/"),n=e(t),t="";n&&(t=i.shift()+"/");for(var r=0;r>>1,s=null,u=r;return function(t){if(t<1||e>10),s[u++]=56320+(1023&r)):s[u++]=(15&r)<<12|(63&t[i++])<<6|63&t[i++],8191>6|192:(55296==(64512&r)&&56320==(64512&(e=t.charCodeAt(u+1)))?(++u,i[n++]=(r=65536+((1023&r)<<10)+(1023&e))>>18|240,i[n++]=r>>12&63|128):i[n++]=r>>12|224,i[n++]=r>>6&63|128),i[n++]=63&r|128);return n-s}},{}],11:[function(t,i,n){var l=t(14),d=t(33);function u(t,i,n,r){var e=!1;if(i.resolvedType)if(i.resolvedType instanceof l){t("switch(d%s){",r);for(var s=i.resolvedType.values,u=Object.keys(s),o=0;o>>0",r,r);break;case"int32":case"sint32":case"sfixed32":t("m%s=d%s|0",r,r);break;case"uint64":h=!0;case"int64":case"sint64":case"fixed64":case"sfixed64":t("if(util.Long)")("(m%s=util.Long.fromValue(d%s)).unsigned=%j",r,r,h)('else if(typeof d%s==="string")',r)("m%s=parseInt(d%s,10)",r,r)('else if(typeof d%s==="number")',r)("m%s=d%s",r,r)('else if(typeof d%s==="object")',r)("m%s=new util.LongBits(d%s.low>>>0,d%s.high>>>0).toNumber(%s)",r,r,r,h?"true":"");break;case"bytes":t('if(typeof d%s==="string")',r)("util.base64.decode(d%s,m%s=util.newBuffer(util.base64.length(d%s)),0)",r,r,r)("else if(d%s.length >= 0)",r)("m%s=d%s",r,r);break;case"string":t("m%s=String(d%s)",r,r);break;case"bool":t("m%s=Boolean(d%s)",r,r)}}return t}function v(t,i,n,r){if(i.resolvedType)i.resolvedType instanceof l?t("d%s=o.enums===String?(types[%i].values[m%s]===undefined?m%s:types[%i].values[m%s]):m%s",r,n,r,r,n,r,r):t("d%s=types[%i].toObject(m%s,o)",r,n,r);else{var e=!1;switch(i.type){case"double":case"float":t("d%s=o.json&&!isFinite(m%s)?String(m%s):m%s",r,r,r,r);break;case"uint64":e=!0;case"int64":case"sint64":case"fixed64":case"sfixed64":t('if(typeof m%s==="number")',r)("d%s=o.longs===String?String(m%s):m%s",r,r,r)("else")("d%s=o.longs===String?util.Long.prototype.toString.call(m%s):o.longs===Number?new util.LongBits(m%s.low>>>0,m%s.high>>>0).toNumber(%s):m%s",r,r,r,r,e?"true":"",r);break;case"bytes":t("d%s=o.bytes===String?util.base64.encode(m%s,0,m%s.length):o.bytes===Array?Array.prototype.slice.call(m%s):m%s",r,r,r,r,r);break;default:t("d%s=m%s",r,r)}}return t}n.fromObject=function(t){var i=t.fieldsArray,n=d.codegen(["d"],t.name+"$fromObject")("if(d instanceof this.ctor)")("return d");if(!i.length)return n("return new this.ctor");n("var m=new this.ctor");for(var r=0;r>>3){");for(var n=0;n>>3){")("case 1: k=r.%s(); break",r.keyType)("case 2:"),h.basic[e]===g?i("value=types[%i].decode(r,r.uint32())",n):i("value=r.%s()",e),i("break")("default:")("r.skipType(tag2&7)")("break")("}")("}"),h.long[r.keyType]!==g?i('%s[typeof k==="object"?util.longToHash(k):k]=value',s):i("%s[k]=value",s)):r.repeated?(i("if(!(%s&&%s.length))",s,s)("%s=[]",s),h.packed[e]!==g&&i("if((t&7)===2){")("var c2=r.uint32()+r.pos")("while(r.pos>>0,8|c.mapKey[s.keyType],s.keyType),h===g?n("types[%i].encode(%s[ks[i]],w.uint32(18).fork()).ldelim().ldelim()",u,i):n(".uint32(%i).%s(%s[ks[i]]).ldelim()",16|h,o,i),n("}")("}")):s.repeated?(n("if(%s!=null&&%s.length){",i,i),s.packed&&c.packed[o]!==g?n("w.uint32(%i).fork()",(s.id<<3|2)>>>0)("for(var i=0;i<%s.length;++i)",i)("w.%s(%s[i])",o,i)("w.ldelim()"):(n("for(var i=0;i<%s.length;++i)",i),h===g?l(n,s,u,i+"[i]"):n("w.uint32(%i).%s(%s[i])",(s.id<<3|h)>>>0,o,i)),n("}")):(s.optional&&n("if(%s!=null&&Object.hasOwnProperty.call(m,%j))",i,s.name),h===g?l(n,s,u,i):n("w.uint32(%i).%s(%s)",(s.id<<3|h)>>>0,o,i))}return n("return w")};var f=t(14),c=t(32),a=t(33);function l(t,i,n,r){i.resolvedType.group?t("types[%i].encode(%s,w.uint32(%i)).uint32(%i)",n,r,(i.id<<3|3)>>>0,(i.id<<3|4)>>>0):t("types[%i].encode(%s,w.uint32(%i).fork()).ldelim()",n,r,(i.id<<3|2)>>>0)}},{14:14,32:32,33:33}],14:[function(t,i,n){i.exports=s;var h=t(22),r=(((s.prototype=Object.create(h.prototype)).constructor=s).className="Enum",t(21)),e=t(33);function s(t,i,n,r,e,s){if(h.call(this,t,n),i&&"object"!=typeof i)throw TypeError("values must be an object");if(this.valuesById={},this.values=Object.create(this.valuesById),this.comment=r,this.comments=e||{},this.valuesOptions=s,this.reserved=g,i)for(var u=Object.keys(i),o=0;oi)return!0;return!1},a.isReservedName=function(t,i){if(t)for(var n=0;n "+t.len)}function h(t){this.buf=t,this.pos=0,this.len=t.length}function f(){return e.Buffer?function(t){return(h.create=function(t){return e.Buffer.isBuffer(t)?new r(t):a(t)})(t)}:a}var c,a="undefined"!=typeof Uint8Array?function(t){if(t instanceof Uint8Array||Array.isArray(t))return new h(t);throw Error("illegal buffer")}:function(t){if(Array.isArray(t))return new h(t);throw Error("illegal buffer")};function l(){var t=new s(0,0),i=0;if(!(4=this.len)throw o(this);if(t.lo=(t.lo|(127&this.buf[this.pos])<<7*i)>>>0,this.buf[this.pos++]<128)return t}return t.lo=(t.lo|(127&this.buf[this.pos++])<<7*i)>>>0,t}for(;i<4;++i)if(t.lo=(t.lo|(127&this.buf[this.pos])<<7*i)>>>0,this.buf[this.pos++]<128)return t;if(t.lo=(t.lo|(127&this.buf[this.pos])<<28)>>>0,t.hi=(t.hi|(127&this.buf[this.pos])>>4)>>>0,this.buf[this.pos++]<128)return t;if(i=0,4>>0,this.buf[this.pos++]<128)return t}else for(;i<5;++i){if(this.pos>=this.len)throw o(this);if(t.hi=(t.hi|(127&this.buf[this.pos])<<7*i+3)>>>0,this.buf[this.pos++]<128)return t}throw Error("invalid varint encoding")}function d(t,i){return(t[i-4]|t[i-3]<<8|t[i-2]<<16|t[i-1]<<24)>>>0}function v(){if(this.pos+8>this.len)throw o(this,8);return new s(d(this.buf,this.pos+=4),d(this.buf,this.pos+=4))}h.create=f(),h.prototype.h=e.Array.prototype.subarray||e.Array.prototype.slice,h.prototype.uint32=(c=4294967295,function(){if(c=(127&this.buf[this.pos])>>>0,this.buf[this.pos++]<128||(c=(c|(127&this.buf[this.pos])<<7)>>>0,this.buf[this.pos++]<128||(c=(c|(127&this.buf[this.pos])<<14)>>>0,this.buf[this.pos++]<128||(c=(c|(127&this.buf[this.pos])<<21)>>>0,this.buf[this.pos++]<128||(c=(c|(15&this.buf[this.pos])<<28)>>>0,this.buf[this.pos++]<128||!((this.pos+=5)>this.len))))))return c;throw this.pos=this.len,o(this,10)}),h.prototype.int32=function(){return 0|this.uint32()},h.prototype.sint32=function(){var t=this.uint32();return t>>>1^-(1&t)|0},h.prototype.bool=function(){return 0!==this.uint32()},h.prototype.fixed32=function(){if(this.pos+4>this.len)throw o(this,4);return d(this.buf,this.pos+=4)},h.prototype.sfixed32=function(){if(this.pos+4>this.len)throw o(this,4);return 0|d(this.buf,this.pos+=4)},h.prototype.float=function(){if(this.pos+4>this.len)throw o(this,4);var t=e.float.readFloatLE(this.buf,this.pos);return this.pos+=4,t},h.prototype.double=function(){if(this.pos+8>this.len)throw o(this,4);var t=e.float.readDoubleLE(this.buf,this.pos);return this.pos+=8,t},h.prototype.bytes=function(){var t=this.uint32(),i=this.pos,n=this.pos+t;if(n>this.len)throw o(this,t);return this.pos+=t,Array.isArray(this.buf)?this.buf.slice(i,n):i===n?new this.buf.constructor(0):this.h.call(this.buf,i,n)},h.prototype.string=function(){var t=this.bytes();return u.read(t,0,t.length)},h.prototype.skip=function(t){if("number"==typeof t){if(this.pos+t>this.len)throw o(this,t);this.pos+=t}else do{if(this.pos>=this.len)throw o(this)}while(128&this.buf[this.pos++]);return this},h.prototype.skipType=function(t){switch(t){case 0:this.skip();break;case 1:this.skip(8);break;case 2:this.skip(this.uint32());break;case 3:for(;4!=(t=7&this.uint32());)this.skipType(t);break;case 5:this.skip(4);break;default:throw Error("invalid wire type "+t+" at offset "+this.pos)}return this},h.r=function(t){r=t,h.create=f(),r.r();var i=e.Long?"toLong":"toNumber";e.merge(h.prototype,{int64:function(){return l.call(this)[i](!1)},uint64:function(){return l.call(this)[i](!0)},sint64:function(){return l.call(this).zzDecode()[i](!1)},fixed64:function(){return v.call(this)[i](!0)},sfixed64:function(){return v.call(this)[i](!1)}})}},{35:35}],25:[function(t,i,n){i.exports=s;var r=t(24),e=((s.prototype=Object.create(r.prototype)).constructor=s,t(35));function s(t){r.call(this,t)}s.r=function(){e.Buffer&&(s.prototype.h=e.Buffer.prototype.slice)},s.prototype.string=function(){var t=this.uint32();return this.buf.utf8Slice?this.buf.utf8Slice(this.pos,this.pos=Math.min(this.pos+t,this.len)):this.buf.toString("utf-8",this.pos,this.pos=Math.min(this.pos+t,this.len))},s.r()},{24:24,35:35}],26:[function(t,i,n){i.exports=h;var r,d,v,e=t(21),s=(((h.prototype=Object.create(e.prototype)).constructor=h).className="Root",t(15)),u=t(14),o=t(23),b=t(33);function h(t){e.call(this,"",t),this.deferred=[],this.files=[]}function p(){}h.fromJSON=function(t,i){return i=i||new h,t.options&&i.setOptions(t.options),i.addJSON(t.nested)},h.prototype.resolvePath=b.path.resolve,h.prototype.fetch=b.fetch,h.prototype.load=function t(i,s,e){"function"==typeof s&&(e=s,s=g);var u=this;if(!e)return b.asPromise(t,u,i,s);var o=e===p;function h(t,i){if(e){var n=e;if(e=null,o)throw t;n(t,i)}}function f(t){var i=t.lastIndexOf("google/protobuf/");if(-1>>0,this.hi=i>>>0}var s=e.zero=new e(0,0),u=(s.toNumber=function(){return 0},s.zzEncode=s.zzDecode=function(){return this},s.length=function(){return 1},e.zeroHash="\0\0\0\0\0\0\0\0",e.fromNumber=function(t){var i,n;return 0===t?s:(n=(t=(i=t<0)?-t:t)>>>0,t=(t-n)/4294967296>>>0,i&&(t=~t>>>0,n=~n>>>0,4294967295<++n&&(n=0,4294967295<++t&&(t=0))),new e(n,t))},e.from=function(t){if("number"==typeof t)return e.fromNumber(t);if(r.isString(t)){if(!r.Long)return e.fromNumber(parseInt(t,10));t=r.Long.fromString(t)}return t.low||t.high?new e(t.low>>>0,t.high>>>0):s},e.prototype.toNumber=function(t){var i;return!t&&this.hi>>>31?(t=1+~this.lo>>>0,i=~this.hi>>>0,-(t+4294967296*(i=t?i:i+1>>>0))):this.lo+4294967296*this.hi},e.prototype.toLong=function(t){return r.Long?new r.Long(0|this.lo,0|this.hi,!!t):{low:0|this.lo,high:0|this.hi,unsigned:!!t}},String.prototype.charCodeAt);e.fromHash=function(t){return"\0\0\0\0\0\0\0\0"===t?s:new e((u.call(t,0)|u.call(t,1)<<8|u.call(t,2)<<16|u.call(t,3)<<24)>>>0,(u.call(t,4)|u.call(t,5)<<8|u.call(t,6)<<16|u.call(t,7)<<24)>>>0)},e.prototype.toHash=function(){return String.fromCharCode(255&this.lo,this.lo>>>8&255,this.lo>>>16&255,this.lo>>>24,255&this.hi,this.hi>>>8&255,this.hi>>>16&255,this.hi>>>24)},e.prototype.zzEncode=function(){var t=this.hi>>31;return this.hi=((this.hi<<1|this.lo>>>31)^t)>>>0,this.lo=(this.lo<<1^t)>>>0,this},e.prototype.zzDecode=function(){var t=-(1&this.lo);return this.lo=((this.lo>>>1|this.hi<<31)^t)>>>0,this.hi=(this.hi>>>1^t)>>>0,this},e.prototype.length=function(){var t=this.lo,i=(this.lo>>>28|this.hi<<4)>>>0,n=this.hi>>>24;return 0==n?0==i?t<16384?t<128?1:2:t<2097152?3:4:i<16384?i<128?5:6:i<2097152?7:8:n<128?9:10}},{35:35}],35:[function(t,i,n){var r=n;function e(t,i,n){for(var r=Object.keys(i),e=0;e>>7|t.hi<<25)>>>0,t.hi>>>=7;for(;127>>7;i[n++]=t.lo}function p(t,i,n){i[n]=255&t,i[n+1]=t>>>8&255,i[n+2]=t>>>16&255,i[n+3]=t>>>24}a.create=l(),a.alloc=function(t){return new e.Array(t)},e.Array!==Array&&(a.alloc=e.pool(a.alloc,e.Array.prototype.subarray)),a.prototype.p=function(t,i,n){return this.tail=this.tail.next=new h(t,i,n),this.len+=i,this},(v.prototype=Object.create(h.prototype)).fn=function(t,i,n){for(;127>>=7;i[n]=t},a.prototype.uint32=function(t){return this.len+=(this.tail=this.tail.next=new v((t>>>=0)<128?1:t<16384?2:t<2097152?3:t<268435456?4:5,t)).len,this},a.prototype.int32=function(t){return t<0?this.p(b,10,s.fromNumber(t)):this.uint32(t)},a.prototype.sint32=function(t){return this.uint32((t<<1^t>>31)>>>0)},a.prototype.int64=a.prototype.uint64=function(t){t=s.from(t);return this.p(b,t.length(),t)},a.prototype.sint64=function(t){t=s.from(t).zzEncode();return this.p(b,t.length(),t)},a.prototype.bool=function(t){return this.p(d,1,t?1:0)},a.prototype.sfixed32=a.prototype.fixed32=function(t){return this.p(p,4,t>>>0)},a.prototype.sfixed64=a.prototype.fixed64=function(t){t=s.from(t);return this.p(p,4,t.lo).p(p,4,t.hi)},a.prototype.float=function(t){return this.p(e.float.writeFloatLE,4,t)},a.prototype.double=function(t){return this.p(e.float.writeDoubleLE,8,t)};var y=e.Array.prototype.set?function(t,i,n){i.set(t,n)}:function(t,i,n){for(var r=0;r>>0;return n?(e.isString(t)&&(i=a.alloc(n=u.length(t)),u.decode(t,i,0),t=i),this.uint32(n).p(y,n,t)):this.p(d,1,0)},a.prototype.string=function(t){var i=o.length(t);return i?this.uint32(i).p(o.write,i,t):this.p(d,1,0)},a.prototype.fork=function(){return this.states=new c(this),this.head=this.tail=new h(f,0,0),this.len=0,this},a.prototype.reset=function(){return this.states?(this.head=this.states.head,this.tail=this.states.tail,this.len=this.states.len,this.states=this.states.next):(this.head=this.tail=new h(f,0,0),this.len=0),this},a.prototype.ldelim=function(){var t=this.head,i=this.tail,n=this.len;return this.reset().uint32(n),n&&(this.tail.next=t.next,this.tail=i,this.len+=n),this},a.prototype.finish=function(){for(var t=this.head.next,i=this.constructor.alloc(this.len),n=0;t;)t.fn(t.val,i,n),n+=t.len,t=t.next;return i},a.r=function(t){r=t,a.create=l(),r.r()}},{35:35}],39:[function(t,i,n){i.exports=s;var r=t(38),e=((s.prototype=Object.create(r.prototype)).constructor=s,t(35));function s(){r.call(this)}function u(t,i,n){t.length<40?e.utf8.write(t,i,n):i.utf8Write?i.utf8Write(t,n):i.write(t,n)}s.r=function(){s.alloc=e.b,s.writeBytesBuffer=e.Buffer&&e.Buffer.prototype instanceof Uint8Array&&"set"===e.Buffer.prototype.set.name?function(t,i,n){i.set(t,n)}:function(t,i,n){if(t.copy)t.copy(i,n,0,t.length);else for(var r=0;r>>0;return this.uint32(i),i&&this.p(s.writeBytesBuffer,i,t),this},s.prototype.string=function(t){var i=e.Buffer.byteLength(t);return this.uint32(i),i&&this.p(u,i,t),this},s.r()},{35:35,38:38}]},{},[16])}(); + +// pbjs .proto转Json 注意下划线转为了驼峰 已去除goodsInfo BusinessPromot LiveFuseForumData +const tiebaJson = {"nested":{"model":{"nested":{"Abstract":{"fields":{"text":{"type":"string","id":2},"type":{"type":"int32","id":1}}},"ActionControl":{"fields":{"name":{"type":"string","id":2},"textColor":{"type":"string","id":3},"textColorPressed":{"type":"string","id":4},"url":{"type":"string","id":1}}},"AdCloseInfo":{"fields":{"actionControl":{"type":"ActionControl","id":5},"reasons":{"rule":"repeated","type":"string","id":3},"supportClose":{"type":"int32","id":1}}},"Advertisement":{"fields":{"advertisementId":{"type":"string","id":5},"clickStatisticsUrl":{"type":"string","id":7},"deeplink":{"type":"string","id":9},"displayAdIcon":{"type":"string","id":12},"floatingText":{"type":"string","id":8},"jumpLink":{"type":"string","id":4},"packageName":{"type":"string","id":11},"pic":{"type":"string","id":2},"picClick":{"type":"string","id":3},"scheme":{"type":"string","id":10},"time":{"type":"int64","id":1},"viewStatisticsUrl":{"type":"string","id":6}}},"AgreeBanner":{"fields":{"iconUrl":{"type":"string","id":2},"text":{"type":"string","id":1},"topAgreeUser":{"rule":"repeated","type":"SimpleUser","id":4},"url":{"type":"string","id":3}}},"SimpleUser":{"fields":{"portrait":{"type":"string","id":8},"userId":{"type":"int64","id":1},"userName":{"type":"string","id":5}}},"Agree":{"fields":{"agreeNum":{"type":"int64","id":1},"agreeType":{"type":"int32","id":3},"diffAgreeNum":{"type":"int64","id":5},"disagreeNum":{"type":"int64","id":4},"hasAgree":{"type":"int32","id":2},"lzAgree":{"type":"int32","id":6}}},"AlaChallengeInfo":{"fields":{"challengeId":{"type":"int64","id":1},"rivalHlsUrl":{"type":"string","id":5},"rivalRtmpUrl":{"type":"string","id":4},"rivalSession":{"type":"string","id":3},"winningNum":{"type":"int64","id":2}}},"AlaLiveInfo":{"fields":{"audienceCount":{"type":"uint32","id":14},"challengeInfo":{"type":"AlaChallengeInfo","id":25},"cover":{"type":"string","id":2},"coverWide":{"type":"string","id":48},"description":{"type":"string","id":11},"dislikeInfo":{"rule":"repeated","type":"DislikeInfo","id":43},"firstHeadline":{"type":"string","id":34},"groupId":{"type":"uint64","id":6},"hlsUrl":{"type":"string","id":5},"liveFrom":{"type":"int32","id":29},"liveId":{"type":"uint64","id":1},"liveStatus":{"type":"int32","id":18},"liveType":{"type":"uint32","id":15},"openRecomDuration":{"type":"uint32","id":41},"openRecomFans":{"type":"uint32","id":40},"openRecomLocation":{"type":"uint32","id":39},"openRecomReason":{"type":"uint32","id":38},"pbDisplayType":{"type":"uint32","id":36},"recomReason":{"type":"string","id":37},"roomId":{"type":"uint64","id":44},"routerType":{"type":"string","id":32},"rtmpUrl":{"type":"string","id":4},"screenDirection":{"type":"uint32","id":16},"secondHeadline":{"type":"string","id":35},"sessionId":{"type":"string","id":3},"shareInfo":{"type":"AlaShareInfo","id":19},"thirdAppId":{"type":"string","id":21},"thirdLiveType":{"type":"string","id":33},"thirdRoomId":{"type":"string","id":31},"userInfo":{"type":"AlaUserInfo","id":12},"yyExt":{"type":"YyExt","id":49},"labelName":{"type":"string","id":17},"userLabel":{"type":"UniversalLabel","id":51}}},"DislikeInfo":{"fields":{"dislikeId":{"type":"uint32","id":2},"dislikeReason":{"type":"string","id":1},"extra":{"type":"string","id":3}}},"AlaShareInfo":{"fields":{"shareCount":{"type":"int32","id":3},"shareUserCount":{"type":"int32","id":2}}},"AlaUserInfo":{"fields":{"alaId":{"type":"uint64","id":1},"anchorFans":{"type":"int32","id":24},"anchorLive":{"type":"uint64","id":7},"enterLive":{"type":"uint64","id":6},"lat":{"type":"double","id":12},"liveId":{"type":"uint64","id":9},"liveStatus":{"type":"uint32","id":8},"lng":{"type":"double","id":11},"location":{"type":"string","id":10},"portrait":{"type":"string","id":3},"userId":{"type":"uint64","id":23},"userName":{"type":"string","id":2},"yyExt":{"type":"YyExt","id":25}}},"YyExt":{"fields":{"iconUrl":{"type":"string","id":8},"isYyGame":{"type":"int32","id":5},"rankShow":{"type":"string","id":7},"sid":{"type":"string","id":1},"ssid":{"type":"string","id":2},"streamInfo":{"type":"string","id":6},"templateId":{"type":"string","id":3},"yyUid":{"type":"string","id":4},"feedId":{"type":"string","id":9}}},"UniversalLabel":{"fields":{"backgroundColor":{"type":"string","id":5},"backgroundColorBlack":{"type":"string","id":6},"labelId":{"type":"string","id":1},"labelText":{"type":"string","id":2},"roundRadius":{"type":"int32","id":7},"textColor":{"type":"string","id":3},"textColorBlack":{"type":"string","id":4}}},"Anti":{"fields":{"blockPopInfo":{"type":"BlockPopInfo","id":22},"blockStat":{"type":"int32","id":6},"canGoods":{"type":"int32","id":27},"daysTofree":{"type":"int32","id":9},"delThreadText":{"rule":"repeated","type":"DelThreadText","id":24},"forbidFlag":{"type":"int32","id":4},"forbidInfo":{"type":"string","id":5},"hasChance":{"type":"int32","id":10},"hideStat":{"type":"int32","id":7},"ifaddition":{"type":"int32","id":13},"ifpost":{"type":"int32","id":2},"ifvoice":{"type":"int32","id":11},"ifxiaoying":{"type":"string","id":18},"multiDelthread":{"type":"int32","id":25},"pollLevel":{"type":"uint32","id":26},"pollMessage":{"type":"string","id":19},"replyPrivateFlag":{"type":"int32","id":23},"tbs":{"type":"string","id":1},"vcodeStat":{"type":"int32","id":8},"videoLocalMessage":{"type":"string","id":21},"videoMessage":{"type":"string","id":20},"voiceMessage":{"type":"string","id":12}}},"BlockPopInfo":{"fields":{"aheadInfo":{"type":"string","id":3},"aheadType":{"type":"int32","id":6},"aheadUrl":{"type":"string","id":4},"appealMsg":{"type":"string","id":8},"appealStatus":{"type":"int32","id":7},"blockInfo":{"type":"string","id":2},"canPost":{"type":"int32","id":1},"okInfo":{"type":"string","id":5},"subBlockInfo":{"type":"string","id":11}}},"DelThreadText":{"fields":{"textId":{"type":"int32","id":1},"textInfo":{"type":"string","id":2}}},"ApkDetail":{"fields":{"authorityUrl":{"type":"string","id":11},"developer":{"type":"string","id":1},"needInnerBuy":{"type":"int32","id":10},"needNetwork":{"type":"int32","id":9},"privacyUrl":{"type":"string","id":12},"publisher":{"type":"string","id":2},"size":{"type":"string","id":8},"updateTime":{"type":"string","id":7},"version":{"type":"string","id":3},"versionCode":{"type":"int32","id":6}}},"App":{"fields":{"appTime":{"type":"int32","id":10},"extInfo":{"type":"string","id":29},"id":{"type":"string","id":13},"locCode":{"type":"string","id":31},"name":{"type":"string","id":14},"posName":{"type":"string","id":20},"url":{"type":"string","id":16},"urlType":{"type":"int32","id":15}}},"BaijiahaoInfo":{"fields":{"authDesc":{"type":"string","id":6},"authId":{"type":"int32","id":5},"avatar":{"type":"string","id":2}}},"Baijiahao":{"fields":{"oriUgcNid":{"type":"string","id":1},"oriUgcTid":{"type":"string","id":2},"oriUgcVid":{"type":"string","id":4}}},"Balv":{"fields":{"daysTofree":{"type":"int32","id":3},"isBlack":{"type":"int32","id":1},"isBlock":{"type":"int32","id":2}}},"BannerList":{"fields":{"app":{"rule":"repeated","type":"App","id":1},"pbBannerAd":{"type":"App","id":5}}},"Banner":{"fields":{"bannerType":{"type":"int32","id":2},"bannerUrl":{"type":"string","id":1},"desc":{"type":"string","id":5},"type":{"type":"int32","id":4}}},"BazhuSign":{"fields":{"desc":{"type":"string","id":1},"level":{"type":"string","id":2}}},"BusinessAccountInfo":{"fields":{"isBusinessAccount":{"type":"int32","id":1},"isForumBusinessAccount":{"type":"int32","id":2}}},"CallFansInfo":{"fields":{"canCall":{"type":"int32","id":1}}},"Classify":{"fields":{"classId":{"type":"int32","id":3},"className":{"type":"string","id":4}}},"CustomFigure":{"fields":{"backgroundType":{"type":"string","id":2},"backgroundValue":{"type":"string","id":3},"dynamicFigureUrl":{"type":"string","id":4},"figureUrl":{"type":"string","id":1}}},"CustomState":{"fields":{"content":{"type":"string","id":2},"icon":{"type":"string","id":1},"iconType":{"type":"string","id":3}}},"DeletedReasonInfo":{"fields":{"isBoomgrow":{"type":"int32","id":2},"isGraysCaleForum":{"type":"int32","id":1}}},"EditConfig":{"fields":{"isFirstEdit":{"type":"int32","id":2},"showEdit":{"type":"int32","id":1}}},"EditInfo":{"fields":{"editEnable":{"type":"int32","id":2},"editErrorMsg":{"type":"string","id":3},"editErrorNo":{"type":"int32","id":6},"editFrom":{"type":"int32","id":5},"editStatus":{"type":"int32","id":1},"lastEditTime":{"type":"int32","id":4}}},"Error":{"fields":{"errmsg":{"type":"string","id":2},"errorno":{"type":"int32","id":1},"usermsg":{"type":"string","id":3}}},"ForumActiveInfo":{"fields":{"forumBrief":{"type":"string","id":1},"forumShareUrl":{"type":"string","id":2}}},"ForumRuleStatus":{"fields":{"hasForumRule":{"type":"int32","id":4},"title":{"type":"string","id":2}}},"ForumShowInfo":{"fields":{"content":{"type":"string","id":1},"showType":{"type":"int64","id":3},"tag":{"type":"ForumShowInfoTag","id":2}}},"ForumShowInfoTag":{"fields":{"bgColor":{"type":"ThemeColorInfo","id":3},"text":{"type":"string","id":1},"textColor":{"type":"ThemeColorInfo","id":2}}},"ThemeColorInfo":{"fields":{"dark":{"type":"ThemeElement","id":3},"day":{"type":"ThemeElement","id":1},"night":{"type":"ThemeElement","id":2}}},"ThemeElement":{"fields":{"commonColor":{"type":"string","id":1},"darkColor":{"type":"string","id":2},"fontColor":{"type":"string","id":5},"lightColor":{"type":"string","id":3},"patternImage":{"type":"string","id":4}}},"FrequentlyForumInfo":{"fields":{"accessFlag":{"type":"uint32","id":15},"forumState":{"type":"uint32","id":14}}},"FrsTabInfo":{"fields":{"isGeneralTab":{"type":"int32","id":7},"tabCode":{"type":"string","id":8},"tabId":{"type":"int32","id":1},"tabName":{"type":"string","id":3},"tabType":{"type":"int32","id":2},"tabUrl":{"type":"string","id":4}}},"GconAccount":{"fields":{"hasAccount":{"type":"int32","id":1},"menuName":{"type":"string","id":2}}},"GraffitiInfo":{"fields":{"gid":{"type":"int64","id":2},"url":{"type":"string","id":1}}},"Group":{"fields":{"groupCount":{"type":"int32","id":2},"hideRecommendGroup":{"type":"int32","id":1}}},"HeadItem":{"fields":{"content":{"type":"string","id":2},"name":{"type":"string","id":1},"type":{"type":"int32","id":3}}},"HeadSdk":{"fields":{"headPic":{"type":"string","id":1},"headText":{"type":"string","id":2},"headType":{"type":"int32","id":5},"sdkName":{"type":"string","id":3},"sdkParams":{"type":"string","id":4}}},"HotUserRankEntry":{"fields":{"hotUser":{"rule":"repeated","type":"ShortUserInfo","id":1},"moduleName":{"type":"string","id":2}}},"ShortUserInfo":{"fields":{"portrait":{"type":"string","id":2},"userId":{"type":"int64","id":1}}},"Icon":{"fields":{"icon":{"type":"string","id":4},"name":{"type":"string","id":1},"position":{"type":"Position","id":7},"spriteInfo":{"rule":"repeated","type":"string","id":8},"terminal":{"type":"Terminal","id":6},"value":{"type":"int32","id":5},"weight":{"type":"int32","id":2}}},"Position":{"fields":{"card":{"type":"int32","id":4},"frs":{"type":"int32","id":1},"home":{"type":"int32","id":3},"pb":{"type":"int32","id":2}}},"Terminal":{"fields":{"client":{"type":"int32","id":3},"pc":{"type":"int32","id":1},"wap":{"type":"int32","id":2}}},"ItemInfo":{"fields":{"apkName":{"type":"string","id":23},"brief":{"type":"string","id":4},"buttonLink":{"type":"string","id":20},"buttonLinkType":{"type":"int32","id":22},"buttonName":{"type":"string","id":19},"forumName":{"type":"string","id":12},"iconSize":{"type":"double","id":6},"iconUrl":{"type":"string","id":3},"id":{"type":"uint32","id":1},"isSchool":{"type":"uint32","id":9},"itemAppid":{"type":"string","id":21},"itemOptions":{"rule":"repeated","type":"ItemOptions","id":7},"name":{"type":"string","id":2},"score":{"type":"ItemTable","id":8},"tags":{"rule":"repeated","type":"string","id":5}}},"ItemOptions":{"fields":{"key":{"type":"string","id":1},"value":{"type":"string","id":2}}},"ItemTable":{"fields":{"itemPlot":{"rule":"repeated","type":"ItemPlot","id":7},"itemPoint":{"rule":"repeated","type":"ItemPoint","id":6},"totalPointNum":{"type":"int32","id":5}}},"ItemPlot":{"fields":{"level":{"type":"uint32","id":1},"num":{"type":"uint32","id":2}}},"ItemPoint":{"fields":{"point":{"type":"double","id":2},"timeIntval":{"type":"string","id":1}}},"Item":{"fields":{"apkDetail":{"type":"ApkDetail","id":15},"apkName":{"type":"string","id":13},"buttonLink":{"type":"string","id":9},"buttonLinkType":{"type":"int32","id":12},"buttonName":{"type":"string","id":8},"categoryId":{"type":"int32","id":11},"forumName":{"type":"string","id":14},"iconSize":{"type":"double","id":3},"iconUrl":{"type":"string","id":4},"itemAppid":{"type":"string","id":10},"itemId":{"type":"int64","id":1},"itemName":{"type":"string","id":2},"score":{"type":"double","id":6},"star":{"type":"int32","id":7},"tags":{"rule":"repeated","type":"string","id":5}}},"Lbs":{"fields":{"lat":{"type":"string","id":1},"lng":{"type":"string","id":2},"name":{"type":"string","id":3}}},"Manager":{"fields":{"id":{"type":"int64","id":1},"name":{"type":"string","id":2},"portrait":{"type":"string","id":4},"showName":{"type":"string","id":3}}},"MediaNum":{"fields":{"pic":{"type":"int32","id":1}}},"Media":{"fields":{"bigPic":{"type":"string","id":3},"bsize":{"type":"string","id":12},"dynamicPic":{"type":"string","id":18},"height":{"type":"uint32","id":11},"hthMidLoc":{"type":"double","id":23},"isLongPic":{"type":"uint32","id":19},"originPic":{"type":"string","id":15},"originSize":{"type":"uint32","id":16},"postId":{"type":"int64","id":17},"showOriginalBtn":{"type":"uint32","id":20},"smallPic":{"type":"string","id":2},"srcPic":{"type":"string","id":8},"type":{"type":"int32","id":1},"vhsrc":{"type":"string","id":7},"vpic":{"type":"string","id":5},"vsrc":{"type":"string","id":6},"waterPic":{"type":"string","id":4},"width":{"type":"uint32","id":10},"wthMidLoc":{"type":"double","id":22}}},"MemberShowIcon":{"fields":{"icon":{"type":"string","id":1},"name":{"type":"string","id":2},"url":{"type":"string","id":3}}},"MemeInfo":{"fields":{"detailLink":{"type":"string","id":7},"height":{"type":"uint32","id":6},"pckId":{"type":"uint32","id":1},"picId":{"type":"uint64","id":2},"picUrl":{"type":"string","id":3},"thumbnail":{"type":"string","id":4},"width":{"type":"uint32","id":5}}},"NativeApp":{"fields":{"downloadAnd":{"type":"string","id":3},"downloadIos":{"type":"string","id":4},"jumpIos":{"type":"string","id":2}}},"NavTabInfo":{"fields":{"menu":{"rule":"repeated","type":"FrsTabInfo","id":2},"tab":{"rule":"repeated","type":"FrsTabInfo","id":1}}},"NewGodInfo":{"fields":{"fieldId":{"type":"uint32","id":2},"fieldName":{"type":"string","id":3},"status":{"type":"int32","id":1},"type":{"type":"uint32","id":4},"typeName":{"type":"string","id":5}}},"OriginThreadInfo":{"fields":{"_abstract":{"rule":"repeated","type":"Abstract","id":3},"agree":{"type":"Agree","id":19},"alaInfo":{"type":"AlaLiveInfo","id":6},"author":{"type":"User","id":18},"content":{"rule":"repeated","type":"PbContent","id":14},"fid":{"type":"int64","id":7},"fname":{"type":"string","id":4},"isDeleted":{"type":"int32","id":9},"isFrsMask":{"type":"int32","id":28},"isNewStyle":{"type":"int32","id":15},"isUgc":{"type":"int32","id":10},"item":{"type":"Item","id":22},"media":{"rule":"repeated","type":"Media","id":2},"oriUgcInfo":{"type":"Baijiahao","id":11},"pid":{"type":"int64","id":25},"pollInfo":{"type":"PollInfo","id":21},"replyNum":{"type":"int32","id":16},"sharedNum":{"type":"int32","id":20},"threadType":{"type":"int32","id":8},"tid":{"type":"string","id":5},"title":{"type":"string","id":1},"videoInfo":{"type":"VideoInfo","id":13}}},"User":{"fields":{"agreeNum":{"type":"int32","id":88},"alaInfo":{"type":"AlaUserInfo","id":78},"alaLiveInfo":{"type":"AlaLiveInfo","id":85},"appealThreadPopover":{"type":"string","id":112},"baijiahaoInfo":{"type":"BaijiahaoInfo","id":95},"balv":{"type":"Balv","id":10},"bawuType":{"type":"string","id":26},"bazhuGrade":{"type":"BazhuSign","id":105},"bimgEndTime":{"type":"int32","id":40},"bimgUrl":{"type":"string","id":13},"businessAccountInfo":{"type":"BusinessAccountInfo","id":111},"callFansInfo":{"type":"CallFansInfo","id":104},"displayAuthType":{"type":"int32","id":123},"displayIntro":{"type":"string","id":138},"fansNickname":{"type":"string","id":57},"fansNum":{"type":"int32","id":30},"gender":{"type":"int32","id":42},"giftNum":{"type":"int32","id":49},"hasConcerned":{"type":"int32","id":35},"iconinfo":{"rule":"repeated","type":"Icon","id":17},"id":{"type":"int64","id":2},"iosBimgFormat":{"type":"string","id":22},"ip":{"type":"string","id":28},"ipAddress":{"type":"string","id":127},"isBawu":{"type":"int32","id":25},"isDefaultAvatar":{"type":"int32","id":106},"isInterestman":{"type":"int32","id":16},"isLike":{"type":"int32","id":24},"isLogin":{"type":"int32","id":1},"isManager":{"type":"int32","id":11},"isMem":{"type":"int32","id":39},"isSelectTail":{"type":"int32","id":51},"isVerify":{"type":"int32","id":15},"isVideobiggie":{"type":"int32","id":93},"leftCallNum":{"type":"int32","id":89},"levelId":{"type":"int32","id":23},"name":{"type":"string","id":3},"nameShow":{"type":"string","id":4},"newGodData":{"type":"NewGodInfo","id":101},"newTshowIcon":{"rule":"repeated","type":"TshowInfo","id":65},"noUn":{"type":"int32","id":6},"payMemberInfo":{"type":"PayMemberInfo","id":41},"pendant":{"type":"Pendant","id":77},"portrait":{"type":"string","id":5},"privSets":{"type":"PrivSets","id":45},"privThread":{"type":"int32","id":92},"profitList":{"rule":"repeated","type":"TwAnchorProfitItem","id":67},"rank":{"type":"string","id":12},"sealPrefix":{"type":"string","id":79},"sex":{"type":"int32","id":32},"showPbPrivateFlag":{"type":"int32","id":117},"tbVip":{"type":"TbVipInfo","id":72},"themeCard":{"type":"ThemeCardInUser","id":69},"threadNum":{"type":"int32","id":87},"tshowIcon":{"rule":"repeated","type":"TshowInfo","id":18},"twAnchorInfo":{"type":"TwZhiBoUser","id":66},"type":{"type":"int32","id":7},"uk":{"type":"string","id":107},"userType":{"type":"int32","id":19},"userhide":{"type":"int32","id":9},"vipInfo":{"type":"UserVipInfo","id":61},"workCreatorInfo":{"type":"WorkCreatorInfo","id":124},"userGrowth":{"type":"UserGrowth","id":137},"themeTail":{"type":"ThemeTailInUser","id":141},"editConfig":{"type":"EditConfig","id":126},"levelName":{"type":"string","id":125}}},"TshowInfo":{"fields":{"icon":{"type":"string","id":1},"name":{"type":"string","id":2},"url":{"type":"string","id":3}}},"PayMemberInfo":{"fields":{"endTime":{"type":"int32","id":2},"picUrl":{"type":"string","id":5},"propsId":{"type":"int32","id":1}}},"Pendant":{"fields":{"imgUrl":{"type":"string","id":2},"propsId":{"type":"uint64","id":1},"dynamicUrl":{"type":"string","id":3}}},"PrivSets":{"fields":{"bazhuShowInside":{"type":"int32","id":8},"bazhuShowOutside":{"type":"int32","id":9},"friend":{"type":"int32","id":5},"group":{"type":"int32","id":3},"like":{"type":"int32","id":2},"live":{"type":"int32","id":6},"location":{"type":"int32","id":1},"post":{"type":"int32","id":4},"reply":{"type":"int32","id":7}}},"TwAnchorProfitItem":{"fields":{"availableAnchorLevel":{"type":"uint32","id":2},"iconLockUrl":{"type":"string","id":5},"iconUnlockUrl":{"type":"string","id":4},"id":{"type":"int32","id":1},"name":{"type":"string","id":3}}},"TbVipInfo":{"fields":{"intro":{"type":"string","id":1},"vDetail":{"type":"string","id":3},"vUrl":{"type":"string","id":2}}},"ThemeCardInUser":{"fields":{"imgAndroid":{"type":"string","id":4},"imgIos":{"type":"string","id":2},"level":{"type":"uint32","id":5},"propsId":{"type":"uint64","id":1},"dynamicUrl":{"type":"string","id":6},"exclusiveNo":{"type":"string","id":7},"jumpUrl":{"type":"string","id":8}}},"TwZhiBoUser":{"fields":{"anchorLevel":{"type":"uint32","id":1},"fieldEx":{"type":"string","id":3},"inBlackList":{"type":"uint32","id":2}}},"UserVipInfo":{"fields":{"aScore":{"type":"int32","id":6},"eTime":{"type":"uint32","id":3},"extScore":{"type":"uint32","id":4},"iconUrl":{"type":"string","id":8},"nScore":{"type":"uint32","id":7},"sTime":{"type":"uint32","id":2},"vLevel":{"type":"uint32","id":5},"vStatus":{"type":"uint32","id":1}}},"WorkCreatorInfo":{"fields":{"authDesc":{"type":"string","id":1}}},"UserGrowth":{"fields":{"levelId":{"type":"uint32","id":1},"score":{"type":"int64","id":2},"targetScore":{"type":"int64","id":3},"taskInfo":{"rule":"repeated","type":"UserTaskInfo","id":5},"tmoney":{"type":"double","id":4}}},"UserTaskInfo":{"fields":{"actType":{"type":"string","id":10},"brief":{"type":"string","id":3},"currNum":{"type":"int32","id":7},"id":{"type":"int64","id":1},"name":{"type":"string","id":2},"status":{"type":"int32","id":5},"targetNum":{"type":"int32","id":6},"targetScheme":{"type":"string","id":11},"taskIconUrl":{"type":"string","id":4},"taskType":{"type":"int32","id":8},"weight":{"type":"int32","id":9}}},"ThemeTailInUser":{"fields":{"dynamic":{"type":"string","id":2},"propsId":{"type":"string","id":3},"url":{"type":"string","id":1}}},"PbContent":{"fields":{"_static":{"type":"string","id":17},"bigCdnSrc":{"type":"string","id":9},"bsize":{"type":"string","id":5},"c":{"type":"string","id":11},"cdnSrc":{"type":"string","id":8},"cdnSrcActive":{"type":"string","id":36},"count":{"type":"int32","id":28},"duringTime":{"type":"uint32","id":13},"dynamic":{"type":"string","id":16},"eType":{"type":"uint32","id":24},"graffitiInfo":{"type":"GraffitiInfo","id":29},"height":{"type":"uint32","id":19},"isLongPic":{"type":"uint32","id":34},"isNativeApp":{"type":"uint32","id":22},"itemForumName":{"type":"string","id":39},"itemId":{"type":"uint64","id":38},"link":{"type":"string","id":3},"memeInfo":{"type":"MemeInfo","id":33},"nativeApp":{"type":"NativeApp","id":23},"originSize":{"type":"uint32","id":27},"originSrc":{"type":"string","id":25},"packetName":{"type":"string","id":20},"phonetype":{"type":"string","id":21},"picId":{"type":"int64","id":42},"showOriginalBtn":{"type":"uint32","id":35},"src":{"type":"string","id":4},"text":{"type":"string","id":2},"tiebaplusInfo":{"type":"TiebaPlusInfo","id":40},"type":{"type":"uint32","id":1},"uid":{"type":"int64","id":15},"width":{"type":"uint32","id":18},"urlType":{"type":"int32","id":32},"voiceMd5":{"type":"string","id":12},"isSub":{"type":"uint32","id":14}}},"TiebaPlusInfo":{"fields":{"appCompany":{"type":"string","id":11},"appIcon":{"type":"string","id":6},"appId":{"type":"string","id":5},"appPackage":{"type":"string","id":7},"appPower":{"type":"string","id":10},"appPrivacy":{"type":"string","id":9},"appVersion":{"type":"string","id":8},"buttonDesc":{"type":"string","id":23},"desc":{"type":"string","id":2},"downloadUrl":{"type":"string","id":4},"forumName":{"type":"string","id":20},"h5JumpNumber":{"type":"string","id":14},"h5JumpParam":{"type":"string","id":15},"h5JumpType":{"type":"int32","id":13},"isAppoint":{"type":"int32","id":18},"itemId":{"type":"string","id":17},"jumpSetting":{"type":"int32","id":21},"jumpType":{"type":"int32","id":16},"jumpUrl":{"type":"string","id":3},"pluginUser":{"type":"PluginUser","id":19},"targetType":{"type":"int32","id":12},"title":{"type":"string","id":1},"wxThumbnail":{"type":"string","id":22}}},"PluginUser":{"fields":{"isDownloadCardWhiteuser":{"type":"int32","id":5},"userId":{"type":"int64","id":1},"userNameShow":{"type":"string","id":2},"userPhoto":{"type":"string","id":4},"userType":{"type":"int32","id":3}}},"PollInfo":{"fields":{"endTime":{"type":"int32","id":8},"isMulti":{"type":"int32","id":2},"isPolled":{"type":"int32","id":5},"lastTime":{"type":"uint32","id":13},"options":{"rule":"repeated","type":"PollOption","id":9},"optionsCount":{"type":"int32","id":4},"polledValue":{"type":"string","id":6},"title":{"type":"string","id":12},"totalNum":{"type":"int64","id":3},"totalPoll":{"type":"int64","id":11}}},"PollOption":{"fields":{"id":{"type":"int32","id":1},"num":{"type":"int64","id":2},"text":{"type":"string","id":3}}},"VideoInfo":{"fields":{"firstFrameThumbnail":{"type":"string","id":22},"isVertical":{"type":"uint32","id":15},"playCount":{"type":"int32","id":10},"smallThumbnailUrl":{"type":"string","id":21},"thumbnailHeight":{"type":"uint32","id":8},"thumbnailUrl":{"type":"string","id":6},"thumbnailWidth":{"type":"uint32","id":7},"videoDesc":{"rule":"repeated","type":"VideoDesc","id":12},"videoDuration":{"type":"uint32","id":3},"videoHeight":{"type":"uint32","id":5},"videoLength":{"type":"int32","id":9},"videoMd5":{"type":"string","id":1},"videoType":{"type":"uint32","id":14},"videoUrl":{"type":"string","id":2},"videoWidth":{"type":"uint32","id":4}}},"VideoDesc":{"fields":{"videoHeight":{"type":"string","id":5},"videoId":{"type":"int32","id":1},"videoUrl":{"type":"string","id":3},"videoWidth":{"type":"string","id":4}}},"Page":{"fields":{"curGoodId":{"type":"int32","id":8},"currentPage":{"type":"int32","id":3},"hasMore":{"type":"int32","id":6},"hasPrev":{"type":"int32","id":7},"newTotalPage":{"type":"int32","id":14},"offset":{"type":"int32","id":2},"pageSize":{"type":"int32","id":1},"pnum":{"type":"int32","id":10},"reqNum":{"type":"int32","id":9},"tnum":{"type":"int32","id":11},"totalCount":{"type":"int32","id":4},"totalNum":{"type":"int32","id":12},"totalPage":{"type":"int32","id":5}}},"PbGoodsInfo":{"fields":{"goodsFrom":{"type":"string","id":6},"goodsImage":{"type":"string","id":2},"goodsPrice":{"type":"string","id":3},"goodsTitle":{"type":"string","id":1},"goodsUrl":{"type":"string","id":4},"goodsUrlH5":{"type":"string","id":7},"sort":{"type":"uint32","id":5}}},"PbLinkInfo":{"fields":{"extTxt":{"type":"string","id":5},"linkFrom":{"type":"string","id":4},"picUrl":{"type":"string","id":3},"sort":{"type":"uint32","id":6},"title":{"type":"string","id":1},"toUrl":{"type":"string","id":2},"urlType":{"type":"int32","id":7}}},"PbPresent":{"fields":{"total":{"type":"uint32","id":1}}},"Post":{"fields":{"agree":{"type":"Agree","id":37},"author":{"type":"User","id":23},"authorId":{"type":"int64","id":19},"bimgUrl":{"type":"string","id":17},"content":{"rule":"repeated","type":"PbContent","id":5},"customFigure":{"type":"CustomFigure","id":60},"customState":{"type":"CustomState","id":61},"floor":{"type":"uint32","id":3},"foldCommentApplyUrl":{"type":"string","id":57},"foldCommentStatus":{"type":"int32","id":56},"foldTip":{"type":"string","id":44},"id":{"type":"uint64","id":1},"imgNumAbtest":{"type":"int32","id":41},"iosBimgFormat":{"type":"string","id":18},"isBub":{"type":"uint32","id":11},"isFold":{"type":"int32","id":43},"isPostVisible":{"type":"int32","id":39},"isTopAgreePost":{"type":"int32","id":45},"isVoice":{"type":"uint32","id":9},"isVote":{"type":"uint32","id":8},"isWonderfulPost":{"type":"int32","id":51},"lbsInfo":{"type":"Lbs","id":7},"needLog":{"type":"int32","id":40},"outerItem":{"type":"Item","id":54},"present":{"type":"PbPresent","id":28},"showSquared":{"type":"int32","id":47},"signature":{"type":"SignatureData","id":21},"subPostList":{"type":"SubPost","id":15},"subPostNumber":{"type":"uint32","id":13},"tailInfo":{"type":"TailInfo","id":22},"tid":{"type":"int64","id":46},"time":{"type":"uint32","id":4},"title":{"type":"string","id":2},"dynamicUrl":{"type":"string","id":63},"itemStar":{"rule":"repeated","type":"HeadItem","id":52},"item":{"type":"Item","id":53},"bubbleInfo":{"type":"ThemeBubble","id":64},"rumorSourceImg":{"type":"string","id":65},"advertisement":{"type":"Advertisement","id":55}}},"SignatureData":{"fields":{"content":{"rule":"repeated","type":"SignatureContent","id":4},"fontColor":{"type":"string","id":3},"fontKeyName":{"type":"string","id":2},"signatureId":{"type":"int32","id":1}}},"SignatureContent":{"fields":{"text":{"type":"string","id":2},"type":{"type":"int32","id":1}}},"SubPost":{"fields":{"subPostList":{"rule":"repeated","type":"SubPostList","id":2}}},"SubPostList":{"fields":{"authorId":{"type":"int64","id":4},"content":{"rule":"repeated","type":"PbContent","id":2},"floor":{"type":"uint32","id":6},"id":{"type":"uint64","id":1},"time":{"type":"uint32","id":3},"title":{"type":"string","id":5}}},"TailInfo":{"fields":{"content":{"type":"string","id":4},"iconLink":{"type":"string","id":3},"iconUrl":{"type":"string","id":2},"tailType":{"type":"int32","id":1}}},"ThemeBubble":{"fields":{"jumpUrl":{"type":"string","id":3},"packageId":{"type":"int32","id":2},"propsId":{"type":"int32","id":1}}},"RecommendInfo":{"fields":{"title":{"type":"string","id":1},"userList":{"rule":"repeated","type":"SchoolRecomUserInfo","id":2}}},"SchoolRecomUserInfo":{"fields":{"institute":{"type":"string","id":4},"isLiked":{"type":"uint32","id":5},"portrait":{"type":"string","id":3},"uid":{"type":"uint64","id":1},"uname":{"type":"string","id":2}}},"RecommendTip":{"fields":{"isFollow":{"type":"string","id":2},"reason":{"type":"string","id":1}}},"RecomTagInfo":{"fields":{"id":{"type":"int32","id":1},"name":{"type":"string","id":2},"pic":{"type":"string","id":3}}},"RecomTopicList":{"fields":{"discussNum":{"type":"uint64","id":4},"tag":{"type":"uint32","id":5},"topicDesc":{"type":"string","id":6},"topicId":{"type":"uint64","id":1},"topicName":{"type":"string","id":2},"topicPic":{"type":"string","id":7},"type":{"type":"uint32","id":3}}},"RewardCard":{"fields":{"bannerJumpUrl":{"type":"string","id":15},"buttonText":{"type":"string","id":7},"endText":{"type":"string","id":5},"endTime":{"type":"string","id":6},"headImgs":{"rule":"repeated","type":"string","id":13},"icon":{"type":"string","id":2},"id":{"type":"string","id":1},"joinNum":{"type":"string","id":9},"joinSuccText":{"type":"string","id":14},"jumpUrl":{"type":"string","id":8},"rewardMaterial":{"rule":"repeated","type":"RewardMaterial","id":11},"startText":{"type":"string","id":4},"title":{"type":"string","id":3},"totalNum":{"type":"string","id":12}}},"RewardMaterial":{"fields":{"icon":{"type":"string","id":1},"isMatched":{"type":"int32","id":3},"isNewestMatchedLevel":{"type":"int32","id":4},"unlockLevel":{"type":"string","id":2}}},"ServiceArea":{"fields":{"picurl":{"type":"string","id":2},"servicename":{"type":"string","id":1},"serviceurl":{"type":"string","id":3},"thirdStatisticsUrl":{"rule":"repeated","type":"string","id":8}}},"SimpleForum":{"fields":{"avatar":{"type":"string","id":4},"deletedReasonInfo":{"type":"DeletedReasonInfo","id":17},"firstClass":{"type":"string","id":7},"id":{"type":"int64","id":1},"isBrandForum":{"type":"int32","id":14},"isExists":{"type":"int32","id":3},"isFrsMask":{"type":"int32","id":18},"isLiked":{"type":"uint32","id":5},"memberNum":{"type":"int32","id":12},"name":{"type":"string","id":2},"postNum":{"type":"int32","id":13},"secondClass":{"type":"string","id":8},"themeColor":{"type":"ThemeColorInfo","id":19},"recommendTip":{"type":"string","id":20},"showInfo":{"type":"ForumShowInfo","id":22},"spritePbGuide":{"type":"SpritePBGuide","id":23}}},"SpritePBGuide":{"fields":{"buttonText":{"type":"string","id":3},"guideText":{"type":"string","id":2},"guideType":{"type":"int64","id":1},"jumpUrl":{"type":"string","id":4}}},"SmartApp":{"fields":{"_abstract":{"type":"string","id":3},"avatar":{"type":"string","id":1},"h5Url":{"type":"string","id":5},"id":{"type":"string","id":6},"isGame":{"type":"int32","id":10},"isRecom":{"type":"int32","id":9},"link":{"type":"string","id":7},"name":{"type":"string","id":2},"nawsAppId":{"type":"uint64","id":8},"pic":{"type":"string","id":4}}},"SortOption":{"fields":{"name":{"type":"string","id":1},"sortType":{"type":"int32","id":2}}},"StarEnter":{"fields":{"bazhuMark":{"type":"int32","id":10},"icon":{"type":"string","id":1},"text":{"type":"string","id":8},"time":{"type":"int32","id":6},"title":{"type":"string","id":2},"type":{"type":"int32","id":4},"url":{"type":"string","id":5},"weight":{"type":"int32","id":3}}},"TaskInfo":{"fields":{"bgimg":{"type":"string","id":3},"cardType":{"type":"int32","id":15},"endTime":{"type":"int64","id":6},"floorGodReply":{"type":"string","id":14},"forumId":{"type":"int64","id":8},"forumName":{"type":"string","id":9},"isGodReply":{"type":"int32","id":13},"objId":{"type":"string","id":10},"rewardCard":{"type":"RewardCard","id":12},"startTime":{"type":"int64","id":5},"taskId":{"type":"int64","id":1},"threadId":{"type":"int64","id":2},"threadImg":{"type":"string","id":4},"threadImgSize":{"type":"string","id":7},"voteSchema":{"type":"VoteSchema","id":11}}},"VoteSchema":{"fields":{"jumpUrl":{"type":"string","id":3},"textAfterVote":{"type":"string","id":2},"textBeforeVote":{"type":"string","id":1}}},"ThreadIdListInfo":{"fields":{"isPartialVisible":{"type":"int32","id":2},"tid":{"type":"int64","id":1}}},"ThreadInfo":{"fields":{"_abstract":{"rule":"repeated","type":"Abstract","id":21},"abTag":{"type":"string","id":108},"agree":{"type":"Agree","id":126},"agreeNum":{"type":"int32","id":124},"alaInfo":{"type":"AlaLiveInfo","id":113},"articleCover":{"type":"string","id":162},"author":{"type":"User","id":18},"authorId":{"type":"int64","id":56},"bjhContentTag":{"type":"int32","id":163},"categoryName":{"type":"string","id":73},"cheakRepeat":{"type":"uint32","id":107},"clickMonitorUrl":{"type":"string","id":206},"clickUrl":{"type":"string","id":32},"collectMarkPid":{"type":"string","id":51},"collectNum":{"type":"uint32","id":190},"collectStatus":{"type":"int32","id":50},"commentNum":{"type":"int32","id":20},"createTime":{"type":"int32","id":45},"customFigure":{"type":"CustomFigure","id":211},"customState":{"type":"CustomState","id":212},"dislikeInfo":{"rule":"repeated","type":"DislikeInfo","id":120},"exposureMonitorUrl":{"type":"string","id":205},"fid":{"type":"int64","id":27},"firstPostContent":{"rule":"repeated","type":"PbContent","id":142},"firstPostId":{"type":"int64","id":40},"fname":{"type":"string","id":28},"forumInfo":{"type":"SimpleForum","id":155},"id":{"type":"int64","id":1},"isActivity":{"type":"int32","id":16},"isBakan":{"type":"int32","id":12},"isBjh":{"type":"int32","id":161},"isBookChapter":{"type":"uint32","id":103},"isBub":{"type":"int32","id":39},"isCalled":{"type":"int32","id":136},"isDeal":{"type":"int32","id":97},"isDeleted":{"type":"int32","id":181},"isFrsMask":{"type":"int32","id":198},"isGod":{"type":"int32","id":131},"isGodthreadRecommend":{"type":"int32","id":85},"isGood":{"type":"int32","id":10},"isHeadlinepost":{"type":"int32","id":165},"isHighlight":{"type":"int32","id":213},"isLinkThread":{"type":"int32","id":128},"isLivepost":{"type":"int32","id":30},"isMeizhi":{"type":"int32","id":14},"isMembertop":{"type":"int32","id":54},"isMultiforumThread":{"type":"int32","id":123},"isNotice":{"type":"int32","id":17},"isNovel":{"type":"int32","id":76},"isNovelReward":{"type":"int32","id":78},"isNovelThank":{"type":"int32","id":77},"isNtitle":{"type":"int32","id":38},"isPartialVisible":{"type":"int32","id":127},"isPic":{"type":"int32","id":43},"isPictxt":{"type":"int32","id":204},"isProtal":{"type":"int32","id":13},"isSCard":{"type":"uint32","id":170},"isShareThread":{"type":"int32","id":143},"isTiebaplusAd":{"type":"string","id":193},"isTop":{"type":"int32","id":9},"isTopic":{"type":"int32","id":148},"isVideobiggieRecomthread":{"type":"int32","id":153},"isVoiceThread":{"type":"int32","id":15},"isVote":{"type":"int32","id":11},"lastReadPid":{"type":"uint64","id":106},"lastReplyer":{"type":"User","id":19},"lastTime":{"type":"string","id":6},"lastTimeInt":{"type":"int32","id":7},"legoCard":{"type":"string","id":94},"livecoverSrc":{"type":"string","id":67},"location":{"type":"Lbs","id":62},"media":{"rule":"repeated","type":"Media","id":22},"mediaNum":{"rule":"repeated","type":"MediaNum","id":25},"nid":{"type":"string","id":164},"originThreadInfo":{"type":"OriginThreadInfo","id":141},"pbLinkInfo":{"rule":"repeated","type":"PbLinkInfo","id":178},"pollInfo":{"type":"PollInfo","id":74},"postId":{"type":"int64","id":52},"recomReason":{"type":"string","id":109},"recomSource":{"type":"string","id":104},"recomWeight":{"type":"string","id":105},"recommendTip":{"type":"RecommendTip","id":202},"replyNum":{"type":"int32","id":4},"richAbstract":{"rule":"repeated","type":"PbContent","id":112},"richTitle":{"rule":"repeated","type":"PbContent","id":111},"scardPacketId":{"type":"string","id":171},"shareNum":{"type":"int64","id":135},"showCommented":{"type":"int32","id":31},"storecount":{"type":"int32","id":68},"tShareImg":{"type":"string","id":159},"tabId":{"type":"int32","id":175},"tabName":{"type":"string","id":176},"threadRecommendInfos":{"rule":"repeated","type":"ThreadRecommendInfo","id":191},"threadShareLink":{"type":"string","id":172},"threadType":{"type":"int32","id":26},"threadTypes":{"type":"int32","id":8},"tid":{"type":"int64","id":2},"tiebaplusCantDelete":{"type":"int32","id":197},"tiebaplusExtraParam":{"type":"string","id":196},"tiebaplusOrderId":{"type":"string","id":194},"tiebaplusToken":{"type":"string","id":195},"title":{"type":"string","id":3},"topAgreePost":{"type":"Post","id":125},"topic":{"type":"Topic","id":47},"topicH5Url":{"type":"string","id":150},"topicUserName":{"type":"string","id":149},"twzhiboInfo":{"type":"ZhiBoInfoTW","id":72},"videoInfo":{"type":"VideoInfo","id":79},"viewNum":{"type":"int32","id":5},"wonderfulPostInfo":{"type":"string","id":177},"worksInfo":{"type":"WorksInfo","id":189},"zan":{"type":"Zan","id":41},"tiebaplusAd":{"type":"TiebaPlusAd","id":201},"itemStar":{"rule":"repeated","type":"HeadItem","id":180},"threadRecommendTag":{"type":"ThreadRecommendTag","id":210},"item":{"type":"Item","id":179},"taskInfo":{"type":"TaskInfo","id":83},"isXiuxiuThread":{"type":"int32","id":214},"nawsInfo":{"type":"SmartApp","id":156},"editInfo":{"type":"EditInfo","id":203},"isExcellentThread":{"type":"int32","id":219}}},"ThreadRecommendInfo":{"fields":{"backgroundColor":{"type":"ThemeColorInfo","id":13},"recommendIcon":{"type":"string","id":9},"recommendReason":{"type":"string","id":5},"recommendReasonColor":{"type":"ThemeColorInfo","id":11},"recommendType":{"type":"string","id":7},"recommendTypeColor":{"type":"ThemeColorInfo","id":10},"stripColor":{"type":"ThemeColorInfo","id":12},"topicId":{"type":"int64","id":6},"recommendTail":{"type":"string","id":8},"jumpLink":{"type":"string","id":14}}},"Topic":{"fields":{"isLpost":{"type":"int32","id":1},"link":{"type":"string","id":3}}},"ZhiBoInfoTW":{"fields":{"content":{"type":"string","id":11},"copythreadRemind":{"type":"uint32","id":20},"fieldEx":{"type":"string","id":22},"forumId":{"type":"uint64","id":8},"forumName":{"type":"string","id":7},"freqNum":{"type":"uint32","id":19},"isCopytwzhibo":{"type":"uint32","id":21},"isHeadline":{"type":"int32","id":17},"lastModifiedTime":{"type":"uint64","id":9},"livecoverSrc":{"type":"string","id":2},"livecoverSrcBsize":{"type":"string","id":3},"livecoverSrcStatus":{"type":"string","id":15},"postNum":{"type":"uint32","id":4},"replyNum":{"type":"uint32","id":5},"threadId":{"type":"uint64","id":1},"title":{"type":"string","id":10},"user":{"type":"User","id":12},"zan":{"type":"Zan","id":6}}},"Zan":{"fields":{"isLiked":{"type":"int32","id":3},"lastTime":{"type":"int32","id":4},"num":{"type":"int32","id":1}}},"WorksInfo":{"fields":{"isWorks":{"type":"int32","id":1},"tagList":{"type":"VideoTags","id":3}}},"VideoTags":{"fields":{"first":{"type":"string","id":1},"second":{"type":"string","id":2},"tags":{"rule":"repeated","type":"string","id":3}}},"TiebaPlusAd":{"fields":{"adSource":{"type":"string","id":3},"costUrl":{"type":"string","id":1},"showUrl":{"type":"string","id":2}}},"ThreadRecommendTag":{"fields":{"backgroundColor":{"type":"ThemeColorInfo","id":3},"text":{"type":"string","id":1},"textColor":{"type":"ThemeColorInfo","id":2}}},"VitalityInfo":{"fields":{"frequentlyForumInfo":{"type":"FrequentlyForumInfo","id":1}}},"frs":{"nested":{"ActivityHead":{"fields":{"activityTitle":{"type":"string","id":2},"activityType":{"type":"int32","id":1},"headImgs":{"rule":"repeated","type":"HeadImgs","id":3},"isAd":{"type":"bool","id":13},"objId":{"type":"string","id":5},"pullDownClickUrl":{"type":"string","id":12},"pullDownExposureUrl":{"type":"string","id":11},"pullDownInterval":{"type":"int32","id":8},"pullDownPackageName":{"type":"string","id":15},"pullDownPicAndroid":{"type":"string","id":10},"pullDownPicIos":{"type":"string","id":9},"pullDownSchema":{"type":"string","id":14},"pullDownUrl":{"type":"string","id":7},"topSize":{"type":"Size","id":4}}},"CoverImageColor":{"fields":{"model":{"type":"int32","id":2},"value":{"type":"string","id":1}}},"DataRes":{"fields":{"activityhead":{"type":"ActivityHead","id":23},"adSampleMapKey":{"type":"string","id":114},"adShowSelect":{"type":"int32","id":112},"agreeBanner":{"type":"AgreeBanner","id":65},"anti":{"type":"Anti","id":5},"aspShownInfo":{"type":"string","id":56},"ctime":{"type":"int32","id":12},"fortuneBag":{"type":"int32","id":10},"fortuneDesc":{"type":"string","id":19},"forum":{"type":"ForumInfo","id":2},"forumRule":{"type":"ForumRuleStatus","id":105},"frsStar":{"type":"StarInfo","id":3},"frsTabDefault":{"type":"int32","id":38},"frsTabInfo":{"rule":"repeated","type":"FrsTabInfo","id":22},"gameDefaultTabId":{"type":"int32","id":74},"gconAccount":{"type":"GconAccount","id":18},"group":{"type":"Group","id":6},"hotUserEntry":{"type":"HotUserRankEntry","id":102},"isGetHorseRaceLamp":{"type":"int32","id":104},"isNewUrl":{"type":"int32","id":9},"itemInfo":{"type":"ItemInfo","id":103},"logid":{"type":"int64","id":13},"navTabInfo":{"type":"NavTabInfo","id":37},"needLog":{"type":"int32","id":48},"page":{"type":"Page","id":4},"partialVisibleToast":{"type":"string","id":62},"privateForumActiveInfo":{"type":"ForumActiveInfo","id":98},"serverTime":{"type":"int32","id":14},"serviceArea":{"rule":"repeated","type":"ServiceArea","id":100},"showAdsense":{"type":"int32","id":108},"smartFrsType":{"type":"int32","id":47},"sortType":{"type":"int32","id":39},"starEnter":{"rule":"repeated","type":"StarEnter","id":20},"threadIdList":{"rule":"repeated","type":"int64","id":8},"threadIdListInfo":{"rule":"repeated","type":"ThreadIdListInfo","id":64},"threadList":{"rule":"repeated","type":"ThreadInfo","id":7},"time":{"type":"int32","id":11},"user":{"type":"User","id":1},"userList":{"rule":"repeated","type":"User","id":17},"videoAutoPlay":{"type":"int32","id":93},"vitalityInfo":{"type":"VitalityInfo","id":42},"voiceRoomConfig":{"type":"int32","id":111},"headSdk":{"type":"HeadSdk","id":34},"frsGameTabInfo":{"rule":"repeated","type":"FrsTabInfo","id":68},"isMemberBroadcastForum":{"type":"int32","id":119},"forumGroup":{"type":"ForumGroup","id":120}}},"Fans":{"fields":{"isGet":{"type":"int32","id":4},"leftTime":{"type":"int32","id":2},"num":{"type":"int32","id":5},"open":{"type":"int32","id":3},"startTime":{"type":"int32","id":1}}},"FeedGroupInfo":{"fields":{"jumpUrl":{"type":"string","id":2},"name":{"type":"string","id":1}}},"ForumGroup":{"fields":{"feedCard":{"type":"GroupFeedCard","id":2},"topbarEntrance":{"type":"TopbarEntrance","id":1}}},"ForumInfo":{"fields":{"accelerateCotent":{"type":"string","id":50},"albumOpenPhotoFrs":{"type":"int32","id":23},"avatar":{"type":"string","id":24},"banner":{"type":"Banner","id":32},"bannerList":{"type":"BannerList","id":33},"canUseAccelerate":{"type":"int32","id":49},"curScore":{"type":"int32","id":13},"deletedReasonInfo":{"type":"DeletedReasonInfo","id":85},"fShareImg":{"type":"string","id":78},"firstClass":{"type":"string","id":3},"forumGameLabel":{"type":"string","id":66},"forumShareLink":{"type":"string","id":79},"forumvipShowIcon":{"type":"MemberShowIcon","id":55},"gameName":{"type":"string","id":54},"gameUrl":{"type":"string","id":47},"goodClassify":{"rule":"repeated","type":"Classify","id":21},"hasFrsStar":{"type":"int32","id":12},"hasGame":{"type":"int32","id":46},"hasPostpre":{"type":"int32","id":26},"id":{"type":"int64","id":1},"isBrandForum":{"type":"int32","id":71},"isFrsMask":{"type":"int32","id":86},"isLike":{"type":"int32","id":6},"isLiveGameForum":{"type":"int32","id":63},"isNewGameForum":{"type":"int32","id":65},"isPrivateForum":{"type":"int32","id":75},"isShowAllTopThread":{"type":"int32","id":72},"isShowBawutask":{"type":"int32","id":77},"isShowForumrule":{"type":"int32","id":84},"levelId":{"type":"int32","id":35},"levelName":{"type":"string","id":8},"levelupScore":{"type":"int32","id":14},"managers":{"rule":"repeated","type":"Manager","id":17},"memberNum":{"type":"int32","id":9},"name":{"type":"string","id":2},"postNum":{"type":"int32","id":11},"riskTipNotice":{"type":"string","id":81},"riskTipPop":{"type":"string","id":80},"riskTipPopTitle":{"type":"string","id":82},"secondClass":{"type":"string","id":4},"signInInfo":{"type":"SignInfo","id":15},"slogan":{"type":"string","id":25},"specialForumType":{"type":"string","id":68},"superboy":{"type":"string","id":40},"tagInfo":{"type":"TagInfo","id":38},"themeColor":{"type":"ThemeColorInfo","id":73},"threadNum":{"type":"int32","id":10},"topicSpecialIcon":{"type":"string","id":69},"topicSpecialIconRight":{"type":"string","id":70},"userLevel":{"type":"int32","id":7},"warningMsg":{"type":"string","id":67},"postPrefix":{"type":"PostPrefix","id":39}}},"FrsPageResIdl":{"fields":{"data":{"type":"DataRes","id":2},"error":{"type":"Error","id":1}}},"GroupFeedCard":{"fields":{"cardTitle":{"type":"string","id":1},"groupList":{"rule":"repeated","type":"FeedGroupInfo","id":3},"index":{"type":"uint32","id":2}}},"HeadImgs":{"fields":{"btnText":{"type":"string","id":5},"coverImageColor":{"type":"CoverImageColor","id":26},"coverUrl":{"type":"string","id":24},"downloadAppid":{"type":"string","id":23},"downloadAppname":{"type":"string","id":13},"downloadDeveloper":{"type":"string","id":14},"downloadImg":{"type":"string","id":17},"downloadIsThirdpage":{"type":"int32","id":12},"downloadItemId":{"type":"int32","id":22},"downloadPackageName":{"type":"string","id":21},"downloadPackageSize":{"type":"string","id":15},"downloadPrivacyPolicy":{"type":"string","id":20},"downloadUrl":{"type":"string","id":16},"downloadUserPower":{"type":"string","id":19},"downloadVersion":{"type":"string","id":18},"hasSecondPage":{"type":"uint32","id":10},"imgUrl":{"type":"string","id":1},"packageName":{"type":"string","id":11},"pcUrl":{"type":"string","id":2},"playUrl":{"type":"string","id":25},"schema":{"type":"string","id":8},"subtitle":{"type":"string","id":4},"tagNameUrl":{"type":"string","id":6},"tagNameWh":{"type":"string","id":7},"thirdStatisticsUrl":{"rule":"repeated","type":"string","id":9},"title":{"type":"string","id":3},"videoImageColor":{"rule":"repeated","type":"VideoImageColor","id":27}}},"PostPrefix":{"fields":{"mode":{"type":"int32","id":1},"text":{"type":"string","id":2},"time":{"type":"string","id":4},"type":{"type":"string","id":3}}},"SignForum":{"fields":{"isOn":{"type":"int32","id":1}}},"SignInfo":{"fields":{"forumInfo":{"type":"SignForum","id":2},"userInfo":{"type":"SignUser","id":1},"hasChatroomSign":{"type":"int32","id":3}}},"SignUser":{"fields":{"cSignNum":{"type":"int32","id":8},"contSignNum":{"type":"int32","id":5},"hunSignNum":{"type":"int32","id":9},"isOrgDisabled":{"type":"int32","id":7},"isSignIn":{"type":"int32","id":2},"missSignNum":{"type":"int32","id":11},"signTime":{"type":"int32","id":4},"totalResignNum":{"type":"int32","id":10},"userId":{"type":"int64","id":1},"userSignRank":{"type":"int32","id":3}}},"Size":{"fields":{"height":{"type":"int32","id":2},"width":{"type":"int32","id":1}}},"StarInfo":{"fields":{"hasFrsStar":{"type":"int32","id":1},"head":{"type":"string","id":3},"starForumHeadimg":{"type":"string","id":17},"top":{"type":"string","id":2},"fans":{"type":"Fans","id":6},"topSize":{"type":"Size","id":14},"headSize":{"type":"Size","id":15}}},"TagInfo":{"fields":{"color":{"type":"int32","id":4},"firstCategory":{"type":"string","id":12},"forumId":{"type":"int64","id":1},"hotValue":{"type":"int32","id":5},"influence":{"type":"int32","id":8},"opTime":{"type":"int32","id":10},"recomTag":{"type":"RecomTagInfo","id":11},"relationWeight":{"type":"int32","id":9},"tagId":{"type":"int32","id":2},"tagLevel":{"type":"int32","id":7},"tagName":{"type":"string","id":3},"tagType":{"type":"int32","id":6}}},"TopbarEntrance":{"fields":{"guideTipFirstText":{"type":"string","id":1},"guideTipText":{"type":"string","id":2},"jumpUrl":{"type":"string","id":3}}},"VideoImageColor":{"fields":{"color":{"type":"string","id":2},"time":{"type":"uint32","id":1}}}}},"threadlist":{"nested":{"DataRes":{"fields":{"adSampleMapKey":{"type":"string","id":8},"adShowSelect":{"type":"int32","id":7},"bannerList":{"type":"BannerList","id":3},"partialVisibleToast":{"type":"string","id":5},"threadList":{"rule":"repeated","type":"ThreadInfo","id":1},"userList":{"rule":"repeated","type":"User","id":2}}},"ThreadListResIdl":{"fields":{"data":{"type":"DataRes","id":2},"error":{"type":"Error","id":1}}}}},"generaltablelist":{"nested":{"DataRes":{"fields":{"adSampleMapKey":{"type":"string","id":13},"adShowSelect":{"type":"int32","id":11},"appList":{"rule":"repeated","type":"App","id":10},"generalList":{"rule":"repeated","type":"ThreadInfo","id":1},"hasMore":{"type":"int32","id":2},"itemInfo":{"type":"ItemInfo","id":8},"sortType":{"type":"int32","id":7},"userList":{"rule":"repeated","type":"User","id":3},"sortOption":{"rule":"repeated","type":"SortOption","id":9}}},"GeneralTabListResIdl":{"fields":{"data":{"type":"DataRes","id":2},"error":{"type":"Error","id":1}}}}},"pb":{"nested":{"BusinessPromotInfo":{"fields":{"isHeadlinepost":{"type":"int32","id":2},"isPromot":{"type":"int64","id":1},"isSCard":{"type":"int32","id":3}}},"DataRes":{"fields":{"anti":{"type":"Anti","id":4},"bannerList":{"type":"BannerList","id":12},"businessPromotInfo":{"type":"BusinessPromotInfo","id":53},"displayForum":{"type":"SimpleForum","id":39},"foldTip":{"type":"string","id":44},"forum":{"type":"SimpleForum","id":2},"forumRule":{"type":"ForumRuleStatus","id":60},"hasFloor":{"type":"int32","id":7},"hasFoldComment":{"type":"int32","id":68},"isBlackWhite":{"type":"int32","id":62},"isNewUrl":{"type":"int32","id":10},"isOfficialForum":{"type":"int32","id":63},"isPurchase":{"type":"int32","id":65},"page":{"type":"Page","id":3},"partialVisibleToast":{"type":"string","id":41},"pbNotice":{"type":"string","id":67},"pbNoticeType":{"type":"int32","id":66},"pbSortInfo":{"rule":"repeated","type":"PbSortType","id":49},"postList":{"rule":"repeated","type":"Post","id":6},"recomAlaInfo":{"type":"AlaLiveInfo","id":55},"serverTime":{"type":"int32","id":14},"showAdsense":{"type":"int32","id":61},"sortType":{"type":"int32","id":50},"switchReadOpen":{"type":"int32","id":32},"thread":{"type":"ThreadInfo","id":8},"threadFreqNum":{"type":"int64","id":37},"threadTopic":{"rule":"repeated","type":"RecomTopicList","id":48},"user":{"type":"User","id":1},"userList":{"rule":"repeated","type":"User","id":13},"floatingIcon":{"type":"FloatingIcon","id":64},"firstFloorPost":{"type":"Post","id":38},"topAnswer":{"type":"Post","id":73}}},"FloatingIconItem":{"fields":{"clickStatisticsUrl":{"type":"string","id":4},"deeplink":{"type":"string","id":5},"displayAdIcon":{"type":"string","id":13},"floatType":{"type":"string","id":10},"foldLottie":{"type":"string","id":8},"foldName":{"type":"string","id":11},"iconUrl":{"type":"string","id":2},"packageName":{"type":"string","id":7},"scheme":{"type":"string","id":6},"unfoldLottie":{"type":"string","id":9},"unfoldName":{"type":"string","id":12},"url":{"type":"string","id":1},"viewStatisticsUrl":{"type":"string","id":3}}},"FloatingIcon":{"fields":{"pbpage":{"type":"FloatingIconItem","id":1}}},"PbPageResIdl":{"fields":{"data":{"type":"DataRes","id":2},"error":{"type":"Error","id":1}}},"PbSortType":{"fields":{"sortName":{"type":"string","id":2},"sortType":{"type":"int32","id":1}}}}},"personalized":{"nested":{"DataRes":{"fields":{"anti":{"type":"Anti","id":16},"liveAnswer":{"type":"LiveAnswer","id":17},"bannerList":{"type":"BannerList","id":9},"freshCtrlNum":{"type":"int32","id":21},"isNewUrl":{"type":"int32","id":8},"sugSeconds":{"type":"uint32","id":6},"threadList":{"rule":"repeated","type":"ThreadInfo","id":2},"threadPersonalized":{"rule":"repeated","type":"ThreadPersonalized","id":7},"userFollowLive":{"type":"UserFollowLive","id":20},"showAdsense":{"type":"int32","id":25}}},"DislikeReason":{"fields":{"dislikeId":{"type":"uint32","id":2},"dislikeReason":{"type":"string","id":1},"extra":{"type":"string","id":3}}},"LiveAnswer":{"fields":{"bannerHigh":{"type":"int32","id":3},"bannerUrl":{"type":"string","id":1},"bannerWidth":{"type":"int32","id":2},"jumpUrl":{"type":"string","id":4},"activityId":{"type":"int64","id":5}}},"PersonalizedResIdl":{"fields":{"data":{"type":"DataRes","id":2},"error":{"type":"Error","id":1}}},"ThreadPersonalized":{"fields":{"abtestTag":{"type":"string","id":4},"dislikeResource":{"rule":"repeated","type":"DislikeReason","id":5},"extra":{"type":"string","id":6},"source":{"type":"string","id":3},"tid":{"type":"uint64","id":1},"weight":{"type":"string","id":2}}},"UserFollowLive":{"fields":{"_switch":{"type":"uint32","id":2}}}}}}}}}; + +const tiebaRoot = protobuf.Root.fromJSON(tiebaJson); +const url = $request.url; +const method = $request.method; +const isQuanX = typeof $task !== "undefined"; +const binaryBody = isQuanX ? new Uint8Array($response.bodyBytes) : $response.body; +let body; + +console.log(`2023-06-15`); +if($request.method !== 'POST'){ + $notification.post('贴吧proto去广告脚本错误', "请求方法不为POST:", url); +} + +if (url.includes("frs/page")) { + console.log('贴吧-FrsPage'); + // model.frs.FrsPageResIdl 并不是json中的完整路径,但可以使用 + let frsPageResIdlType = tiebaRoot.lookupType("model.frs.FrsPageResIdl"); + let frsPageResIdlObj = frsPageResIdlType.decode(binaryBody); + + frsPageResIdlObj.data.threadList = removeLive(frsPageResIdlObj.data.threadList); + if(frsPageResIdlObj.data.activityhead?.isAd){ + console.log('frs去除吧内header图片广告'); + frsPageResIdlObj.data.activityhead = null; + } else { + console.log('无需处理activityhead'); + } + body = frsPageResIdlType.encode(frsPageResIdlObj).finish(); +} else if (url.includes("frs/threadlist")) { + console.log('贴吧-threadlist'); + let threadListResIdlType = tiebaRoot.lookupType("model.threadlist.ThreadListResIdl"); + let threadListResIdlObj = threadListResIdlType.decode(binaryBody); + + body = threadListResIdlType.encode(threadListResIdlObj).finish(); +} else if (url.includes("pb/page")) { + console.log('贴吧-PbPage'); + let pbPageResIdlType = tiebaRoot.lookupType("model.pb.PbPageResIdl"); + let pbPageResIdlObj = pbPageResIdlType.decode(binaryBody); + if(pbPageResIdlObj.data.postList?.length){ + for (const post of pbPageResIdlObj.data.postList) { + if(post.outerItem){ + console.log('outer_item去除'); + post.outerItem = null; + } + } + } else { + console.log('无需处理postList中的outer_item'); + } + if(pbPageResIdlObj.data.recomAlaInfo?.liveId){ + console.log('帖子详情页推荐的直播广告去除'); + pbPageResIdlObj.data.recomAlaInfo = null; + } else { + console.log('帖子详情页无直播广告'); + } + body = pbPageResIdlType.encode(pbPageResIdlObj).finish(); +} else if (url.includes("excellent/personalized")) { + console.log('贴吧-personalized'); + let personalizedResIdlType = tiebaRoot.lookupType("model.personalized.PersonalizedResIdl"); + let personalizedResIdlObj = personalizedResIdlType.decode(binaryBody); + + personalizedResIdlObj.data.threadList = removeLive(personalizedResIdlObj.data.threadList); + if(personalizedResIdlObj.data.liveAnswer){ + console.log('去除推荐页上方的banner广告'); + personalizedResIdlObj.data.liveAnswer = null; + } else { + console.log('推荐页无banner广告'); + } + body = personalizedResIdlType.encode(personalizedResIdlObj).finish(); +} else if (url.includes("frs/generalTabList")) { + console.log('贴吧-generalTabList'); + let generalTabListResIdlType = tiebaRoot.lookupType("model.generaltablelist.GeneralTabListResIdl"); + let generalTabListResIdlObj = generalTabListResIdlType.decode(binaryBody); + body = generalTabListResIdlType.encode(generalTabListResIdlObj).finish(); +} else { + $notification.post('贴吧proto去广告脚本错误', "url匹配错误:", url); +} +// body.byteLength 和 body.buffer.byteLength 不一定相同 (如帖子没有回复/少量回复时) +console.log(`${body.byteLength}---${body.buffer.byteLength}`); +if(isQuanX){ + $done({bodyBytes: body.buffer.slice(body.byteOffset, body.byteLength + body.byteOffset)}); +} else { + $done({body}); +} + +function removeLive(threadList) { + let newThreadList = threadList; + const beforeLength = threadList?.length; + if(beforeLength){ + newThreadList = threadList.filter(item => { + if(item.alaInfo){ + console.log('去除推荐的直播帖子'); + return false; + } + return true; + }); + if(beforeLength === newThreadList.length){ + console.log("无推荐的直播帖子"); + } + } else { + console.log('无需处理threadList'); + } + return newThreadList; +} \ No newline at end of file diff --git a/Scripts/AdBlock/Other/Tieba-2.min.js b/Scripts/AdBlock/Other/Tieba-2.min.js new file mode 100644 index 0000000..9e4f58e --- /dev/null +++ b/Scripts/AdBlock/Other/Tieba-2.min.js @@ -0,0 +1 @@ +let protobuf;!function(g){"use strict";var r,e,i;r={1:[function(t,e,i){e.exports=function(t,e){for(var i=Array(arguments.length-1),n=0,r=2,s=!0;r>2],r=(3&a)<<4,d=1;break;case 1:o[p++]=n[r|a>>4],r=(15&a)<<2,d=2;break;case 2:o[p++]=n[r|a>>6],o[p++]=n[63&a],d=0}8191>4,n=a,p=2;break;case 2:e[i++]=(15&n)<<4|(60&a)>>2,n=a,p=3;break;case 3:e[i++]=(3&n)<<6|a,p=0}}if(1===p)throw Error(o);return i-s},i.test=function(t){return/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(t)}},{}],3:[function(t,e,i){(e.exports=function t(e,i){"string"==typeof e&&(i=e,e=g);var n=[];function r(e){if("string"!=typeof e){var i=s();if(t.verbose&&console.log("codegen: "+i),i="return "+i,e){for(var o=Object.keys(e),p=Array(o.length+1),d=Array(o.length),a=0;a>>0:e<11754943508222875e-54?(r<<31|Math.round(e/1401298464324817e-60))>>>0:(r<<31|127+(t=Math.floor(Math.log(e)/Math.LN2))<<23|8388607&Math.round(e*Math.pow(2,-t)*8388608))>>>0,i,n)}function i(t,e,i){return e=2*((t=t(e,i))>>31)+1,i=t>>>23&255,t&=8388607,255==i?t?NaN:1/0*e:0==i?1401298464324817e-60*e*t:e*Math.pow(2,i-150)*(8388608+t)}function n(t,e,i){y[0]=t,e[i]=u[0],e[i+1]=u[1],e[i+2]=u[2],e[i+3]=u[3]}function d(t,e,i){y[0]=t,e[i]=u[3],e[i+1]=u[2],e[i+2]=u[1],e[i+3]=u[0]}function a(t,e){return u[0]=t[e],u[1]=t[e+1],u[2]=t[e+2],u[3]=t[e+3],y[0]}function l(t,e){return u[3]=t[e],u[2]=t[e+1],u[1]=t[e+2],u[0]=t[e+3],y[0]}var y,u,f,c,h;function g(t,e,i,n,r,s){var o,p=n<0?1:0;0===(n=p?-n:n)?(t(0,r,s+e),t(0<1/n?0:2147483648,r,s+i)):isNaN(n)?(t(0,r,s+e),t(2146959360,r,s+i)):17976931348623157e292>>0,r,s+i)):n<22250738585072014e-324?(t((o=n/5e-324)>>>0,r,s+e),t((p<<31|o/4294967296)>>>0,r,s+i)):(t(4503599627370496*(o=n*Math.pow(2,-(n=1024===(n=Math.floor(Math.log(n)/Math.LN2))?1023:n)))>>>0,r,s+e),t((p<<31|n+1023<<20|1048576*o&1048575)>>>0,r,s+i))}function m(t,e,i,n,r){return e=t(n,r+e),n=2*((t=t(n,r+i))>>31)+1,i=4294967296*(1048575&t)+e,2047==(r=t>>>20&2047)?i?NaN:1/0*n:0==r?5e-324*n*i:n*Math.pow(2,r-1075)*(i+4503599627370496)}function b(t,e,i){f[0]=t,e[i]=c[0],e[i+1]=c[1],e[i+2]=c[2],e[i+3]=c[3],e[i+4]=c[4],e[i+5]=c[5],e[i+6]=c[6],e[i+7]=c[7]}function v(t,e,i){f[0]=t,e[i]=c[7],e[i+1]=c[6],e[i+2]=c[5],e[i+3]=c[4],e[i+4]=c[3],e[i+5]=c[2],e[i+6]=c[1],e[i+7]=c[0]}function I(t,e){return c[0]=t[e],c[1]=t[e+1],c[2]=t[e+2],c[3]=t[e+3],c[4]=t[e+4],c[5]=t[e+5],c[6]=t[e+6],c[7]=t[e+7],f[0]}function T(t,e){return c[7]=t[e],c[6]=t[e+1],c[5]=t[e+2],c[4]=t[e+3],c[3]=t[e+4],c[2]=t[e+5],c[1]=t[e+6],c[0]=t[e+7],f[0]}return"undefined"!=typeof Float32Array?(y=new Float32Array([-0]),h=128===(u=new Uint8Array(y.buffer))[3],t.writeFloatLE=h?n:d,t.writeFloatBE=h?d:n,t.readFloatLE=h?a:l,t.readFloatBE=h?l:a):(t.writeFloatLE=e.bind(null,r),t.writeFloatBE=e.bind(null,s),t.readFloatLE=i.bind(null,o),t.readFloatBE=i.bind(null,p)),"undefined"!=typeof Float64Array?(f=new Float64Array([-0]),h=128===(c=new Uint8Array(f.buffer))[7],t.writeDoubleLE=h?b:v,t.writeDoubleBE=h?v:b,t.readDoubleLE=h?I:T,t.readDoubleBE=h?T:I):(t.writeDoubleLE=g.bind(null,r,0,4),t.writeDoubleBE=g.bind(null,s,4,0),t.readDoubleLE=m.bind(null,o,0,4),t.readDoubleBE=m.bind(null,p,4,0)),t}function r(t,e,i){e[i]=255&t,e[i+1]=t>>>8&255,e[i+2]=t>>>16&255,e[i+3]=t>>>24}function s(t,e,i){e[i]=t>>>24,e[i+1]=t>>>16&255,e[i+2]=t>>>8&255,e[i+3]=255&t}function o(t,e){return(t[e]|t[e+1]<<8|t[e+2]<<16|t[e+3]<<24)>>>0}function p(t,e){return(t[e]<<24|t[e+1]<<16|t[e+2]<<8|t[e+3])>>>0}e.exports=n(n)},{}],7:[function(t,i,n){function r(t){try{var i=eval("require")(t);if(i&&(i.length||Object.keys(i).length))return i}catch(t){}return null}i.exports=r},{}],8:[function(t,e,i){var n=i.isAbsolute=function(t){return/^(?:\/|\w+:)/.test(t)},r=i.normalize=function(t){var e=(t=t.replace(/\\/g,"/").replace(/\/{2,}/g,"/")).split("/"),i=n(t);t="",i&&(t=e.shift()+"/");for(var r=0;r>>1,s=null,o=n;return function(i){return i<1||r>10),s[o++]=56320+(1023&n)):s[o++]=(15&n)<<12|(63&t[e++])<<6|63&t[e++],8191>6|192:(55296==(64512&n)&&56320==(64512&(r=t.charCodeAt(o+1)))?(++o,e[i++]=(n=65536+((1023&n)<<10)+(1023&r))>>18|240,e[i++]=n>>12&63|128):e[i++]=n>>12|224,e[i++]=n>>6&63|128),e[i++]=63&n|128);return i-s}},{}],11:[function(t,e,i){var n=t(14),r=t(33);function s(t,e,i,r){var s=!1;if(e.resolvedType)if(e.resolvedType instanceof n){t("switch(d%s){",r);for(var o=e.resolvedType.values,p=Object.keys(o),d=0;d>>0",r,r);break;case"int32":case"sint32":case"sfixed32":t("m%s=d%s|0",r,r);break;case"uint64":a=!0;case"int64":case"sint64":case"fixed64":case"sfixed64":t("if(util.Long)")("(m%s=util.Long.fromValue(d%s)).unsigned=%j",r,r,a)('else if(typeof d%s==="string")',r)("m%s=parseInt(d%s,10)",r,r)('else if(typeof d%s==="number")',r)("m%s=d%s",r,r)('else if(typeof d%s==="object")',r)("m%s=new util.LongBits(d%s.low>>>0,d%s.high>>>0).toNumber(%s)",r,r,r,a?"true":"");break;case"bytes":t('if(typeof d%s==="string")',r)("util.base64.decode(d%s,m%s=util.newBuffer(util.base64.length(d%s)),0)",r,r,r)("else if(d%s.length >= 0)",r)("m%s=d%s",r,r);break;case"string":t("m%s=String(d%s)",r,r);break;case"bool":t("m%s=Boolean(d%s)",r,r)}}return t}function o(t,e,i,r){if(e.resolvedType)e.resolvedType instanceof n?t("d%s=o.enums===String?(types[%i].values[m%s]===undefined?m%s:types[%i].values[m%s]):m%s",r,i,r,r,i,r,r):t("d%s=types[%i].toObject(m%s,o)",r,i,r);else{var s=!1;switch(e.type){case"double":case"float":t("d%s=o.json&&!isFinite(m%s)?String(m%s):m%s",r,r,r,r);break;case"uint64":s=!0;case"int64":case"sint64":case"fixed64":case"sfixed64":t('if(typeof m%s==="number")',r)("d%s=o.longs===String?String(m%s):m%s",r,r,r)("else")("d%s=o.longs===String?util.Long.prototype.toString.call(m%s):o.longs===Number?new util.LongBits(m%s.low>>>0,m%s.high>>>0).toNumber(%s):m%s",r,r,r,r,s?"true":"",r);break;case"bytes":t("d%s=o.bytes===String?util.base64.encode(m%s,0,m%s.length):o.bytes===Array?Array.prototype.slice.call(m%s):m%s",r,r,r,r,r);break;default:t("d%s=m%s",r,r)}}return t}i.fromObject=function(t){var e=t.fieldsArray,i=r.codegen(["d"],t.name+"$fromObject")("if(d instanceof this.ctor)")("return d");if(!e.length)return i("return new this.ctor");i("var m=new this.ctor");for(var o=0;o>>3){");for(var i=0;i>>3){")("case 1: k=r.%s(); break",o.keyType)("case 2:"),r.basic[p]===g?e("value=types[%i].decode(r,r.uint32())",i):e("value=r.%s()",p),e("break")("default:")("r.skipType(tag2&7)")("break")("}")("}"),r.long[o.keyType]!==g?e('%s[typeof k==="object"?util.longToHash(k):k]=value',d):e("%s[k]=value",d)):o.repeated?(e("if(!(%s&&%s.length))",d,d)("%s=[]",d),r.packed[p]!==g&&e("if((t&7)===2){")("var c2=r.uint32()+r.pos")("while(r.pos>>0,8|r.mapKey[a.keyType],a.keyType),u===g?i("types[%i].encode(%s[ks[i]],w.uint32(18).fork()).ldelim().ldelim()",l,e):i(".uint32(%i).%s(%s[ks[i]]).ldelim()",16|u,y,e),i("}")("}")):a.repeated?(i("if(%s!=null&&%s.length){",e,e),a.packed&&r.packed[y]!==g?i("w.uint32(%i).fork()",(a.id<<3|2)>>>0)("for(var i=0;i<%s.length;++i)",e)("w.%s(%s[i])",y,e)("w.ldelim()"):(i("for(var i=0;i<%s.length;++i)",e),u===g?o(i,a,l,e+"[i]"):i("w.uint32(%i).%s(%s[i])",(a.id<<3|u)>>>0,y,e)),i("}")):(a.optional&&i("if(%s!=null&&Object.hasOwnProperty.call(m,%j))",e,a.name),u===g?o(i,a,l,e):i("w.uint32(%i).%s(%s)",(a.id<<3|u)>>>0,y,e))}return i("return w")};var n=t(14),r=t(32),s=t(33);function o(t,e,i,n){e.resolvedType.group?t("types[%i].encode(%s,w.uint32(%i)).uint32(%i)",i,n,(e.id<<3|3)>>>0,(e.id<<3|4)>>>0):t("types[%i].encode(%s,w.uint32(%i).fork()).ldelim()",i,n,(e.id<<3|2)>>>0)}},{14:14,32:32,33:33}],14:[function(t,e,i){e.exports=o;var n=t(22),r=(((o.prototype=Object.create(n.prototype)).constructor=o).className="Enum",t(21)),s=t(33);function o(t,e,i,r,s,o){if(n.call(this,t,i),e&&"object"!=typeof e)throw TypeError("values must be an object");if(this.valuesById={},this.values=Object.create(this.valuesById),this.comment=r,this.comments=s||{},this.valuesOptions=o,this.reserved=g,e)for(var p=Object.keys(e),d=0;de)return!0;return!1},y.isReservedName=function(t,e){if(t)for(var i=0;i "+t.len)}function d(t){this.buf=t,this.pos=0,this.len=t.length}function a(){return r.Buffer?function(t){return(d.create=function(t){return r.Buffer.isBuffer(t)?new n(t):y(t)})(t)}:y}var l,y="undefined"!=typeof Uint8Array?function(t){if(t instanceof Uint8Array||Array.isArray(t))return new d(t);throw Error("illegal buffer")}:function(t){if(Array.isArray(t))return new d(t);throw Error("illegal buffer")};function u(){var t=new s(0,0),e=0;if(!(4=this.len)throw p(this);if(t.lo=(t.lo|(127&this.buf[this.pos])<<7*e)>>>0,this.buf[this.pos++]<128)return t}return t.lo=(t.lo|(127&this.buf[this.pos++])<<7*e)>>>0,t}for(;e<4;++e)if(t.lo=(t.lo|(127&this.buf[this.pos])<<7*e)>>>0,this.buf[this.pos++]<128)return t;if(t.lo=(t.lo|(127&this.buf[this.pos])<<28)>>>0,t.hi=(t.hi|(127&this.buf[this.pos])>>4)>>>0,this.buf[this.pos++]<128)return t;if(e=0,4>>0,this.buf[this.pos++]<128)return t}else for(;e<5;++e){if(this.pos>=this.len)throw p(this);if(t.hi=(t.hi|(127&this.buf[this.pos])<<7*e+3)>>>0,this.buf[this.pos++]<128)return t}throw Error("invalid varint encoding")}function f(t,e){return(t[e-4]|t[e-3]<<8|t[e-2]<<16|t[e-1]<<24)>>>0}function c(){if(this.pos+8>this.len)throw p(this,8);return new s(f(this.buf,this.pos+=4),f(this.buf,this.pos+=4))}d.create=a(),d.prototype.h=r.Array.prototype.subarray||r.Array.prototype.slice,d.prototype.uint32=(l=4294967295,function(){if(l=(127&this.buf[this.pos])>>>0,this.buf[this.pos++]<128||(l=(l|(127&this.buf[this.pos])<<7)>>>0,this.buf[this.pos++]<128||(l=(l|(127&this.buf[this.pos])<<14)>>>0,this.buf[this.pos++]<128||(l=(l|(127&this.buf[this.pos])<<21)>>>0,this.buf[this.pos++]<128||(l=(l|(15&this.buf[this.pos])<<28)>>>0,this.buf[this.pos++]<128||!((this.pos+=5)>this.len))))))return l;throw this.pos=this.len,p(this,10)}),d.prototype.int32=function(){return 0|this.uint32()},d.prototype.sint32=function(){var t=this.uint32();return t>>>1^-(1&t)|0},d.prototype.bool=function(){return 0!==this.uint32()},d.prototype.fixed32=function(){if(this.pos+4>this.len)throw p(this,4);return f(this.buf,this.pos+=4)},d.prototype.sfixed32=function(){if(this.pos+4>this.len)throw p(this,4);return 0|f(this.buf,this.pos+=4)},d.prototype.float=function(){if(this.pos+4>this.len)throw p(this,4);var t=r.float.readFloatLE(this.buf,this.pos);return this.pos+=4,t},d.prototype.double=function(){if(this.pos+8>this.len)throw p(this,4);var t=r.float.readDoubleLE(this.buf,this.pos);return this.pos+=8,t},d.prototype.bytes=function(){var t=this.uint32(),e=this.pos,i=this.pos+t;if(i>this.len)throw p(this,t);return this.pos+=t,Array.isArray(this.buf)?this.buf.slice(e,i):e===i?new this.buf.constructor(0):this.h.call(this.buf,e,i)},d.prototype.string=function(){var t=this.bytes();return o.read(t,0,t.length)},d.prototype.skip=function(t){if("number"==typeof t){if(this.pos+t>this.len)throw p(this,t);this.pos+=t}else do{if(this.pos>=this.len)throw p(this)}while(128&this.buf[this.pos++]);return this},d.prototype.skipType=function(t){switch(t){case 0:this.skip();break;case 1:this.skip(8);break;case 2:this.skip(this.uint32());break;case 3:for(;4!=(t=7&this.uint32());)this.skipType(t);break;case 5:this.skip(4);break;default:throw Error("invalid wire type "+t+" at offset "+this.pos)}return this},d.r=function(t){n=t,d.create=a(),n.r();var e=r.Long?"toLong":"toNumber";r.merge(d.prototype,{int64:function(){return u.call(this)[e](!1)},uint64:function(){return u.call(this)[e](!0)},sint64:function(){return u.call(this).zzDecode()[e](!1)},fixed64:function(){return c.call(this)[e](!0)},sfixed64:function(){return c.call(this)[e](!1)}})}},{35:35}],25:[function(t,e,i){e.exports=s;var n=t(24),r=((s.prototype=Object.create(n.prototype)).constructor=s,t(35));function s(t){n.call(this,t)}s.r=function(){r.Buffer&&(s.prototype.h=r.Buffer.prototype.slice)},s.prototype.string=function(){var t=this.uint32();return this.buf.utf8Slice?this.buf.utf8Slice(this.pos,this.pos=Math.min(this.pos+t,this.len)):this.buf.toString("utf-8",this.pos,this.pos=Math.min(this.pos+t,this.len))},s.r()},{24:24,35:35}],26:[function(t,e,i){e.exports=y;var n,r,s,o=t(21),p=(((y.prototype=Object.create(o.prototype)).constructor=y).className="Root",t(15)),d=t(14),a=t(23),l=t(33);function y(t){o.call(this,"",t),this.deferred=[],this.files=[]}function u(){}y.fromJSON=function(t,e){return e=e||new y,t.options&&e.setOptions(t.options),e.addJSON(t.nested)},y.prototype.resolvePath=l.path.resolve,y.prototype.fetch=l.fetch,y.prototype.load=function t(e,i,n){"function"==typeof i&&(n=i,i=g);var o=this;if(!n)return l.asPromise(t,o,e,i);var p=n===u;function d(t,e){if(n){var i=n;if(n=null,p)throw t;i(t,e)}}function a(t){var e=t.lastIndexOf("google/protobuf/");return-1>>0,this.hi=e>>>0}var s=r.zero=new r(0,0),o=(s.toNumber=function(){return 0},s.zzEncode=s.zzDecode=function(){return this},s.length=function(){return 1},r.zeroHash="\0\0\0\0\0\0\0\0",r.fromNumber=function(t){var e,i;return 0===t?s:(i=(t=(e=t<0)?-t:t)>>>0,t=(t-i)/4294967296>>>0,e&&(t=~t>>>0,i=~i>>>0,4294967295<++i&&(i=0,4294967295<++t&&(t=0))),new r(i,t))},r.from=function(t){if("number"==typeof t)return r.fromNumber(t);if(n.isString(t)){if(!n.Long)return r.fromNumber(parseInt(t,10));t=n.Long.fromString(t)}return t.low||t.high?new r(t.low>>>0,t.high>>>0):s},r.prototype.toNumber=function(t){var e;return!t&&this.hi>>>31?(t=1+~this.lo>>>0,e=~this.hi>>>0,-(t+4294967296*(e=t?e:e+1>>>0))):this.lo+4294967296*this.hi},r.prototype.toLong=function(t){return n.Long?new n.Long(0|this.lo,0|this.hi,!!t):{low:0|this.lo,high:0|this.hi,unsigned:!!t}},String.prototype.charCodeAt);r.fromHash=function(t){return"\0\0\0\0\0\0\0\0"===t?s:new r((o.call(t,0)|o.call(t,1)<<8|o.call(t,2)<<16|o.call(t,3)<<24)>>>0,(o.call(t,4)|o.call(t,5)<<8|o.call(t,6)<<16|o.call(t,7)<<24)>>>0)},r.prototype.toHash=function(){return String.fromCharCode(255&this.lo,this.lo>>>8&255,this.lo>>>16&255,this.lo>>>24,255&this.hi,this.hi>>>8&255,this.hi>>>16&255,this.hi>>>24)},r.prototype.zzEncode=function(){var t=this.hi>>31;return this.hi=((this.hi<<1|this.lo>>>31)^t)>>>0,this.lo=(this.lo<<1^t)>>>0,this},r.prototype.zzDecode=function(){var t=-(1&this.lo);return this.lo=((this.lo>>>1|this.hi<<31)^t)>>>0,this.hi=(this.hi>>>1^t)>>>0,this},r.prototype.length=function(){var t=this.lo,e=(this.lo>>>28|this.hi<<4)>>>0,i=this.hi>>>24;return 0==i?0==e?t<16384?t<128?1:2:t<2097152?3:4:e<16384?e<128?5:6:e<2097152?7:8:i<128?9:10}},{35:35}],35:[function(t,e,i){var n=i;function r(t,e,i){for(var n=Object.keys(e),r=0;r>>7|t.hi<<25)>>>0,t.hi>>>=7;for(;127>>7;e[i++]=t.lo}function m(t,e,i){e[i]=255&t,e[i+1]=t>>>8&255,e[i+2]=t>>>16&255,e[i+3]=t>>>24}y.create=u(),y.alloc=function(t){return new r.Array(t)},r.Array!==Array&&(y.alloc=r.pool(y.alloc,r.Array.prototype.subarray)),y.prototype.p=function(t,e,i){return this.tail=this.tail.next=new d(t,e,i),this.len+=e,this},(c.prototype=Object.create(d.prototype)).fn=function(t,e,i){for(;127>>=7;e[i]=t},y.prototype.uint32=function(t){return this.len+=(this.tail=this.tail.next=new c((t>>>=0)<128?1:t<16384?2:t<2097152?3:t<268435456?4:5,t)).len,this},y.prototype.int32=function(t){return t<0?this.p(h,10,s.fromNumber(t)):this.uint32(t)},y.prototype.sint32=function(t){return this.uint32((t<<1^t>>31)>>>0)},y.prototype.int64=y.prototype.uint64=function(t){return t=s.from(t),this.p(h,t.length(),t)},y.prototype.sint64=function(t){return t=s.from(t).zzEncode(),this.p(h,t.length(),t)},y.prototype.bool=function(t){return this.p(f,1,t?1:0)},y.prototype.sfixed32=y.prototype.fixed32=function(t){return this.p(m,4,t>>>0)},y.prototype.sfixed64=y.prototype.fixed64=function(t){return t=s.from(t),this.p(m,4,t.lo).p(m,4,t.hi)},y.prototype.float=function(t){return this.p(r.float.writeFloatLE,4,t)},y.prototype.double=function(t){return this.p(r.float.writeDoubleLE,8,t)};var b=r.Array.prototype.set?function(t,e,i){e.set(t,i)}:function(t,e,i){for(var n=0;n>>0;return i?(r.isString(t)&&(e=y.alloc(i=o.length(t)),o.decode(t,e,0),t=e),this.uint32(i).p(b,i,t)):this.p(f,1,0)},y.prototype.string=function(t){var e=p.length(t);return e?this.uint32(e).p(p.write,e,t):this.p(f,1,0)},y.prototype.fork=function(){return this.states=new l(this),this.head=this.tail=new d(a,0,0),this.len=0,this},y.prototype.reset=function(){return this.states?(this.head=this.states.head,this.tail=this.states.tail,this.len=this.states.len,this.states=this.states.next):(this.head=this.tail=new d(a,0,0),this.len=0),this},y.prototype.ldelim=function(){var t=this.head,e=this.tail,i=this.len;return this.reset().uint32(i),i&&(this.tail.next=t.next,this.tail=e,this.len+=i),this},y.prototype.finish=function(){for(var t=this.head.next,e=this.constructor.alloc(this.len),i=0;t;)t.fn(t.val,e,i),i+=t.len,t=t.next;return e},y.r=function(t){n=t,y.create=u(),n.r()}},{35:35}],39:[function(t,e,i){e.exports=s;var n=t(38),r=((s.prototype=Object.create(n.prototype)).constructor=s,t(35));function s(){n.call(this)}function o(t,e,i){t.length<40?r.utf8.write(t,e,i):e.utf8Write?e.utf8Write(t,i):e.write(t,i)}s.r=function(){s.alloc=r.b,s.writeBytesBuffer=r.Buffer&&r.Buffer.prototype instanceof Uint8Array&&"set"===r.Buffer.prototype.set.name?function(t,e,i){e.set(t,i)}:function(t,e,i){if(t.copy)t.copy(e,i,0,t.length);else for(var n=0;n>>0;return this.uint32(e),e&&this.p(s.writeBytesBuffer,e,t),this},s.prototype.string=function(t){var e=r.Buffer.byteLength(t);return this.uint32(e),e&&this.p(o,e,t),this},s.r()},{35:35,38:38}]},e={},i=function t(i){var n=e[i];return n||r[i][0].call(n=e[i]={exports:{}},t,n,n.exports),n.exports}(16),protobuf=i.util.global.protobuf=i,"function"==typeof define&&define.amd&&define(["long"],(function(t){return t&&t.isLong&&(i.util.Long=t,i.configure()),i})),"object"==typeof module&&module&&module.exports&&(module.exports=i)}();const tiebaJson={nested:{model:{nested:{Abstract:{fields:{text:{type:"string",id:2},type:{type:"int32",id:1}}},ActionControl:{fields:{name:{type:"string",id:2},textColor:{type:"string",id:3},textColorPressed:{type:"string",id:4},url:{type:"string",id:1}}},AdCloseInfo:{fields:{actionControl:{type:"ActionControl",id:5},reasons:{rule:"repeated",type:"string",id:3},supportClose:{type:"int32",id:1}}},Advertisement:{fields:{advertisementId:{type:"string",id:5},clickStatisticsUrl:{type:"string",id:7},deeplink:{type:"string",id:9},displayAdIcon:{type:"string",id:12},floatingText:{type:"string",id:8},jumpLink:{type:"string",id:4},packageName:{type:"string",id:11},pic:{type:"string",id:2},picClick:{type:"string",id:3},scheme:{type:"string",id:10},time:{type:"int64",id:1},viewStatisticsUrl:{type:"string",id:6}}},AgreeBanner:{fields:{iconUrl:{type:"string",id:2},text:{type:"string",id:1},topAgreeUser:{rule:"repeated",type:"SimpleUser",id:4},url:{type:"string",id:3}}},SimpleUser:{fields:{portrait:{type:"string",id:8},userId:{type:"int64",id:1},userName:{type:"string",id:5}}},Agree:{fields:{agreeNum:{type:"int64",id:1},agreeType:{type:"int32",id:3},diffAgreeNum:{type:"int64",id:5},disagreeNum:{type:"int64",id:4},hasAgree:{type:"int32",id:2},lzAgree:{type:"int32",id:6}}},AlaChallengeInfo:{fields:{challengeId:{type:"int64",id:1},rivalHlsUrl:{type:"string",id:5},rivalRtmpUrl:{type:"string",id:4},rivalSession:{type:"string",id:3},winningNum:{type:"int64",id:2}}},AlaLiveInfo:{fields:{audienceCount:{type:"uint32",id:14},challengeInfo:{type:"AlaChallengeInfo",id:25},cover:{type:"string",id:2},coverWide:{type:"string",id:48},description:{type:"string",id:11},dislikeInfo:{rule:"repeated",type:"DislikeInfo",id:43},firstHeadline:{type:"string",id:34},groupId:{type:"uint64",id:6},hlsUrl:{type:"string",id:5},liveFrom:{type:"int32",id:29},liveId:{type:"uint64",id:1},liveStatus:{type:"int32",id:18},liveType:{type:"uint32",id:15},openRecomDuration:{type:"uint32",id:41},openRecomFans:{type:"uint32",id:40},openRecomLocation:{type:"uint32",id:39},openRecomReason:{type:"uint32",id:38},pbDisplayType:{type:"uint32",id:36},recomReason:{type:"string",id:37},roomId:{type:"uint64",id:44},routerType:{type:"string",id:32},rtmpUrl:{type:"string",id:4},screenDirection:{type:"uint32",id:16},secondHeadline:{type:"string",id:35},sessionId:{type:"string",id:3},shareInfo:{type:"AlaShareInfo",id:19},thirdAppId:{type:"string",id:21},thirdLiveType:{type:"string",id:33},thirdRoomId:{type:"string",id:31},userInfo:{type:"AlaUserInfo",id:12},yyExt:{type:"YyExt",id:49},labelName:{type:"string",id:17},userLabel:{type:"UniversalLabel",id:51}}},DislikeInfo:{fields:{dislikeId:{type:"uint32",id:2},dislikeReason:{type:"string",id:1},extra:{type:"string",id:3}}},AlaShareInfo:{fields:{shareCount:{type:"int32",id:3},shareUserCount:{type:"int32",id:2}}},AlaUserInfo:{fields:{alaId:{type:"uint64",id:1},anchorFans:{type:"int32",id:24},anchorLive:{type:"uint64",id:7},enterLive:{type:"uint64",id:6},lat:{type:"double",id:12},liveId:{type:"uint64",id:9},liveStatus:{type:"uint32",id:8},lng:{type:"double",id:11},location:{type:"string",id:10},portrait:{type:"string",id:3},userId:{type:"uint64",id:23},userName:{type:"string",id:2},yyExt:{type:"YyExt",id:25}}},YyExt:{fields:{iconUrl:{type:"string",id:8},isYyGame:{type:"int32",id:5},rankShow:{type:"string",id:7},sid:{type:"string",id:1},ssid:{type:"string",id:2},streamInfo:{type:"string",id:6},templateId:{type:"string",id:3},yyUid:{type:"string",id:4},feedId:{type:"string",id:9}}},UniversalLabel:{fields:{backgroundColor:{type:"string",id:5},backgroundColorBlack:{type:"string",id:6},labelId:{type:"string",id:1},labelText:{type:"string",id:2},roundRadius:{type:"int32",id:7},textColor:{type:"string",id:3},textColorBlack:{type:"string",id:4}}},Anti:{fields:{blockPopInfo:{type:"BlockPopInfo",id:22},blockStat:{type:"int32",id:6},canGoods:{type:"int32",id:27},daysTofree:{type:"int32",id:9},delThreadText:{rule:"repeated",type:"DelThreadText",id:24},forbidFlag:{type:"int32",id:4},forbidInfo:{type:"string",id:5},hasChance:{type:"int32",id:10},hideStat:{type:"int32",id:7},ifaddition:{type:"int32",id:13},ifpost:{type:"int32",id:2},ifvoice:{type:"int32",id:11},ifxiaoying:{type:"string",id:18},multiDelthread:{type:"int32",id:25},pollLevel:{type:"uint32",id:26},pollMessage:{type:"string",id:19},replyPrivateFlag:{type:"int32",id:23},tbs:{type:"string",id:1},vcodeStat:{type:"int32",id:8},videoLocalMessage:{type:"string",id:21},videoMessage:{type:"string",id:20},voiceMessage:{type:"string",id:12}}},BlockPopInfo:{fields:{aheadInfo:{type:"string",id:3},aheadType:{type:"int32",id:6},aheadUrl:{type:"string",id:4},appealMsg:{type:"string",id:8},appealStatus:{type:"int32",id:7},blockInfo:{type:"string",id:2},canPost:{type:"int32",id:1},okInfo:{type:"string",id:5},subBlockInfo:{type:"string",id:11}}},DelThreadText:{fields:{textId:{type:"int32",id:1},textInfo:{type:"string",id:2}}},ApkDetail:{fields:{authorityUrl:{type:"string",id:11},developer:{type:"string",id:1},needInnerBuy:{type:"int32",id:10},needNetwork:{type:"int32",id:9},privacyUrl:{type:"string",id:12},publisher:{type:"string",id:2},size:{type:"string",id:8},updateTime:{type:"string",id:7},version:{type:"string",id:3},versionCode:{type:"int32",id:6}}},App:{fields:{appTime:{type:"int32",id:10},extInfo:{type:"string",id:29},id:{type:"string",id:13},locCode:{type:"string",id:31},name:{type:"string",id:14},posName:{type:"string",id:20},url:{type:"string",id:16},urlType:{type:"int32",id:15}}},BaijiahaoInfo:{fields:{authDesc:{type:"string",id:6},authId:{type:"int32",id:5},avatar:{type:"string",id:2}}},Baijiahao:{fields:{oriUgcNid:{type:"string",id:1},oriUgcTid:{type:"string",id:2},oriUgcVid:{type:"string",id:4}}},Balv:{fields:{daysTofree:{type:"int32",id:3},isBlack:{type:"int32",id:1},isBlock:{type:"int32",id:2}}},BannerList:{fields:{app:{rule:"repeated",type:"App",id:1},pbBannerAd:{type:"App",id:5}}},Banner:{fields:{bannerType:{type:"int32",id:2},bannerUrl:{type:"string",id:1},desc:{type:"string",id:5},type:{type:"int32",id:4}}},BazhuSign:{fields:{desc:{type:"string",id:1},level:{type:"string",id:2}}},BusinessAccountInfo:{fields:{isBusinessAccount:{type:"int32",id:1},isForumBusinessAccount:{type:"int32",id:2}}},CallFansInfo:{fields:{canCall:{type:"int32",id:1}}},Classify:{fields:{classId:{type:"int32",id:3},className:{type:"string",id:4}}},CustomFigure:{fields:{backgroundType:{type:"string",id:2},backgroundValue:{type:"string",id:3},dynamicFigureUrl:{type:"string",id:4},figureUrl:{type:"string",id:1}}},CustomState:{fields:{content:{type:"string",id:2},icon:{type:"string",id:1},iconType:{type:"string",id:3}}},DeletedReasonInfo:{fields:{isBoomgrow:{type:"int32",id:2},isGraysCaleForum:{type:"int32",id:1}}},EditConfig:{fields:{isFirstEdit:{type:"int32",id:2},showEdit:{type:"int32",id:1}}},EditInfo:{fields:{editEnable:{type:"int32",id:2},editErrorMsg:{type:"string",id:3},editErrorNo:{type:"int32",id:6},editFrom:{type:"int32",id:5},editStatus:{type:"int32",id:1},lastEditTime:{type:"int32",id:4}}},Error:{fields:{errmsg:{type:"string",id:2},errorno:{type:"int32",id:1},usermsg:{type:"string",id:3}}},ForumActiveInfo:{fields:{forumBrief:{type:"string",id:1},forumShareUrl:{type:"string",id:2}}},ForumRuleStatus:{fields:{hasForumRule:{type:"int32",id:4},title:{type:"string",id:2}}},ForumShowInfo:{fields:{content:{type:"string",id:1},showType:{type:"int64",id:3},tag:{type:"ForumShowInfoTag",id:2}}},ForumShowInfoTag:{fields:{bgColor:{type:"ThemeColorInfo",id:3},text:{type:"string",id:1},textColor:{type:"ThemeColorInfo",id:2}}},ThemeColorInfo:{fields:{dark:{type:"ThemeElement",id:3},day:{type:"ThemeElement",id:1},night:{type:"ThemeElement",id:2}}},ThemeElement:{fields:{commonColor:{type:"string",id:1},darkColor:{type:"string",id:2},fontColor:{type:"string",id:5},lightColor:{type:"string",id:3},patternImage:{type:"string",id:4}}},FrequentlyForumInfo:{fields:{accessFlag:{type:"uint32",id:15},forumState:{type:"uint32",id:14}}},FrsTabInfo:{fields:{isGeneralTab:{type:"int32",id:7},tabCode:{type:"string",id:8},tabId:{type:"int32",id:1},tabName:{type:"string",id:3},tabType:{type:"int32",id:2},tabUrl:{type:"string",id:4}}},GconAccount:{fields:{hasAccount:{type:"int32",id:1},menuName:{type:"string",id:2}}},GraffitiInfo:{fields:{gid:{type:"int64",id:2},url:{type:"string",id:1}}},Group:{fields:{groupCount:{type:"int32",id:2},hideRecommendGroup:{type:"int32",id:1}}},HeadItem:{fields:{content:{type:"string",id:2},name:{type:"string",id:1},type:{type:"int32",id:3}}},HeadSdk:{fields:{headPic:{type:"string",id:1},headText:{type:"string",id:2},headType:{type:"int32",id:5},sdkName:{type:"string",id:3},sdkParams:{type:"string",id:4}}},HotUserRankEntry:{fields:{hotUser:{rule:"repeated",type:"ShortUserInfo",id:1},moduleName:{type:"string",id:2}}},ShortUserInfo:{fields:{portrait:{type:"string",id:2},userId:{type:"int64",id:1}}},Icon:{fields:{icon:{type:"string",id:4},name:{type:"string",id:1},position:{type:"Position",id:7},spriteInfo:{rule:"repeated",type:"string",id:8},terminal:{type:"Terminal",id:6},value:{type:"int32",id:5},weight:{type:"int32",id:2}}},Position:{fields:{card:{type:"int32",id:4},frs:{type:"int32",id:1},home:{type:"int32",id:3},pb:{type:"int32",id:2}}},Terminal:{fields:{client:{type:"int32",id:3},pc:{type:"int32",id:1},wap:{type:"int32",id:2}}},ItemInfo:{fields:{apkName:{type:"string",id:23},brief:{type:"string",id:4},buttonLink:{type:"string",id:20},buttonLinkType:{type:"int32",id:22},buttonName:{type:"string",id:19},forumName:{type:"string",id:12},iconSize:{type:"double",id:6},iconUrl:{type:"string",id:3},id:{type:"uint32",id:1},isSchool:{type:"uint32",id:9},itemAppid:{type:"string",id:21},itemOptions:{rule:"repeated",type:"ItemOptions",id:7},name:{type:"string",id:2},score:{type:"ItemTable",id:8},tags:{rule:"repeated",type:"string",id:5}}},ItemOptions:{fields:{key:{type:"string",id:1},value:{type:"string",id:2}}},ItemTable:{fields:{itemPlot:{rule:"repeated",type:"ItemPlot",id:7},itemPoint:{rule:"repeated",type:"ItemPoint",id:6},totalPointNum:{type:"int32",id:5}}},ItemPlot:{fields:{level:{type:"uint32",id:1},num:{type:"uint32",id:2}}},ItemPoint:{fields:{point:{type:"double",id:2},timeIntval:{type:"string",id:1}}},Item:{fields:{apkDetail:{type:"ApkDetail",id:15},apkName:{type:"string",id:13},buttonLink:{type:"string",id:9},buttonLinkType:{type:"int32",id:12},buttonName:{type:"string",id:8},categoryId:{type:"int32",id:11},forumName:{type:"string",id:14},iconSize:{type:"double",id:3},iconUrl:{type:"string",id:4},itemAppid:{type:"string",id:10},itemId:{type:"int64",id:1},itemName:{type:"string",id:2},score:{type:"double",id:6},star:{type:"int32",id:7},tags:{rule:"repeated",type:"string",id:5}}},Lbs:{fields:{lat:{type:"string",id:1},lng:{type:"string",id:2},name:{type:"string",id:3}}},Manager:{fields:{id:{type:"int64",id:1},name:{type:"string",id:2},portrait:{type:"string",id:4},showName:{type:"string",id:3}}},MediaNum:{fields:{pic:{type:"int32",id:1}}},Media:{fields:{bigPic:{type:"string",id:3},bsize:{type:"string",id:12},dynamicPic:{type:"string",id:18},height:{type:"uint32",id:11},hthMidLoc:{type:"double",id:23},isLongPic:{type:"uint32",id:19},originPic:{type:"string",id:15},originSize:{type:"uint32",id:16},postId:{type:"int64",id:17},showOriginalBtn:{type:"uint32",id:20},smallPic:{type:"string",id:2},srcPic:{type:"string",id:8},type:{type:"int32",id:1},vhsrc:{type:"string",id:7},vpic:{type:"string",id:5},vsrc:{type:"string",id:6},waterPic:{type:"string",id:4},width:{type:"uint32",id:10},wthMidLoc:{type:"double",id:22}}},MemberShowIcon:{fields:{icon:{type:"string",id:1},name:{type:"string",id:2},url:{type:"string",id:3}}},MemeInfo:{fields:{detailLink:{type:"string",id:7},height:{type:"uint32",id:6},pckId:{type:"uint32",id:1},picId:{type:"uint64",id:2},picUrl:{type:"string",id:3},thumbnail:{type:"string",id:4},width:{type:"uint32",id:5}}},NativeApp:{fields:{downloadAnd:{type:"string",id:3},downloadIos:{type:"string",id:4},jumpIos:{type:"string",id:2}}},NavTabInfo:{fields:{menu:{rule:"repeated",type:"FrsTabInfo",id:2},tab:{rule:"repeated",type:"FrsTabInfo",id:1}}},NewGodInfo:{fields:{fieldId:{type:"uint32",id:2},fieldName:{type:"string",id:3},status:{type:"int32",id:1},type:{type:"uint32",id:4},typeName:{type:"string",id:5}}},OriginThreadInfo:{fields:{_abstract:{rule:"repeated",type:"Abstract",id:3},agree:{type:"Agree",id:19},alaInfo:{type:"AlaLiveInfo",id:6},author:{type:"User",id:18},content:{rule:"repeated",type:"PbContent",id:14},fid:{type:"int64",id:7},fname:{type:"string",id:4},isDeleted:{type:"int32",id:9},isFrsMask:{type:"int32",id:28},isNewStyle:{type:"int32",id:15},isUgc:{type:"int32",id:10},item:{type:"Item",id:22},media:{rule:"repeated",type:"Media",id:2},oriUgcInfo:{type:"Baijiahao",id:11},pid:{type:"int64",id:25},pollInfo:{type:"PollInfo",id:21},replyNum:{type:"int32",id:16},sharedNum:{type:"int32",id:20},threadType:{type:"int32",id:8},tid:{type:"string",id:5},title:{type:"string",id:1},videoInfo:{type:"VideoInfo",id:13}}},User:{fields:{agreeNum:{type:"int32",id:88},alaInfo:{type:"AlaUserInfo",id:78},alaLiveInfo:{type:"AlaLiveInfo",id:85},appealThreadPopover:{type:"string",id:112},baijiahaoInfo:{type:"BaijiahaoInfo",id:95},balv:{type:"Balv",id:10},bawuType:{type:"string",id:26},bazhuGrade:{type:"BazhuSign",id:105},bimgEndTime:{type:"int32",id:40},bimgUrl:{type:"string",id:13},businessAccountInfo:{type:"BusinessAccountInfo",id:111},callFansInfo:{type:"CallFansInfo",id:104},displayAuthType:{type:"int32",id:123},displayIntro:{type:"string",id:138},fansNickname:{type:"string",id:57},fansNum:{type:"int32",id:30},gender:{type:"int32",id:42},giftNum:{type:"int32",id:49},hasConcerned:{type:"int32",id:35},iconinfo:{rule:"repeated",type:"Icon",id:17},id:{type:"int64",id:2},iosBimgFormat:{type:"string",id:22},ip:{type:"string",id:28},ipAddress:{type:"string",id:127},isBawu:{type:"int32",id:25},isDefaultAvatar:{type:"int32",id:106},isInterestman:{type:"int32",id:16},isLike:{type:"int32",id:24},isLogin:{type:"int32",id:1},isManager:{type:"int32",id:11},isMem:{type:"int32",id:39},isSelectTail:{type:"int32",id:51},isVerify:{type:"int32",id:15},isVideobiggie:{type:"int32",id:93},leftCallNum:{type:"int32",id:89},levelId:{type:"int32",id:23},name:{type:"string",id:3},nameShow:{type:"string",id:4},newGodData:{type:"NewGodInfo",id:101},newTshowIcon:{rule:"repeated",type:"TshowInfo",id:65},noUn:{type:"int32",id:6},payMemberInfo:{type:"PayMemberInfo",id:41},pendant:{type:"Pendant",id:77},portrait:{type:"string",id:5},privSets:{type:"PrivSets",id:45},privThread:{type:"int32",id:92},profitList:{rule:"repeated",type:"TwAnchorProfitItem",id:67},rank:{type:"string",id:12},sealPrefix:{type:"string",id:79},sex:{type:"int32",id:32},showPbPrivateFlag:{type:"int32",id:117},tbVip:{type:"TbVipInfo",id:72},themeCard:{type:"ThemeCardInUser",id:69},threadNum:{type:"int32",id:87},tshowIcon:{rule:"repeated",type:"TshowInfo",id:18},twAnchorInfo:{type:"TwZhiBoUser",id:66},type:{type:"int32",id:7},uk:{type:"string",id:107},userType:{type:"int32",id:19},userhide:{type:"int32",id:9},vipInfo:{type:"UserVipInfo",id:61},workCreatorInfo:{type:"WorkCreatorInfo",id:124},userGrowth:{type:"UserGrowth",id:137},themeTail:{type:"ThemeTailInUser",id:141},editConfig:{type:"EditConfig",id:126},levelName:{type:"string",id:125}}},TshowInfo:{fields:{icon:{type:"string",id:1},name:{type:"string",id:2},url:{type:"string",id:3}}},PayMemberInfo:{fields:{endTime:{type:"int32",id:2},picUrl:{type:"string",id:5},propsId:{type:"int32",id:1}}},Pendant:{fields:{imgUrl:{type:"string",id:2},propsId:{type:"uint64",id:1},dynamicUrl:{type:"string",id:3}}},PrivSets:{fields:{bazhuShowInside:{type:"int32",id:8},bazhuShowOutside:{type:"int32",id:9},friend:{type:"int32",id:5},group:{type:"int32",id:3},like:{type:"int32",id:2},live:{type:"int32",id:6},location:{type:"int32",id:1},post:{type:"int32",id:4},reply:{type:"int32",id:7}}},TwAnchorProfitItem:{fields:{availableAnchorLevel:{type:"uint32",id:2},iconLockUrl:{type:"string",id:5},iconUnlockUrl:{type:"string",id:4},id:{type:"int32",id:1},name:{type:"string",id:3}}},TbVipInfo:{fields:{intro:{type:"string",id:1},vDetail:{type:"string",id:3},vUrl:{type:"string",id:2}}},ThemeCardInUser:{fields:{imgAndroid:{type:"string",id:4},imgIos:{type:"string",id:2},level:{type:"uint32",id:5},propsId:{type:"uint64",id:1},dynamicUrl:{type:"string",id:6},exclusiveNo:{type:"string",id:7},jumpUrl:{type:"string",id:8}}},TwZhiBoUser:{fields:{anchorLevel:{type:"uint32",id:1},fieldEx:{type:"string",id:3},inBlackList:{type:"uint32",id:2}}},UserVipInfo:{fields:{aScore:{type:"int32",id:6},eTime:{type:"uint32",id:3},extScore:{type:"uint32",id:4},iconUrl:{type:"string",id:8},nScore:{type:"uint32",id:7},sTime:{type:"uint32",id:2},vLevel:{type:"uint32",id:5},vStatus:{type:"uint32",id:1}}},WorkCreatorInfo:{fields:{authDesc:{type:"string",id:1}}},UserGrowth:{fields:{levelId:{type:"uint32",id:1},score:{type:"int64",id:2},targetScore:{type:"int64",id:3},taskInfo:{rule:"repeated",type:"UserTaskInfo",id:5},tmoney:{type:"double",id:4}}},UserTaskInfo:{fields:{actType:{type:"string",id:10},brief:{type:"string",id:3},currNum:{type:"int32",id:7},id:{type:"int64",id:1},name:{type:"string",id:2},status:{type:"int32",id:5},targetNum:{type:"int32",id:6},targetScheme:{type:"string",id:11},taskIconUrl:{type:"string",id:4},taskType:{type:"int32",id:8},weight:{type:"int32",id:9}}},ThemeTailInUser:{fields:{dynamic:{type:"string",id:2},propsId:{type:"string",id:3},url:{type:"string",id:1}}},PbContent:{fields:{_static:{type:"string",id:17},bigCdnSrc:{type:"string",id:9},bsize:{type:"string",id:5},c:{type:"string",id:11},cdnSrc:{type:"string",id:8},cdnSrcActive:{type:"string",id:36},count:{type:"int32",id:28},duringTime:{type:"uint32",id:13},dynamic:{type:"string",id:16},eType:{type:"uint32",id:24},graffitiInfo:{type:"GraffitiInfo",id:29},height:{type:"uint32",id:19},isLongPic:{type:"uint32",id:34},isNativeApp:{type:"uint32",id:22},itemForumName:{type:"string",id:39},itemId:{type:"uint64",id:38},link:{type:"string",id:3},memeInfo:{type:"MemeInfo",id:33},nativeApp:{type:"NativeApp",id:23},originSize:{type:"uint32",id:27},originSrc:{type:"string",id:25},packetName:{type:"string",id:20},phonetype:{type:"string",id:21},picId:{type:"int64",id:42},showOriginalBtn:{type:"uint32",id:35},src:{type:"string",id:4},text:{type:"string",id:2},tiebaplusInfo:{type:"TiebaPlusInfo",id:40},type:{type:"uint32",id:1},uid:{type:"int64",id:15},width:{type:"uint32",id:18},urlType:{type:"int32",id:32},voiceMd5:{type:"string",id:12},isSub:{type:"uint32",id:14}}},TiebaPlusInfo:{fields:{appCompany:{type:"string",id:11},appIcon:{type:"string",id:6},appId:{type:"string",id:5},appPackage:{type:"string",id:7},appPower:{type:"string",id:10},appPrivacy:{type:"string",id:9},appVersion:{type:"string",id:8},buttonDesc:{type:"string",id:23},desc:{type:"string",id:2},downloadUrl:{type:"string",id:4},forumName:{type:"string",id:20},h5JumpNumber:{type:"string",id:14},h5JumpParam:{type:"string",id:15},h5JumpType:{type:"int32",id:13},isAppoint:{type:"int32",id:18},itemId:{type:"string",id:17},jumpSetting:{type:"int32",id:21},jumpType:{type:"int32",id:16},jumpUrl:{type:"string",id:3},pluginUser:{type:"PluginUser",id:19},targetType:{type:"int32",id:12},title:{type:"string",id:1},wxThumbnail:{type:"string",id:22}}},PluginUser:{fields:{isDownloadCardWhiteuser:{type:"int32",id:5},userId:{type:"int64",id:1},userNameShow:{type:"string",id:2},userPhoto:{type:"string",id:4},userType:{type:"int32",id:3}}},PollInfo:{fields:{endTime:{type:"int32",id:8},isMulti:{type:"int32",id:2},isPolled:{type:"int32",id:5},lastTime:{type:"uint32",id:13},options:{rule:"repeated",type:"PollOption",id:9},optionsCount:{type:"int32",id:4},polledValue:{type:"string",id:6},title:{type:"string",id:12},totalNum:{type:"int64",id:3},totalPoll:{type:"int64",id:11}}},PollOption:{fields:{id:{type:"int32",id:1},num:{type:"int64",id:2},text:{type:"string",id:3}}},VideoInfo:{fields:{firstFrameThumbnail:{type:"string",id:22},isVertical:{type:"uint32",id:15},playCount:{type:"int32",id:10},smallThumbnailUrl:{type:"string",id:21},thumbnailHeight:{type:"uint32",id:8},thumbnailUrl:{type:"string",id:6},thumbnailWidth:{type:"uint32",id:7},videoDesc:{rule:"repeated",type:"VideoDesc",id:12},videoDuration:{type:"uint32",id:3},videoHeight:{type:"uint32",id:5},videoLength:{type:"int32",id:9},videoMd5:{type:"string",id:1},videoType:{type:"uint32",id:14},videoUrl:{type:"string",id:2},videoWidth:{type:"uint32",id:4}}},VideoDesc:{fields:{videoHeight:{type:"string",id:5},videoId:{type:"int32",id:1},videoUrl:{type:"string",id:3},videoWidth:{type:"string",id:4}}},Page:{fields:{curGoodId:{type:"int32",id:8},currentPage:{type:"int32",id:3},hasMore:{type:"int32",id:6},hasPrev:{type:"int32",id:7},newTotalPage:{type:"int32",id:14},offset:{type:"int32",id:2},pageSize:{type:"int32",id:1},pnum:{type:"int32",id:10},reqNum:{type:"int32",id:9},tnum:{type:"int32",id:11},totalCount:{type:"int32",id:4},totalNum:{type:"int32",id:12},totalPage:{type:"int32",id:5}}},PbGoodsInfo:{fields:{goodsFrom:{type:"string",id:6},goodsImage:{type:"string",id:2},goodsPrice:{type:"string",id:3},goodsTitle:{type:"string",id:1},goodsUrl:{type:"string",id:4},goodsUrlH5:{type:"string",id:7},sort:{type:"uint32",id:5}}},PbLinkInfo:{fields:{extTxt:{type:"string",id:5},linkFrom:{type:"string",id:4},picUrl:{type:"string",id:3},sort:{type:"uint32",id:6},title:{type:"string",id:1},toUrl:{type:"string",id:2},urlType:{type:"int32",id:7}}},PbPresent:{fields:{total:{type:"uint32",id:1}}},Post:{fields:{agree:{type:"Agree",id:37},author:{type:"User",id:23},authorId:{type:"int64",id:19},bimgUrl:{type:"string",id:17},content:{rule:"repeated",type:"PbContent",id:5},customFigure:{type:"CustomFigure",id:60},customState:{type:"CustomState",id:61},floor:{type:"uint32",id:3},foldCommentApplyUrl:{type:"string",id:57},foldCommentStatus:{type:"int32",id:56},foldTip:{type:"string",id:44},id:{type:"uint64",id:1},imgNumAbtest:{type:"int32",id:41},iosBimgFormat:{type:"string",id:18},isBub:{type:"uint32",id:11},isFold:{type:"int32",id:43},isPostVisible:{type:"int32",id:39},isTopAgreePost:{type:"int32",id:45},isVoice:{type:"uint32",id:9},isVote:{type:"uint32",id:8},isWonderfulPost:{type:"int32",id:51},lbsInfo:{type:"Lbs",id:7},needLog:{type:"int32",id:40},outerItem:{type:"Item",id:54},present:{type:"PbPresent",id:28},showSquared:{type:"int32",id:47},signature:{type:"SignatureData",id:21},subPostList:{type:"SubPost",id:15},subPostNumber:{type:"uint32",id:13},tailInfo:{type:"TailInfo",id:22},tid:{type:"int64",id:46},time:{type:"uint32",id:4},title:{type:"string",id:2},dynamicUrl:{type:"string",id:63},itemStar:{rule:"repeated",type:"HeadItem",id:52},item:{type:"Item",id:53},bubbleInfo:{type:"ThemeBubble",id:64},rumorSourceImg:{type:"string",id:65},advertisement:{type:"Advertisement",id:55}}},SignatureData:{fields:{content:{rule:"repeated",type:"SignatureContent",id:4},fontColor:{type:"string",id:3},fontKeyName:{type:"string",id:2},signatureId:{type:"int32",id:1}}},SignatureContent:{fields:{text:{type:"string",id:2},type:{type:"int32",id:1}}},SubPost:{fields:{subPostList:{rule:"repeated",type:"SubPostList",id:2}}},SubPostList:{fields:{authorId:{type:"int64",id:4},content:{rule:"repeated",type:"PbContent",id:2},floor:{type:"uint32",id:6},id:{type:"uint64",id:1},time:{type:"uint32",id:3},title:{type:"string",id:5}}},TailInfo:{fields:{content:{type:"string",id:4},iconLink:{type:"string",id:3},iconUrl:{type:"string",id:2},tailType:{type:"int32",id:1}}},ThemeBubble:{fields:{jumpUrl:{type:"string",id:3},packageId:{type:"int32",id:2},propsId:{type:"int32",id:1}}},RecommendInfo:{fields:{title:{type:"string",id:1},userList:{rule:"repeated",type:"SchoolRecomUserInfo",id:2}}},SchoolRecomUserInfo:{fields:{institute:{type:"string",id:4},isLiked:{type:"uint32",id:5},portrait:{type:"string",id:3},uid:{type:"uint64",id:1},uname:{type:"string",id:2}}},RecommendTip:{fields:{isFollow:{type:"string",id:2},reason:{type:"string",id:1}}},RecomTagInfo:{fields:{id:{type:"int32",id:1},name:{type:"string",id:2},pic:{type:"string",id:3}}},RecomTopicList:{fields:{discussNum:{type:"uint64",id:4},tag:{type:"uint32",id:5},topicDesc:{type:"string",id:6},topicId:{type:"uint64",id:1},topicName:{type:"string",id:2},topicPic:{type:"string",id:7},type:{type:"uint32",id:3}}},RewardCard:{fields:{bannerJumpUrl:{type:"string",id:15},buttonText:{type:"string",id:7},endText:{type:"string",id:5},endTime:{type:"string",id:6},headImgs:{rule:"repeated",type:"string",id:13},icon:{type:"string",id:2},id:{type:"string",id:1},joinNum:{type:"string",id:9},joinSuccText:{type:"string",id:14},jumpUrl:{type:"string",id:8},rewardMaterial:{rule:"repeated",type:"RewardMaterial",id:11},startText:{type:"string",id:4},title:{type:"string",id:3},totalNum:{type:"string",id:12}}},RewardMaterial:{fields:{icon:{type:"string",id:1},isMatched:{type:"int32",id:3},isNewestMatchedLevel:{type:"int32",id:4},unlockLevel:{type:"string",id:2}}},ServiceArea:{fields:{picurl:{type:"string",id:2},servicename:{type:"string",id:1},serviceurl:{type:"string",id:3},thirdStatisticsUrl:{rule:"repeated",type:"string",id:8}}},SimpleForum:{fields:{avatar:{type:"string",id:4},deletedReasonInfo:{type:"DeletedReasonInfo",id:17},firstClass:{type:"string",id:7},id:{type:"int64",id:1},isBrandForum:{type:"int32",id:14},isExists:{type:"int32",id:3},isFrsMask:{type:"int32",id:18},isLiked:{type:"uint32",id:5},memberNum:{type:"int32",id:12},name:{type:"string",id:2},postNum:{type:"int32",id:13},secondClass:{type:"string",id:8},themeColor:{type:"ThemeColorInfo",id:19},recommendTip:{type:"string",id:20},showInfo:{type:"ForumShowInfo",id:22},spritePbGuide:{type:"SpritePBGuide",id:23}}},SpritePBGuide:{fields:{buttonText:{type:"string",id:3},guideText:{type:"string",id:2},guideType:{type:"int64",id:1},jumpUrl:{type:"string",id:4}}},SmartApp:{fields:{_abstract:{type:"string",id:3},avatar:{type:"string",id:1},h5Url:{type:"string",id:5},id:{type:"string",id:6},isGame:{type:"int32",id:10},isRecom:{type:"int32",id:9},link:{type:"string",id:7},name:{type:"string",id:2},nawsAppId:{type:"uint64",id:8},pic:{type:"string",id:4}}},SortOption:{fields:{name:{type:"string",id:1},sortType:{type:"int32",id:2}}},StarEnter:{fields:{bazhuMark:{type:"int32",id:10},icon:{type:"string",id:1},text:{type:"string",id:8},time:{type:"int32",id:6},title:{type:"string",id:2},type:{type:"int32",id:4},url:{type:"string",id:5},weight:{type:"int32",id:3}}},TaskInfo:{fields:{bgimg:{type:"string",id:3},cardType:{type:"int32",id:15},endTime:{type:"int64",id:6},floorGodReply:{type:"string",id:14},forumId:{type:"int64",id:8},forumName:{type:"string",id:9},isGodReply:{type:"int32",id:13},objId:{type:"string",id:10},rewardCard:{type:"RewardCard",id:12},startTime:{type:"int64",id:5},taskId:{type:"int64",id:1},threadId:{type:"int64",id:2},threadImg:{type:"string",id:4},threadImgSize:{type:"string",id:7},voteSchema:{type:"VoteSchema",id:11}}},VoteSchema:{fields:{jumpUrl:{type:"string",id:3},textAfterVote:{type:"string",id:2},textBeforeVote:{type:"string",id:1}}},ThreadIdListInfo:{fields:{isPartialVisible:{type:"int32",id:2},tid:{type:"int64",id:1}}},ThreadInfo:{fields:{_abstract:{rule:"repeated",type:"Abstract",id:21},abTag:{type:"string",id:108},agree:{type:"Agree",id:126},agreeNum:{type:"int32",id:124},alaInfo:{type:"AlaLiveInfo",id:113},articleCover:{type:"string",id:162},author:{type:"User",id:18},authorId:{type:"int64",id:56},bjhContentTag:{type:"int32",id:163},categoryName:{type:"string",id:73},cheakRepeat:{type:"uint32",id:107},clickMonitorUrl:{type:"string",id:206},clickUrl:{type:"string",id:32},collectMarkPid:{type:"string",id:51},collectNum:{type:"uint32",id:190},collectStatus:{type:"int32",id:50},commentNum:{type:"int32",id:20},createTime:{type:"int32",id:45},customFigure:{type:"CustomFigure",id:211},customState:{type:"CustomState",id:212},dislikeInfo:{rule:"repeated",type:"DislikeInfo",id:120},exposureMonitorUrl:{type:"string",id:205},fid:{type:"int64",id:27},firstPostContent:{rule:"repeated",type:"PbContent",id:142},firstPostId:{type:"int64",id:40},fname:{type:"string",id:28},forumInfo:{type:"SimpleForum",id:155},id:{type:"int64",id:1},isActivity:{type:"int32",id:16},isBakan:{type:"int32",id:12},isBjh:{type:"int32",id:161},isBookChapter:{type:"uint32",id:103},isBub:{type:"int32",id:39},isCalled:{type:"int32",id:136},isDeal:{type:"int32",id:97},isDeleted:{type:"int32",id:181},isFrsMask:{type:"int32",id:198},isGod:{type:"int32",id:131},isGodthreadRecommend:{type:"int32",id:85},isGood:{type:"int32",id:10},isHeadlinepost:{type:"int32",id:165},isHighlight:{type:"int32",id:213},isLinkThread:{type:"int32",id:128},isLivepost:{type:"int32",id:30},isMeizhi:{type:"int32",id:14},isMembertop:{type:"int32",id:54},isMultiforumThread:{type:"int32",id:123},isNotice:{type:"int32",id:17},isNovel:{type:"int32",id:76},isNovelReward:{type:"int32",id:78},isNovelThank:{type:"int32",id:77},isNtitle:{type:"int32",id:38},isPartialVisible:{type:"int32",id:127},isPic:{type:"int32",id:43},isPictxt:{type:"int32",id:204},isProtal:{type:"int32",id:13},isSCard:{type:"uint32",id:170},isShareThread:{type:"int32",id:143},isTiebaplusAd:{type:"string",id:193},isTop:{type:"int32",id:9},isTopic:{type:"int32",id:148},isVideobiggieRecomthread:{type:"int32",id:153},isVoiceThread:{type:"int32",id:15},isVote:{type:"int32",id:11},lastReadPid:{type:"uint64",id:106},lastReplyer:{type:"User",id:19},lastTime:{type:"string",id:6},lastTimeInt:{type:"int32",id:7},legoCard:{type:"string",id:94},livecoverSrc:{type:"string",id:67},location:{type:"Lbs",id:62},media:{rule:"repeated",type:"Media",id:22},mediaNum:{rule:"repeated",type:"MediaNum",id:25},nid:{type:"string",id:164},originThreadInfo:{type:"OriginThreadInfo",id:141},pbLinkInfo:{rule:"repeated",type:"PbLinkInfo",id:178},pollInfo:{type:"PollInfo",id:74},postId:{type:"int64",id:52},recomReason:{type:"string",id:109},recomSource:{type:"string",id:104},recomWeight:{type:"string",id:105},recommendTip:{type:"RecommendTip",id:202},replyNum:{type:"int32",id:4},richAbstract:{rule:"repeated",type:"PbContent",id:112},richTitle:{rule:"repeated",type:"PbContent",id:111},scardPacketId:{type:"string",id:171},shareNum:{type:"int64",id:135},showCommented:{type:"int32",id:31},storecount:{type:"int32",id:68},tShareImg:{type:"string",id:159},tabId:{type:"int32",id:175},tabName:{type:"string",id:176},threadRecommendInfos:{rule:"repeated",type:"ThreadRecommendInfo",id:191},threadShareLink:{type:"string",id:172},threadType:{type:"int32",id:26},threadTypes:{type:"int32",id:8},tid:{type:"int64",id:2},tiebaplusCantDelete:{type:"int32",id:197},tiebaplusExtraParam:{type:"string",id:196},tiebaplusOrderId:{type:"string",id:194},tiebaplusToken:{type:"string",id:195},title:{type:"string",id:3},topAgreePost:{type:"Post",id:125},topic:{type:"Topic",id:47},topicH5Url:{type:"string",id:150},topicUserName:{type:"string",id:149},twzhiboInfo:{type:"ZhiBoInfoTW",id:72},videoInfo:{type:"VideoInfo",id:79},viewNum:{type:"int32",id:5},wonderfulPostInfo:{type:"string",id:177},worksInfo:{type:"WorksInfo",id:189},zan:{type:"Zan",id:41},tiebaplusAd:{type:"TiebaPlusAd",id:201},itemStar:{rule:"repeated",type:"HeadItem",id:180},threadRecommendTag:{type:"ThreadRecommendTag",id:210},item:{type:"Item",id:179},taskInfo:{type:"TaskInfo",id:83},isXiuxiuThread:{type:"int32",id:214},nawsInfo:{type:"SmartApp",id:156},editInfo:{type:"EditInfo",id:203},isExcellentThread:{type:"int32",id:219}}},ThreadRecommendInfo:{fields:{backgroundColor:{type:"ThemeColorInfo",id:13},recommendIcon:{type:"string",id:9},recommendReason:{type:"string",id:5},recommendReasonColor:{type:"ThemeColorInfo",id:11},recommendType:{type:"string",id:7},recommendTypeColor:{type:"ThemeColorInfo",id:10},stripColor:{type:"ThemeColorInfo",id:12},topicId:{type:"int64",id:6},recommendTail:{type:"string",id:8},jumpLink:{type:"string",id:14}}},Topic:{fields:{isLpost:{type:"int32",id:1},link:{type:"string",id:3}}},ZhiBoInfoTW:{fields:{content:{type:"string",id:11},copythreadRemind:{type:"uint32",id:20},fieldEx:{type:"string",id:22},forumId:{type:"uint64",id:8},forumName:{type:"string",id:7},freqNum:{type:"uint32",id:19},isCopytwzhibo:{type:"uint32",id:21},isHeadline:{type:"int32",id:17},lastModifiedTime:{type:"uint64",id:9},livecoverSrc:{type:"string",id:2},livecoverSrcBsize:{type:"string",id:3},livecoverSrcStatus:{type:"string",id:15},postNum:{type:"uint32",id:4},replyNum:{type:"uint32",id:5},threadId:{type:"uint64",id:1},title:{type:"string",id:10},user:{type:"User",id:12},zan:{type:"Zan",id:6}}},Zan:{fields:{isLiked:{type:"int32",id:3},lastTime:{type:"int32",id:4},num:{type:"int32",id:1}}},WorksInfo:{fields:{isWorks:{type:"int32",id:1},tagList:{type:"VideoTags",id:3}}},VideoTags:{fields:{first:{type:"string",id:1},second:{type:"string",id:2},tags:{rule:"repeated",type:"string",id:3}}},TiebaPlusAd:{fields:{adSource:{type:"string",id:3},costUrl:{type:"string",id:1},showUrl:{type:"string",id:2}}},ThreadRecommendTag:{fields:{backgroundColor:{type:"ThemeColorInfo",id:3},text:{type:"string",id:1},textColor:{type:"ThemeColorInfo",id:2}}},VitalityInfo:{fields:{frequentlyForumInfo:{type:"FrequentlyForumInfo",id:1}}},frs:{nested:{ActivityHead:{fields:{activityTitle:{type:"string",id:2},activityType:{type:"int32",id:1},headImgs:{rule:"repeated",type:"HeadImgs",id:3},isAd:{type:"bool",id:13},objId:{type:"string",id:5},pullDownClickUrl:{type:"string",id:12},pullDownExposureUrl:{type:"string",id:11},pullDownInterval:{type:"int32",id:8},pullDownPackageName:{type:"string",id:15},pullDownPicAndroid:{type:"string",id:10},pullDownPicIos:{type:"string",id:9},pullDownSchema:{type:"string",id:14},pullDownUrl:{type:"string",id:7},topSize:{type:"Size",id:4}}},CoverImageColor:{fields:{model:{type:"int32",id:2},value:{type:"string",id:1}}},DataRes:{fields:{activityhead:{type:"ActivityHead",id:23},adSampleMapKey:{type:"string",id:114},adShowSelect:{type:"int32",id:112},agreeBanner:{type:"AgreeBanner",id:65},anti:{type:"Anti",id:5},aspShownInfo:{type:"string",id:56},ctime:{type:"int32",id:12},fortuneBag:{type:"int32",id:10},fortuneDesc:{type:"string",id:19},forum:{type:"ForumInfo",id:2},forumRule:{type:"ForumRuleStatus",id:105},frsStar:{type:"StarInfo",id:3},frsTabDefault:{type:"int32",id:38},frsTabInfo:{rule:"repeated",type:"FrsTabInfo",id:22},gameDefaultTabId:{type:"int32",id:74},gconAccount:{type:"GconAccount",id:18},group:{type:"Group",id:6},hotUserEntry:{type:"HotUserRankEntry",id:102},isGetHorseRaceLamp:{type:"int32",id:104},isNewUrl:{type:"int32",id:9},itemInfo:{type:"ItemInfo",id:103},logid:{type:"int64",id:13},navTabInfo:{type:"NavTabInfo",id:37},needLog:{type:"int32",id:48},page:{type:"Page",id:4},partialVisibleToast:{type:"string",id:62},privateForumActiveInfo:{type:"ForumActiveInfo",id:98},serverTime:{type:"int32",id:14},serviceArea:{rule:"repeated",type:"ServiceArea",id:100},showAdsense:{type:"int32",id:108},smartFrsType:{type:"int32",id:47},sortType:{type:"int32",id:39},starEnter:{rule:"repeated",type:"StarEnter",id:20},threadIdList:{rule:"repeated",type:"int64",id:8},threadIdListInfo:{rule:"repeated",type:"ThreadIdListInfo",id:64},threadList:{rule:"repeated",type:"ThreadInfo",id:7},time:{type:"int32",id:11},user:{type:"User",id:1},userList:{rule:"repeated",type:"User",id:17},videoAutoPlay:{type:"int32",id:93},vitalityInfo:{type:"VitalityInfo",id:42},voiceRoomConfig:{type:"int32",id:111},headSdk:{type:"HeadSdk",id:34},frsGameTabInfo:{rule:"repeated",type:"FrsTabInfo",id:68},isMemberBroadcastForum:{type:"int32",id:119},forumGroup:{type:"ForumGroup",id:120}}},Fans:{fields:{isGet:{type:"int32",id:4},leftTime:{type:"int32",id:2},num:{type:"int32",id:5},open:{type:"int32",id:3},startTime:{type:"int32",id:1}}},FeedGroupInfo:{fields:{jumpUrl:{type:"string",id:2},name:{type:"string",id:1}}},ForumGroup:{fields:{feedCard:{type:"GroupFeedCard",id:2},topbarEntrance:{type:"TopbarEntrance",id:1}}},ForumInfo:{fields:{accelerateCotent:{type:"string",id:50},albumOpenPhotoFrs:{type:"int32",id:23},avatar:{type:"string",id:24},banner:{type:"Banner",id:32},bannerList:{type:"BannerList",id:33},canUseAccelerate:{type:"int32",id:49},curScore:{type:"int32",id:13},deletedReasonInfo:{type:"DeletedReasonInfo",id:85},fShareImg:{type:"string",id:78},firstClass:{type:"string",id:3},forumGameLabel:{type:"string",id:66},forumShareLink:{type:"string",id:79},forumvipShowIcon:{type:"MemberShowIcon",id:55},gameName:{type:"string",id:54},gameUrl:{type:"string",id:47},goodClassify:{rule:"repeated",type:"Classify",id:21},hasFrsStar:{type:"int32",id:12},hasGame:{type:"int32",id:46},hasPostpre:{type:"int32",id:26},id:{type:"int64",id:1},isBrandForum:{type:"int32",id:71},isFrsMask:{type:"int32",id:86},isLike:{type:"int32",id:6},isLiveGameForum:{type:"int32",id:63},isNewGameForum:{type:"int32",id:65},isPrivateForum:{type:"int32",id:75},isShowAllTopThread:{type:"int32",id:72},isShowBawutask:{type:"int32",id:77},isShowForumrule:{type:"int32",id:84},levelId:{type:"int32",id:35},levelName:{type:"string",id:8},levelupScore:{type:"int32",id:14},managers:{rule:"repeated",type:"Manager",id:17},memberNum:{type:"int32",id:9},name:{type:"string",id:2},postNum:{type:"int32",id:11},riskTipNotice:{type:"string",id:81},riskTipPop:{type:"string",id:80},riskTipPopTitle:{type:"string",id:82},secondClass:{type:"string",id:4},signInInfo:{type:"SignInfo",id:15},slogan:{type:"string",id:25},specialForumType:{type:"string",id:68},superboy:{type:"string",id:40},tagInfo:{type:"TagInfo",id:38},themeColor:{type:"ThemeColorInfo",id:73},threadNum:{type:"int32",id:10},topicSpecialIcon:{type:"string",id:69},topicSpecialIconRight:{type:"string",id:70},userLevel:{type:"int32",id:7},warningMsg:{type:"string",id:67},postPrefix:{type:"PostPrefix",id:39}}},FrsPageResIdl:{fields:{data:{type:"DataRes",id:2},error:{type:"Error",id:1}}},GroupFeedCard:{fields:{cardTitle:{type:"string",id:1},groupList:{rule:"repeated",type:"FeedGroupInfo",id:3},index:{type:"uint32",id:2}}},HeadImgs:{fields:{btnText:{type:"string",id:5},coverImageColor:{type:"CoverImageColor",id:26},coverUrl:{type:"string",id:24},downloadAppid:{type:"string",id:23},downloadAppname:{type:"string",id:13},downloadDeveloper:{type:"string",id:14},downloadImg:{type:"string",id:17},downloadIsThirdpage:{type:"int32",id:12},downloadItemId:{type:"int32",id:22},downloadPackageName:{type:"string",id:21},downloadPackageSize:{type:"string",id:15},downloadPrivacyPolicy:{type:"string",id:20},downloadUrl:{type:"string",id:16},downloadUserPower:{type:"string",id:19},downloadVersion:{type:"string",id:18},hasSecondPage:{type:"uint32",id:10},imgUrl:{type:"string",id:1},packageName:{type:"string",id:11},pcUrl:{type:"string",id:2},playUrl:{type:"string",id:25},schema:{type:"string",id:8},subtitle:{type:"string",id:4},tagNameUrl:{type:"string",id:6},tagNameWh:{type:"string",id:7},thirdStatisticsUrl:{rule:"repeated",type:"string",id:9},title:{type:"string",id:3},videoImageColor:{rule:"repeated",type:"VideoImageColor",id:27}}},PostPrefix:{fields:{mode:{type:"int32",id:1},text:{type:"string",id:2},time:{type:"string",id:4},type:{type:"string",id:3}}},SignForum:{fields:{isOn:{type:"int32",id:1}}},SignInfo:{fields:{forumInfo:{type:"SignForum",id:2},userInfo:{type:"SignUser",id:1},hasChatroomSign:{type:"int32",id:3}}},SignUser:{fields:{cSignNum:{type:"int32",id:8},contSignNum:{type:"int32",id:5},hunSignNum:{type:"int32",id:9},isOrgDisabled:{type:"int32",id:7},isSignIn:{type:"int32",id:2},missSignNum:{type:"int32",id:11},signTime:{type:"int32",id:4},totalResignNum:{type:"int32",id:10},userId:{type:"int64",id:1},userSignRank:{type:"int32",id:3}}},Size:{fields:{height:{type:"int32",id:2},width:{type:"int32",id:1}}},StarInfo:{fields:{hasFrsStar:{type:"int32",id:1},head:{type:"string",id:3},starForumHeadimg:{type:"string",id:17},top:{type:"string",id:2},fans:{type:"Fans",id:6},topSize:{type:"Size",id:14},headSize:{type:"Size",id:15}}},TagInfo:{fields:{color:{type:"int32",id:4},firstCategory:{type:"string",id:12},forumId:{type:"int64",id:1},hotValue:{type:"int32",id:5},influence:{type:"int32",id:8},opTime:{type:"int32",id:10},recomTag:{type:"RecomTagInfo",id:11},relationWeight:{type:"int32",id:9},tagId:{type:"int32",id:2},tagLevel:{type:"int32",id:7},tagName:{type:"string",id:3},tagType:{type:"int32",id:6}}},TopbarEntrance:{fields:{guideTipFirstText:{type:"string",id:1},guideTipText:{type:"string",id:2},jumpUrl:{type:"string",id:3}}},VideoImageColor:{fields:{color:{type:"string",id:2},time:{type:"uint32",id:1}}}}},threadlist:{nested:{DataRes:{fields:{adSampleMapKey:{type:"string",id:8},adShowSelect:{type:"int32",id:7},bannerList:{type:"BannerList",id:3},partialVisibleToast:{type:"string",id:5},threadList:{rule:"repeated",type:"ThreadInfo",id:1},userList:{rule:"repeated",type:"User",id:2}}},ThreadListResIdl:{fields:{data:{type:"DataRes",id:2},error:{type:"Error",id:1}}}}},generaltablelist:{nested:{DataRes:{fields:{adSampleMapKey:{type:"string",id:13},adShowSelect:{type:"int32",id:11},appList:{rule:"repeated",type:"App",id:10},generalList:{rule:"repeated",type:"ThreadInfo",id:1},hasMore:{type:"int32",id:2},itemInfo:{type:"ItemInfo",id:8},sortType:{type:"int32",id:7},userList:{rule:"repeated",type:"User",id:3},sortOption:{rule:"repeated",type:"SortOption",id:9}}},GeneralTabListResIdl:{fields:{data:{type:"DataRes",id:2},error:{type:"Error",id:1}}}}},pb:{nested:{BusinessPromotInfo:{fields:{isHeadlinepost:{type:"int32",id:2},isPromot:{type:"int64",id:1},isSCard:{type:"int32",id:3}}},DataRes:{fields:{anti:{type:"Anti",id:4},bannerList:{type:"BannerList",id:12},businessPromotInfo:{type:"BusinessPromotInfo",id:53},displayForum:{type:"SimpleForum",id:39},foldTip:{type:"string",id:44},forum:{type:"SimpleForum",id:2},forumRule:{type:"ForumRuleStatus",id:60},hasFloor:{type:"int32",id:7},hasFoldComment:{type:"int32",id:68},isBlackWhite:{type:"int32",id:62},isNewUrl:{type:"int32",id:10},isOfficialForum:{type:"int32",id:63},isPurchase:{type:"int32",id:65},page:{type:"Page",id:3},partialVisibleToast:{type:"string",id:41},pbNotice:{type:"string",id:67},pbNoticeType:{type:"int32",id:66},pbSortInfo:{rule:"repeated",type:"PbSortType",id:49},postList:{rule:"repeated",type:"Post",id:6},recomAlaInfo:{type:"AlaLiveInfo",id:55},serverTime:{type:"int32",id:14},showAdsense:{type:"int32",id:61},sortType:{type:"int32",id:50},switchReadOpen:{type:"int32",id:32},thread:{type:"ThreadInfo",id:8},threadFreqNum:{type:"int64",id:37},threadTopic:{rule:"repeated",type:"RecomTopicList",id:48},user:{type:"User",id:1},userList:{rule:"repeated",type:"User",id:13},floatingIcon:{type:"FloatingIcon",id:64},firstFloorPost:{type:"Post",id:38},topAnswer:{type:"Post",id:73}}},FloatingIconItem:{fields:{clickStatisticsUrl:{type:"string",id:4},deeplink:{type:"string",id:5},displayAdIcon:{type:"string",id:13},floatType:{type:"string",id:10},foldLottie:{type:"string",id:8},foldName:{type:"string",id:11},iconUrl:{type:"string",id:2},packageName:{type:"string",id:7},scheme:{type:"string",id:6},unfoldLottie:{type:"string",id:9},unfoldName:{type:"string",id:12},url:{type:"string",id:1},viewStatisticsUrl:{type:"string",id:3}}},FloatingIcon:{fields:{pbpage:{type:"FloatingIconItem",id:1}}},PbPageResIdl:{fields:{data:{type:"DataRes",id:2},error:{type:"Error",id:1}}},PbSortType:{fields:{sortName:{type:"string",id:2},sortType:{type:"int32",id:1}}}}},personalized:{nested:{DataRes:{fields:{anti:{type:"Anti",id:16},liveAnswer:{type:"LiveAnswer",id:17},bannerList:{type:"BannerList",id:9},freshCtrlNum:{type:"int32",id:21},isNewUrl:{type:"int32",id:8},sugSeconds:{type:"uint32",id:6},threadList:{rule:"repeated",type:"ThreadInfo",id:2},threadPersonalized:{rule:"repeated",type:"ThreadPersonalized",id:7},userFollowLive:{type:"UserFollowLive",id:20},showAdsense:{type:"int32",id:25}}},DislikeReason:{fields:{dislikeId:{type:"uint32",id:2},dislikeReason:{type:"string",id:1},extra:{type:"string",id:3}}},LiveAnswer:{fields:{bannerHigh:{type:"int32",id:3},bannerUrl:{type:"string",id:1},bannerWidth:{type:"int32",id:2},jumpUrl:{type:"string",id:4},activityId:{type:"int64",id:5}}},PersonalizedResIdl:{fields:{data:{type:"DataRes",id:2},error:{type:"Error",id:1}}},ThreadPersonalized:{fields:{abtestTag:{type:"string",id:4},dislikeResource:{rule:"repeated",type:"DislikeReason",id:5},extra:{type:"string",id:6},source:{type:"string",id:3},tid:{type:"uint64",id:1},weight:{type:"string",id:2}}},UserFollowLive:{fields:{_switch:{type:"uint32",id:2}}}}}}}}},tiebaRoot=protobuf.Root.fromJSON(tiebaJson),url=$request.url,method=$request.method,isQuanX="undefined"!=typeof $task,binaryBody=isQuanX?new Uint8Array($response.bodyBytes):$response.body;let body;if(console.log("2023-06-15"),"POST"!==$request.method&&$notification.post("贴吧proto去广告脚本错误","请求方法不为POST:",url),url.includes("frs/page")){console.log("贴吧-FrsPage");let t=tiebaRoot.lookupType("model.frs.FrsPageResIdl"),e=t.decode(binaryBody);e.data.threadList=removeLive(e.data.threadList),e.data.activityhead?.isAd?(console.log("frs去除吧内header图片广告"),e.data.activityhead=null):console.log("无需处理activityhead"),body=t.encode(e).finish()}else if(url.includes("frs/threadlist")){console.log("贴吧-threadlist");let t=tiebaRoot.lookupType("model.threadlist.ThreadListResIdl"),e=t.decode(binaryBody);body=t.encode(e).finish()}else if(url.includes("pb/page")){console.log("贴吧-PbPage");let t=tiebaRoot.lookupType("model.pb.PbPageResIdl"),e=t.decode(binaryBody);if(e.data.postList?.length)for(const t of e.data.postList)t.outerItem&&(console.log("outer_item去除"),t.outerItem=null);else console.log("无需处理postList中的outer_item");e.data.recomAlaInfo?.liveId?(console.log("帖子详情页推荐的直播广告去除"),e.data.recomAlaInfo=null):console.log("帖子详情页无直播广告"),body=t.encode(e).finish()}else if(url.includes("excellent/personalized")){console.log("贴吧-personalized");let t=tiebaRoot.lookupType("model.personalized.PersonalizedResIdl"),e=t.decode(binaryBody);e.data.threadList=removeLive(e.data.threadList),e.data.liveAnswer?(console.log("去除推荐页上方的banner广告"),e.data.liveAnswer=null):console.log("推荐页无banner广告"),body=t.encode(e).finish()}else if(url.includes("frs/generalTabList")){console.log("贴吧-generalTabList");let t=tiebaRoot.lookupType("model.generaltablelist.GeneralTabListResIdl"),e=t.decode(binaryBody);body=t.encode(e).finish()}else $notification.post("贴吧proto去广告脚本错误","url匹配错误:",url);function removeLive(t){let e=t;const i=t?.length;return i?(e=t.filter((t=>!t.alaInfo||(console.log("去除推荐的直播帖子"),!1))),i===e.length&&console.log("无推荐的直播帖子")):console.log("无需处理threadList"),e}console.log(`${body.byteLength}---${body.buffer.byteLength}`),isQuanX?$done({bodyBytes:body.buffer.slice(body.byteOffset,body.byteLength+body.byteOffset)}):$done({body:body}); \ No newline at end of file diff --git a/Scripts/AdBlock/Other/Tieba.js b/Scripts/AdBlock/Other/Tieba.js new file mode 100644 index 0000000..645e9e1 --- /dev/null +++ b/Scripts/AdBlock/Other/Tieba.js @@ -0,0 +1,253 @@ +const url = $request.url; +const method = $request.method; +const postMethod = "POST"; +const notifyTitle = "贴吧json脚本错误"; +console.log(`贴吧json-2023.06.12.2`); + +let body = JSON.parse($response.body); +// 直接全局搜索 @Modify( +if (url.includes("tiebaads/commonbatch") && method === postMethod) { + // 看图模式下的广告 + let adCmd = getUrlParamValue(url, "adcmd"); + if (!adCmd) { + console.log(`url:${url}`); + $notification.post(notifyTitle, "贴吧-tiebaads/commonbatch", "adCmd参数不存在"); + } else { + console.log(`commonbatch:${adCmd}`); + if (body.error_code === 0) { + if (!body.res.ad?.length) { + console.log('ad字段为空'); + } else { + body.res.ad = []; + // 即使ad有内容 也不一定显示广告 + // 因为如果服务器下发的数据少了一些字段同样是无广告的 + console.log('成功'); + } + } else { + console.log('error_code不为0:' + body.error_code); + } + } +} else if (url.includes('c/f/pb/picpage')) { + console.log(`picpage`); + const liveLength = body.recom_live_list?.length; + if (liveLength) { + console.log(`去除直播:${liveLength}`); + body.recom_live_list = []; + } +} else if (url.includes('c/s/sync')) { + // get post(贴吧使用了post)均可访问 + console.log('贴吧-sync'); + if ('floating_icon' in body) { + console.log('右下角悬浮icon'); + if (body.floating_icon) { + if (body.floating_icon.homepage?.icon_url) { + console.log('homepage悬浮去除'); + } else { + console.log('无需去除homepage悬浮'); + } + if (body.floating_icon.pb?.icon_url) { + console.log('pb悬浮去除'); + } else { + console.log('无需去除pb悬浮'); + } + body.floating_icon = null; + } else { + console.log('无需修改floating_icon字段值'); + } + } else { + console.log(`body:${$response.body}`); + $notification.post(notifyTitle, "贴吧-sync", "无floating_icon字段"); + } + + // 回帖栏的广告 + if ('advertisement_config' in body) { + if (!body.advertisement_config?.advertisement_str) { + console.log('无需处理advertisement_config'); + } else { + console.log(`advertisement_str:${body.advertisement_config.advertisement_str}`); + body.advertisement_config = null; + } + } else { + console.log(`body:${$response.body}`); + $notification.post(notifyTitle, "贴吧-sync", "无advertisement_config字段"); + } + + if ('config' in body) { + if (body.config?.switch) { + for (const item of body.config.switch) { + if (['platform_csj_init', 'platform_ks_init', 'platform_gdt_init'].includes(item.name)) { + item.type = '0'; + // 禁止初始化穿山甲/广点通/快手 + console.log(`禁止初始化${item.name}`); + } + } + } + } else { + console.log(`body:${$response.body}`); + $notification.post(notifyTitle, "贴吧-sync", "无config字段"); + } + + if ('screen_fill_data_result' in body) { + if (body.screen_fill_data_result.screen_fill_advertisement_bear_switch === "1") { + body.screen_fill_data_result.screen_fill_advertisement_bear_switch = '0'; + console.log('开屏不展示小熊广告'); + } else { + console.log('无需修改screen_fill_advertisement_bear_switch'); + } + if (body.screen_fill_data_result.screen_fill_advertisement_plj_cpc_switch === "1") { + body.screen_fill_data_result.screen_fill_advertisement_plj_cpc_switch = '0'; + console.log('开屏不展示序章CPC'); + } else { + console.log('无需修改screen_fill_advertisement_plj_cpc_switch'); + } + if (body.screen_fill_data_result.screen_fill_advertisement_plj_switch === "1") { + body.screen_fill_data_result.screen_fill_advertisement_plj_switch = '0'; + console.log('开屏不展示序章'); + } else { + console.log('无需修改screen_fill_advertisement_plj_switch'); + } + } else { + console.log(`body:${$response.body}`); + $notification.post(notifyTitle, "贴吧-sync", "无screen_fill_data_result字段"); + } + + if ('ad_stlog_switch' in body) { + if (body.ad_stlog_switch === '1') { + body.ad_stlog_switch = '0'; + console.log('修改ad_stlog_switch'); + } else { + console.log('无需修改ad_stlog_switch'); + } + } else { + console.log(`body:${$response.body}`); + $notification.post(notifyTitle, "贴吧-sync", "无ad_stlog_switch字段"); + } + + if ('lcs_strategy' in body) { + // 控制长连接开关 开启时帖子会走socket + if (body.lcs_strategy.conn_conf === '0') { + // 关闭 + body.lcs_strategy.conn_conf = '1'; + console.log('修改conn_conf'); + } else { + console.log('无需修改conn_conf'); + } + } else { + console.log(`body:${$response.body}`); + $notification.post(notifyTitle, "贴吧-sync", "无lcs_strategy字段"); + } +} else if (url.includes("c/f/frs/page")) { + console.log('贴吧-FrsPage'); + if (body.live_fuse_forum?.length) { + body.live_fuse_forum = []; + console.log(`去除吧头直播`); + } else { + console.log(`无需处理吧头直播`); + } + + if (body.activityhead?.is_ad) { + body.activityhead = {}; + console.log('去除吧内header图片广告'); + } else { + console.log('无需处理activityhead'); + } + body.thread_list = removeLive(body.thread_list); + removeGoodsInfo(body.forum?.banner_list?.app); +} else if (url.includes("c/f/frs/threadlist")) { + console.log('贴吧-threadlist'); + removeGoodsInfo(body.banner_list?.app); +} else if (url.includes("c/f/pb/page")) { + console.log('贴吧-PbPage'); + if (body.recom_ala_info?.live_id) { + console.log('帖子详情页推荐的直播广告去除'); + body.recom_ala_info = null; + } else { + console.log('帖子详情页无直播广告'); + } + + if (body.post_list?.length) { + for (const post of body.post_list) { + if (post.outer_item) { + console.log('outer_item去除'); + post.outer_item = null; + } + } + } else { + console.log('无需处理postList中的outer_item'); + } + removeGoodsInfo(body.banner_list?.app); + const bannerGoodsInfoLength = body.banner_list?.pb_banner_ad?.goods_info?.length; + if (bannerGoodsInfoLength) { + console.log(`去除pb_banner_ad的goods_info:${bannerGoodsInfoLength}`) + body.banner_list.pb_banner_ad.goods_info = [] + } +} else if (url.includes("c/f/excellent/personalized")) { + console.log('贴吧-personalized'); + removeGoodsInfo(body.banner_list?.app); + body.thread_list = removeLive(body.thread_list); + if(body.live_answer){ + console.log('去除推荐页上方的banner广告'); + body.live_answer = null; + } else { + console.log('推荐页无banner广告'); + } +} else if (url.includes("c/f/frs/generalTabList")) { + console.log('贴吧-generalTabList'); + removeGoodsInfo(body.app_list); +} else { + $notification.post(notifyTitle, "路径/请求方法匹配错误:", method + "," + url); +} + +body = JSON.stringify(body); + +$done({ + body +}); + + +function getUrlParamValue(url, queryName) { + return Object.fromEntries(url.substring(url.indexOf("?") + 1) + .split("&") + .map(pair => pair.split("=")) + )[queryName]; +} + +function removeGoodsInfo(app) { + if (app?.length) { + let goodsInfoSize = 0; + app.forEach(item => { + if (item.goods_info?.length) { + goodsInfoSize++; + item.goods_info = []; + } + }) + if (goodsInfoSize) { + console.log(`去除goods_info:${goodsInfoSize}`); + } else { + console.log(`app内无goods_info`) + } + + } else { + console.log(`app为空,无需处理`); + } +} + +function removeLive(threadList) { + let newThreadList = threadList; + const beforeLength = threadList?.length; + if (beforeLength) { + newThreadList = threadList.filter(item => { + if (item.ala_info) { + console.log('去除推荐的直播帖子'); + return false; + } + return true; + }); + if (beforeLength === newThreadList.length) { + console.log("无推荐的直播帖子"); + } + } else { + console.log('无需处理threadList'); + } + return newThreadList; +} \ No newline at end of file diff --git a/Scripts/AdBlock/Other/Tieba.min.js b/Scripts/AdBlock/Other/Tieba.min.js new file mode 100644 index 0000000..6e2a062 --- /dev/null +++ b/Scripts/AdBlock/Other/Tieba.min.js @@ -0,0 +1 @@ +const url=$request.url,method=$request.method,postMethod="POST",notifyTitle="贴吧json脚本错误";console.log("贴吧json-2023.06.12.2");let body=JSON.parse($response.body);if(url.includes("tiebaads/commonbatch")&&"POST"===method){let o=getUrlParamValue(url,"adcmd");o?(console.log(`commonbatch:${o}`),0===body.error_code?body.res.ad?.length?(body.res.ad=[],console.log("成功")):console.log("ad字段为空"):console.log("error_code不为0:"+body.error_code)):(console.log(`url:${url}`),$notification.post(notifyTitle,"贴吧-tiebaads/commonbatch","adCmd参数不存在"))}else if(url.includes("c/f/pb/picpage")){console.log("picpage");const o=body.recom_live_list?.length;o&&(console.log(`去除直播:${o}`),body.recom_live_list=[])}else if(url.includes("c/s/sync")){if(console.log("贴吧-sync"),"floating_icon"in body?(console.log("右下角悬浮icon"),body.floating_icon?(body.floating_icon.homepage?.icon_url?console.log("homepage悬浮去除"):console.log("无需去除homepage悬浮"),body.floating_icon.pb?.icon_url?console.log("pb悬浮去除"):console.log("无需去除pb悬浮"),body.floating_icon=null):console.log("无需修改floating_icon字段值")):(console.log(`body:${$response.body}`),$notification.post(notifyTitle,"贴吧-sync","无floating_icon字段")),"advertisement_config"in body?body.advertisement_config?.advertisement_str?(console.log(`advertisement_str:${body.advertisement_config.advertisement_str}`),body.advertisement_config=null):console.log("无需处理advertisement_config"):(console.log(`body:${$response.body}`),$notification.post(notifyTitle,"贴吧-sync","无advertisement_config字段")),"config"in body){if(body.config?.switch)for(const o of body.config.switch)["platform_csj_init","platform_ks_init","platform_gdt_init"].includes(o.name)&&(o.type="0",console.log(`禁止初始化${o.name}`))}else console.log(`body:${$response.body}`),$notification.post(notifyTitle,"贴吧-sync","无config字段");"screen_fill_data_result"in body?("1"===body.screen_fill_data_result.screen_fill_advertisement_bear_switch?(body.screen_fill_data_result.screen_fill_advertisement_bear_switch="0",console.log("开屏不展示小熊广告")):console.log("无需修改screen_fill_advertisement_bear_switch"),"1"===body.screen_fill_data_result.screen_fill_advertisement_plj_cpc_switch?(body.screen_fill_data_result.screen_fill_advertisement_plj_cpc_switch="0",console.log("开屏不展示序章CPC")):console.log("无需修改screen_fill_advertisement_plj_cpc_switch"),"1"===body.screen_fill_data_result.screen_fill_advertisement_plj_switch?(body.screen_fill_data_result.screen_fill_advertisement_plj_switch="0",console.log("开屏不展示序章")):console.log("无需修改screen_fill_advertisement_plj_switch")):(console.log(`body:${$response.body}`),$notification.post(notifyTitle,"贴吧-sync","无screen_fill_data_result字段")),"ad_stlog_switch"in body?"1"===body.ad_stlog_switch?(body.ad_stlog_switch="0",console.log("修改ad_stlog_switch")):console.log("无需修改ad_stlog_switch"):(console.log(`body:${$response.body}`),$notification.post(notifyTitle,"贴吧-sync","无ad_stlog_switch字段")),"lcs_strategy"in body?"0"===body.lcs_strategy.conn_conf?(body.lcs_strategy.conn_conf="1",console.log("修改conn_conf")):console.log("无需修改conn_conf"):(console.log(`body:${$response.body}`),$notification.post(notifyTitle,"贴吧-sync","无lcs_strategy字段"))}else if(url.includes("c/f/frs/page"))console.log("贴吧-FrsPage"),body.live_fuse_forum?.length?(body.live_fuse_forum=[],console.log("去除吧头直播")):console.log("无需处理吧头直播"),body.activityhead?.is_ad?(body.activityhead={},console.log("去除吧内header图片广告")):console.log("无需处理activityhead"),body.thread_list=removeLive(body.thread_list),removeGoodsInfo(body.forum?.banner_list?.app);else if(url.includes("c/f/frs/threadlist"))console.log("贴吧-threadlist"),removeGoodsInfo(body.banner_list?.app);else if(url.includes("c/f/pb/page")){if(console.log("贴吧-PbPage"),body.recom_ala_info?.live_id?(console.log("帖子详情页推荐的直播广告去除"),body.recom_ala_info=null):console.log("帖子详情页无直播广告"),body.post_list?.length)for(const o of body.post_list)o.outer_item&&(console.log("outer_item去除"),o.outer_item=null);else console.log("无需处理postList中的outer_item");removeGoodsInfo(body.banner_list?.app);const o=body.banner_list?.pb_banner_ad?.goods_info?.length;o&&(console.log(`去除pb_banner_ad的goods_info:${o}`),body.banner_list.pb_banner_ad.goods_info=[])}else url.includes("c/f/excellent/personalized")?(console.log("贴吧-personalized"),removeGoodsInfo(body.banner_list?.app),body.thread_list=removeLive(body.thread_list),body.live_answer?(console.log("去除推荐页上方的banner广告"),body.live_answer=null):console.log("推荐页无banner广告")):url.includes("c/f/frs/generalTabList")?(console.log("贴吧-generalTabList"),removeGoodsInfo(body.app_list)):$notification.post(notifyTitle,"路径/请求方法匹配错误:",method+","+url);function getUrlParamValue(o,e){return Object.fromEntries(o.substring(o.indexOf("?")+1).split("&").map((o=>o.split("="))))[e]}function removeGoodsInfo(o){if(o?.length){let e=0;o.forEach((o=>{o.goods_info?.length&&(e++,o.goods_info=[])})),e?console.log(`去除goods_info:${e}`):console.log("app内无goods_info")}else console.log("app为空,无需处理")}function removeLive(o){let e=o;const l=o?.length;return l?(e=o.filter((o=>!o.ala_info||(console.log("去除推荐的直播帖子"),!1))),l===e.length&&console.log("无推荐的直播帖子")):console.log("无需处理threadList"),e}body=JSON.stringify(body),$done({body:body}); \ No newline at end of file diff --git a/Scripts/AdBlock/Zhihu/Zhihu.js b/Scripts/AdBlock/Zhihu/Zhihu.js index 99e2868..76bccfc 100644 --- a/Scripts/AdBlock/Zhihu/Zhihu.js +++ b/Scripts/AdBlock/Zhihu/Zhihu.js @@ -8,2113 +8,1936 @@ const zheyeServerKey = "zheye_server_url"; const defaultAnswerBlockedUsers = ["会员推荐", "盐选推荐"]; const keywordMaxCount = 1e3; const $ = MagicJS(scriptName, "INFO"); + function getUserInfo() { - let t = { id: "default", is_vip: false }; - try { - let e = $.data.read(currentUserInfoKey); - if (typeof e === "string") e = JSON.parse(e); - if (!!e && e.hasOwnProperty("id")) { - return e; - } else { - return t; + let defaultUserInfo = {id: "default", is_vip: false}; + try { + let userInfo = $.data.read(currentUserInfoKey); + if (typeof userInfo === "string") userInfo = JSON.parse(userInfo); + if (!!userInfo && userInfo.hasOwnProperty("id")) { + return userInfo + } else { + return defaultUserInfo + } + } catch (err) { + $.logger.error(`获取用户信息出现异常:${err}`); + return defaultUserInfo } - } catch (e) { - $.logger.error(`获取用户信息出现异常:${e}`); - return t; - } } + function modifyAppConfig() { - let t = null; - try { - if (!!$.response.body) { - let e = JSON.parse($.response.body); - e["config"]["homepage_feed_tab"]["tab_infos"] = e["config"][ - "homepage_feed_tab" - ]["tab_infos"].filter((e) => { - if (e["tab_type"] === "activity_tab") { - e["end_time"] = (new Date() - 12e4).toString().slice(0, 10); - return true; - } else { - return false; - } - }); - e["config"]["zvideo_max_number"] = 1; - e["config"]["is_show_followguide_alert"] = false; - delete e["config"]["hp_channel_tab"]; - if (e["config"]["zombie_conf"]) { - e["config"]["zombie_conf"]["zombieEnable"] = false; - } - if (e["config"]["gray_mode"]) { - e["config"]["gray_mode"]["enable"] = false; - e["config"]["gray_mode"]["start_time"] = "4092566400"; - e["config"]["gray_mode"]["end_time"] = "4092566400"; - } - if (e["config"].hasOwnProperty("zhcnh_thread_sync")) { - $.logger.debug(JSON.stringify(e["config"]["zhcnh_thread_sync"])); - e["config"]["zhcnh_thread_sync"]["LocalDNSSetHostWhiteList"] = []; - e["config"]["zhcnh_thread_sync"]["isOpenLocalDNS"] = "0"; - e["config"]["zhcnh_thread_sync"]["ZHBackUpIP_Switch_Open"] = "0"; - e["config"]["zhcnh_thread_sync"]["dns_ip_detector_operation_lock"] = - "1"; - e["config"]["zhcnh_thread_sync"][ - "ZHHTTPSessionManager_setupZHHTTPHeaderField" - ] = "1"; - } - t = { body: JSON.stringify(e) }; - } - } catch (e) { - $.logger.error(`优化软件配置出现异常:${e}`); - } - return t; -} -function modifyMCloudConfig() { - let t = null; - try { - if (!!$.response.body) { - let e = JSON.parse($.response.body); - if (e.data && e.data["configs"]) { - e.data["configs"].forEach((e) => { - if (e["configKey"] === "feed_gray_theme") { - e["configValue"].start_time = "1669824000"; - e["configValue"].end_time = "1669824001"; - e.status = false; - } - }); - } - const r = JSON.stringify(e); - $.logger.debug(r); - t = { body: r }; - } - } catch (e) { - $.logger.error(`优化软件配置出现异常:${e}`); - } - return t; -} -function unlockBlockedKeywords() { - let i = null; - try { - const s = getUserInfo(); - if ($.request.method === "GET") { - let e = $.data.read(keywordBlockKey, null, s.id); - if (!e) { - e = []; - } - let t = { - "Cache-Control": - "no-cache, no-store, must-revalidate, private, max-age=0", - Connection: "keep-alive", - "Content-Type": "application/json;charset=utf-8", - Pragma: "no-cache", - "Referrer-Policy": "no-referrer-when-downgrade", - Server: "CLOUD ELB 1.0.0", - Vary: "Accept-Encoding", - "X-Cache-Lookup": "Cache Miss", - "x-cdn-provider": "tencent", - }; - let r = JSON.stringify({ - success: true, - is_vip: true, - kw_min_length: 2, - kw_max_length: 100, - kw_max_count: keywordMaxCount, - data: e, - }); - if ($.env.isQuanX) { - i = { body: r, headers: t, status: "HTTP/1.1 200 OK" }; - } else { - i = { response: { body: r, headers: t, status: 200 } }; - } - $.logger.debug(`获取本地脚本屏蔽关键词:\n${e.join("、")}`); - } else if ($.request.method === "POST") { - if (!!$.request.body) { - let t = { - "Cache-Control": - "no-cache, no-store, must-revalidate, private, max-age=0", - Connection: "keep-alive", - "Content-Type": "application/json;charset=utf-8", - Pragma: "no-cache", - "Referrer-Policy": "no-referrer-when-downgrade", - Server: "CLOUD ELB 1.0.0", - Vary: "Accept-Encoding", - "X-Cache-Lookup": "Cache Miss", - "x-cdn-provider": "tencent", - }; - let r = decodeURIComponent($.request.body).match(/keyword=(.*)/)[1]; - let n = $.data.read(keywordBlockKey, null, s.id); - if (!n) { - n = []; - } - let o = false; - for (let e = 0; e < n.length; e++) { - if (r === n[e]) { - o = true; - break; - } - } - if (o === false) { - n.push(r); - $.data.write(keywordBlockKey, n, s.id); - let e = JSON.stringify({ success: true }); - if ($.env.isQuanX) { - i = { body: e, headers: t, status: "HTTP/1.1 200 OK" }; - } else { - i = { response: { body: e, headers: t, status: 200 } }; - } - $.logger.debug(`添加本地脚本屏蔽关键词“${r}”`); - } else { - let e = JSON.stringify({ - error: { message: "关键词已存在", code: 100002 }, - }); - if ($.env.isQuanX) { - i = { body: e, headers: t, status: "HTTP/1.1 400 Bad Request" }; - } else { - i = { response: { body: e, headers: t, status: 400 } }; - } - } - } - } else if ($.request.method === "DELETE") { - let t = decodeURIComponent($.request.url).match(/keyword=(.*)/)[1]; - let e = $.data.read(keywordBlockKey, null, s.id); - if (!e) { - e = []; - } - e = e.filter((e) => { - return e !== t; - }); - $.data.write(keywordBlockKey, e, s.id); - let r = { - "Cache-Control": - "no-cache, no-store, must-revalidate, private, max-age=0", - Connection: "keep-alive", - "Content-Type": "application/json;charset=utf-8", - Pragma: "no-cache", - "Referrer-Policy": "no-referrer-when-downgrade", - Server: "CLOUD ELB 1.0.0", - Vary: "Accept-Encoding", - "X-Cache-Lookup": "Cache Miss", - "x-cdn-provider": "tencent", - }; - let n = JSON.stringify({ success: true }); - if ($.env.isQuanX) { - i = { body: n, headers: r, status: "HTTP/1.1 200 OK" }; - } else { - i = { response: { body: n, headers: r, status: 200 } }; - } - $.logger.debug(`删除本地脚本屏蔽关键词:“${t}”`); - } - } catch (e) { - $.logger.debug(`关键词屏蔽操作出现异常:${e}`); - } - return i; -} -function processUserInfo() { - let t = null; - try { - let e = JSON.parse($.response.body); - $.data.write(blackAnswersIdKey, []); - $.logger.debug(`用户登录用户信息,接口响应:${$.response.body}`); - if ( - e && - e["id"] && - e.hasOwnProperty("vip_info") && - e["vip_info"].hasOwnProperty("is_vip") - ) { - const r = { - id: e["id"], - is_vip: e["vip_info"]["is_vip"] - ? e["vip_info"]["is_vip"] !== undefined - : false, - }; - $.logger.debug( - `当前用户id:${e["id"]},是否为VIP:${e["vip_info"]["is_vip"]}` - ); - $.data.write(currentUserInfoKey, r); - if ( - $.data.read("zhihu_settings_fake_vip") !== false && - e["vip_info"]["is_vip"] === false - ) { - e["vip_info"]["is_vip"] = true; - e["vip_info"]["vip_type"] = 2; - e["vip_info"]["vip_icon"] = { - url: "https://picx.zhimg.com/v2-aa8a1823abfc46f14136f01d55224925.jpg?source=88ceefae", - night_mode_url: - "https://picx.zhimg.com/v2-aa8a1823abfc46f14136f01d55224925.jpg?source=88ceefae", - }; - e["vip_info"]["vip_icon_v2"] = { - url: "https://picx.zhimg.com/v2-aa8a1823abfc46f14136f01d55224925.jpg?source=88ceefae", - night_mode_url: - "https://picx.zhimg.com/v2-aa8a1823abfc46f14136f01d55224925.jpg?source=88ceefae", - }; - e["vip_info"]["entrance"] = { - icon: { - url: "https://pic3.zhimg.com/v2-5b7012c8c22fd520f5677305e1e551bf.png", - night_mode_url: - "https://pic4.zhimg.com/v2-e51e3252d7a2cb016a70879defd5da0b.png", - }, - title: "盐选会员 为你严选好内容", - expires_day: "2099-12-31", - sub_title: null, - button_text: "首月 9 元", - jump_url: "zhihu://vip/purchase", - button_jump_url: "zhihu://vip/purchase", - sub_title_new: null, - identity: "super_svip", - }; - e["vip_info"]["entrance_new"] = { - left_button: { - title: "精选会员内容", - description: "为您严选好内容", - jump_url: "zhihu://market/home", - }, - right_button: { - title: "开通盐选会员", - description: "畅享 10w+ 场优质内容等特权", - jump_url: "zhihu://vip/purchase", - }, - }; - e["vip_info"]["entrance_v2"] = { - title: "我的超级盐选会员", - sub_title: "畅享 5000W+ 优质内容", - jump_url: "zhihu://market/home", - button_text: "查看会员", - sub_title_color: "#F8E2C4", - sub_title_list: ["畅享 5000W+ 优质内容"], - card_jump_url: "zhihu://market/home", - }; - $.logger.debug("设置用户为本地盐选会员"); - t = { body: JSON.stringify(e) }; - } - } else { - $.logger.warning( - `没有获取到本次登录用户信息,如未对功能造成影响,请忽略此日志。` - ); - } - } catch (e) { - $.logger.error(`获取当前用户信息出现异常:${e}`); - } - return t; -} -function manageBlackUser() { - const r = getUserInfo(); - let t = {}; - let n = $.data.read(blockedUsersKey, "", r.id); - n = typeof n === "object" && !!n ? n : {}; - defaultAnswerBlockedUsers.forEach((e) => { - n[e] = "00000000000000000000000000000000"; - t[e] = "00000000000000000000000000000000"; - }); - $.logger.debug(`当前用户id:${r.id},脚本黑名单:${JSON.stringify(n)}`); - if ($.request.method === "GET") { + let response = null; try { - if ($.request.url.indexOf("offset") < 0) { - n = t; - $.logger.debug( - "脚本黑名单已清空,请滑动至黑名单末尾保证重新获取完成。" - ); - $.notification.post( - "开始同步黑名单数据,请滑动至黑名单末尾,直至弹出“同步成功”的通知。" - ); - } - let e = JSON.parse($.response.body); - if (!!e["data"]) { - $.logger.debug( - `本次滑动获取的黑名单信息:${JSON.stringify(e["data"])}` - ); - e["data"].forEach((e) => { - if (e["name"] !== "[已重置]") { - n[e["name"]] = e["id"]; - } - }); - $.data.write(blockedUsersKey, n, r.id); - if (e["paging"]["is_end"] === true) { - $.notification.post( - `同步黑名单数据成功!当前黑名单共${ - Object.keys(n).length - defaultAnswerBlockedUsers.length - }人。\n脚本内置黑名单${defaultAnswerBlockedUsers.length}人。` - ); - $.logger.debug(`脚本黑名单内容:${JSON.stringify(n)}。`); - } - } else { - $.logger.warning(`获取黑名单失败,接口响应不合法:${$.response.body}`); - } - } catch (e) { - $.data.del(blockedUsersKey); - $.logger.error(`获取黑名单失败,异常信息:${e}`); - $.notification.post("获取黑名单失败,执行异常,已清空黑名单。"); - } - } else if ($.request.method === "POST") { - try { - let e = JSON.parse($.response.body); - if (e.hasOwnProperty("name") && e.hasOwnProperty("id")) { - $.logger.debug( - `当前需要加入黑名单的用户Id:${e["id"]},用户名:${e["name"]}` - ); - if (e["id"]) { - n[e["name"]] = e["id"]; - $.data.write(blockedUsersKey, n, r.id); - $.logger.debug( - `${ - e["name"] - }写入脚本黑名单成功,当前脚本黑名单数据:${JSON.stringify(n)}` - ); - $.notification.post(`已将用户“${e["name"]}”写入脚本黑名单。`); - } else { - $.logger.error(`${e["name"]}写入脚本黑名单失败,没有获取到用户Id。`); - $.notification.post(`将用户“${e["name"]}”写入脚本黑名单失败!`); - } - } else { - $.logger.warning(`写入黑名单失败,接口响应不合法:${$.response.body}`); - $.notification.post("写入脚本黑名单失败,接口返回不合法。"); - } - } catch (e) { - $.logger.error(`写入黑名单失败,异常信息:${e}`); - $.notification.post("写入脚本黑名单失败,执行异常,请查阅日志。"); - } - } else if ($.request.method === "DELETE") { - try { - let e = JSON.parse($.response.body); - if (e.success) { - let t = $.request.url.match( - /^https?:\/\/api\.zhihu\.com\/settings\/blocked_users\/([0-9a-zA-Z]*)/ - )[1]; - if (t) { - $.logger.debug(`当前需要移出黑名单的用户Id:${t}`); - for (let e in n) { - if (n[e] === t) { - delete n[e]; - $.data.write(blockedUsersKey, n, r.id); - $.logger.debug( - `${e}移出脚本黑名单成功,当前脚本黑名单数据:${JSON.stringify( - n - )}` - ); - $.notification.post(`已将用户“${e}”移出脚本黑名单!`); - break; - } - } - } else { - $.logger.error( - "将用户移出脚本黑名单失败!\n建议从设置中刷新黑名单数据。" - ); - $.notification.post( - `将用户移出脚本黑名单失败,没有获取到用户Id。\n建议从设置中刷新黑名单数据。` - ); - } - } else { - $.logger.warning(`移出黑名单失败,接口响应不合法:${$.response.body}`); - $.notification.post("移出脚本黑名单失败,接口返回不合法。"); - } - } catch (e) { - $.logger.error(`移出黑名单失败,异常信息:${e}`); - $.notification.post("移出脚本黑名单失败,执行异常,请查阅日志。"); - } - } -} -function autoInsertBlackList() { - let e = null; - try { - let t = JSON.parse($.response.body); - delete t["mcn_user_info"]; - e = { body: JSON.stringify(t) }; - if (t.name && t.id && t["is_blocking"] === true) { - const r = getUserInfo(); - let e = $.data.read(blockedUsersKey, "", r.id); - e = typeof e === "object" && !!e ? e : {}; - if (!e[t.name]) { - $.logger.debug( - `当前需要加入黑名单的用户Id:${t["id"]},用户名:${t["name"]}` - ); - e[t["name"]] = t["id"]; - $.data.write(blockedUsersKey, e, r.id); - $.logger.debug( - `${t["name"]}写入脚本黑名单成功,当前脚本黑名单数据:${JSON.stringify( - e - )}` - ); - $.notification.post(`已自动将用户“${t["name"]}”写入脚本黑名单。`); - } - } - } catch (e) { - $.logger.error(`去除MCN信息出现异常:${e}`); - } - return e; -} -function removeMoments() { - let r = null; - try { - let e = JSON.parse( - $.response.body.replace(/(\w+"+\s?):\s?(\d{15,})/g, '$1:"$2"') - ); - const n = getUserInfo(); - let i = $.data.read(blockedUsersKey, "", n.id); - i = !!i ? i : {}; - let t; - const s = $.data.read("zhihu_settings_moments_stream", false); - const a = $.data.read("zhihu_settings_moments_recommend", false); - const l = $.data.read("zhihu_settings_moments_activity", false); - const c = $.data.read("zhihu_settings_blocked_users", false); - t = e.data.filter((e) => { - const t = - c && - e.target && - e.target["origin_pin"] && - e.target["origin_pin"].author && - typeof i[e.target["origin_pin"].author.name] != "undefined"; - const r = s && e["target_type"] === "zvideo"; - const n = a && e.type === "recommend_user_card_list"; - const o = l && e.type === "message_activity_card"; - return !(t || r || n || o); - }); - e["data"] = t; - r = { body: JSON.stringify(e) }; - } catch (e) { - $.logger.error(`关注列表去广告出现异常:${e}`); - } - return r; -} -function _setRecommendTag(e, t, r = "GBK02A") { - if (!e["common_card"]["footline"]) { - e["common_card"]["footline"] = { elements: [] }; - } - e["common_card"]["footline"]["elements"].unshift({ - tag: { text: t, color: r, type: "MASK_ROUNDED_RECTANGLE" }, - }); -} -async function _checkPaidContentByCloud(e, n) { - const t = $.data.read(zheyeServerKey); - if (!t) { - $.notification.post( - "未设置服务端地址,无法进行付费/推广内容探测。\n请配置服务端地址,或使用本地探测。" - ); - } else { - $.logger.debug(`向云端请求以下链接\n${e.join("\n")}`); - const r = `${t}/api/v1/answer/links`; - $.logger.debug(`服务端地址\n${r}`); - await $.http - .post({ - url: r, - headers: { "Content-Type": "application/json" }, - body: e, - }) - .then((r) => { - $.logger.debug( - `云端探测结果<${typeof r.body}>\n${JSON.stringify(r.body)}` - ); - for (let t = 0; t < r.body.length; t++) { - try { - let e = r.body[t]; - if (e !== "") { - _setRecommendTag(n[t], e, "GBK02A"); - } - } catch (e) { - $.logger.error(e); - } - } - }) - .catch((e) => { - $.logger.error(`云端请求出现异常\n${JSON.stringify(e)}`); - }); - } -} -async function _checkPaidContentByLocal(n, o) { - $.logger.debug(`将在本地请求以下链接\n${n.join("\n")}`); - let t = []; - function r(t) { - return new Promise((r) => { - const e = n[t]; - if ( - !e || - e === "" || - !e.startsWith("https://www.zhihu.com/appview/v2/answer") - ) { - r(""); - } else { - $.http - .get({ url: n[t], timeout: 1e3 }) - .then((e) => { - const t = e.body; - if ( - (t.indexOf("查看完整内容") >= 0 || - t.indexOf("查看全部章节") >= 0) && - t.indexOf("paid") >= 0 - ) { - r("付费内容"); - } else if ( - t.indexOf("ad-link-card") >= 0 || - t.indexOf("xg.zhihu.com") >= 0 || - t.indexOf("营销平台") >= 0 - ) { - r("营销推广"); - } else if (t.indexOf("mcn-link-card") >= 0) { - r("购物推广"); - } else { - r(""); - } - }) - .catch((e) => { - $.logger.error(`本地请求出现异常\n${JSON.stringify(e)}`); - r(""); - }); - } - }); - } - for (let e = 0; e < n.length; e++) { - t.push(r(e)); - } - await Promise.all(t).then((r) => { - $.logger.debug(`本地探测结果<${r.length}>\n${JSON.stringify(r)}`); - for (let t = 0; t < r.length; t++) { - try { - let e = r[t]; - if (e !== "") { - _setRecommendTag(o[t], e, "GBK02A"); - } - } catch (e) { - $.logger.error(e); - } - } - }); -} -async function removeRecommend() { - let t = null; - try { - const g = $.data.read("zhihu_settings_recommend_pin", false); - const p = $.data.read("zhihu_settings_recommend_stream", false); - const h = $.data.read("zhihu_settings_remove_article", false); - const y = $.data.read("zhihu_settings_blocked_users", false); - const m = $.data.read("zhihu_settings_blocked_keywords", true); - const r = $.data.read("zhihu_settings_check_paid_content", false); - const o = $.data.read("zhihu_settings_request_content", "local"); - const i = getUserInfo(); - let u = $.data.read(keywordBlockKey, "", i.id); - u = m && !!u ? u : []; - let f = $.data.read(blockedUsersKey, "", i.id); - f = y && !!f ? f : {}; - const s = (o) => { - const e = JSON.stringify(o); - const t = - o["card_type"] === "slot_event_card" || - o["card_type"] === "slot_video_event_card" || - o.hasOwnProperty("ad") || - (o["brief"] && o["brief"].indexOf("slot_card") >= 0) || - (o["extra"] && o["extra"]["type"] === "Training"); - const r = - t !== true && - e.search(/"(type|style)+"\s?:\s?"(drama|zvideo|Video|BIG_IMAGE)+"/i) >= - 0; - const n = r && p; - const i = r !== true && e.search(/"(type|style)+"\s?:\s?"pin"/i) >= 0; - const s = i && g; - const a = e.search(/"(type|style)+"\s?:\s?"article"/i) >= 0; - const l = a && h; - let c = false; - if (r !== true && m) { - for (let n = 0; n < u.length; n++) { - if (e.search(u[n]) >= 0) { - if ($.isDebug) { - let e = o["common_card"]["feed_content"]["title"]["panel_text"]; - let t = o["common_card"]["feed_content"]["content"]["panel_text"]; - let r = ""; - try { - r = - o["common_card"]["feed_content"]["title"]["action"][ - "intent_url" - ]; - } catch {} - $.logger.debug( - `匹配关键字:\n${u[n]}\n标题:\n${e}\n内容:\n${t}` - ); - $.notification.debug( - scriptName, - `关键字:${u[n]}`, - `${e}\n${t}`, - r - ); - } - c = true; - break; - } - } - } - let d; - try { - d = - c !== true && - y && - f && - o["common_card"]["feed_content"]["source_line"]["elements"][1][ - "text" - ]["panel_text"] in f; - } catch { - d = false; - } - return !(t || s || l || n || c || d); - }; - let e = JSON.parse( - $.response.body.replace(/(\w+"+\s?):\s?(\d{15,})/g, '$1:"$2"') - ); - let n = e["data"].filter(s); - if (r === true) { - let r = []; - for (let t = 0; t < n.length; t++) { - if (n[t]) { - try { - let e = - n[t]["common_card"]["feed_content"]["title"]["action"][ - "intent_url" - ]; - e = e.replace( - /^https:\/\/zhihu\.com\/question\/\d+\/answer\//, - "https://www.zhihu.com/appview/v2/answer/" - ); - r.push(e); - } catch { - r.push(""); - } - } - } - if (r.length > 0 && o === "cloud") { - await _checkPaidContentByCloud(r, n); - } else if (r.length > 0 && o === "local") { - await _checkPaidContentByLocal(r, n); - } - } - e["data"] = n; - t = { body: JSON.stringify(e) }; - } catch (e) { - $.logger.error(`推荐列表去广告出现异常:${e}`); - } - return t; -} -function removeQuestions() { - let t = null; - try { - const r = getUserInfo(); - let n = $.data.read(blockedUsersKey, "", r.id); - n = !!n ? n : {}; - let e = JSON.parse($.response.body); - const i = $.data.read("zhihu_settings_blocked_users", false); - $.logger.debug(`当前黑名单列表: ${JSON.stringify(n)}`); - let o = $.data.read(blackAnswersIdKey, []); - delete e["ad_info"]; - if (e["data"]) { - let r = []; - for (let t of e.data) { - let e = ""; - const a = t.target.id.toString(); - try { - if ("target" in t) { - e = t["target"]["author"]["name"]; - } - } catch (e) { - $.logger.error(`获取回答列表用户名出现异常:${e}`); - } - const l = typeof n[e] != "undefined"; - const c = i && l; - if ("target" in t) { - t["target"]["visible_only_to_author"] = false; - t["target"]["is_visible"] = true; - t["target"]["is_copyable"] = true; - } - if (!c) { - r.push(t); - } else if (c === true && o.includes(a) === false) { - o.push(a); - $.notification.debug(`记录黑名单用户${e}的回答Id:${a}`); - } - } - e.data = r; - } - $.data.write(blackAnswersIdKey, o); - const s = JSON.stringify(e); - $.logger.debug(`修改后的回答列表数据:${s}`); - t = { body: s }; - } catch (e) { - $.logger.error(`回答列表去广告出现异常:${e}`); - } - return t; -} -function modifyAnswer() { - let r = null; - try { - let e = $.response.body; - let t = ""; - if ( - (e.indexOf("查看完整内容") >= 0 || e.indexOf("查看全部章节") >= 0) && - e.indexOf("paid") >= 0 - ) { - t = - '
本文为付费内容
'; - } else if ( - e.indexOf("ad-link-card") >= 0 || - e.indexOf("xg.zhihu.com") >= 0 || - e.indexOf("营销平台") >= 0 - ) { - t = - '
本文含有营销推广
'; - } else if (e.indexOf("mcn-link-card") >= 0) { - t = - '
本文含有购物推广
'; - } else if (Math.floor(Math.random() * 200) === 7) { - t = - '
本文为免费内容
'; - } - if (t !== "") { - const n = e.match(/(richText[^<]*>)(.)/)[1]; - const o = e.lastIndexOf(n) + n.length; - r = { body: e.slice(0, o) + t + e.slice(o) }; - } - } catch (e) { - $.logger.error(`付费内容提醒出现异常:${e}`); - } - return r; -} -function removeComment() { - let e = null; - try { - if (!!$.response.body) { - let t = JSON.parse($.response.body); - t["ad_info"] = {}; - if ($.data.read("zhihu_settings_blocked_users", false) === true) { - let e = getUserInfo(); - let s = $.data.read(blockedUsersKey, "", e.id); - s = !!s ? s : {}; - let a = []; - let l = {}; - if (typeof t.root != "undefined") { - const n = t.root.author.name; - const o = typeof s[n] != "undefined"; - if (o === true) { - t.root.is_delete = true; - t.root.can_reply = false; - t.root.can_like = false; - t.root.author.name = "黑名单用户"; - t.root.author.avatar_url = - "https://picx.zhimg.com/v2-abed1a8c04700ba7d72b45195223e0ff_xll.jpg"; - } - } - if (typeof t.data != "undefined") { - t.data.forEach((e) => { - const t = e.author.name; - let r = ""; - if (e["reply_to_author"] && e["reply_to_author"].name) { - r = e["reply_to_author"].name; - } - const n = r !== ""; - const o = typeof s[t] != "undefined"; - const i = typeof s[r] != "undefined"; - if (o === true || i === true) { - if (o && !n && $.request.url.indexOf("root_comment") > 0) { - $.notification.debug(`屏蔽黑名单用户“${t}”的主评论。`); - } else if ( - !o && - n && - !i && - $.request.url.indexOf("child_comment") > 0 - ) { - $.notification.debug(`屏蔽黑名单用户“${t}”的子评论。`); - } else if ( - o && - !i && - $.request.url.indexOf("child_comment") > 0 - ) { - $.notification.debug( - `屏蔽黑名单用户“${t}”回复“${r}”的子评论。` - ); - } else if (o && i && $.request.url.indexOf("child_comment") > 0) { - $.notification.debug( - `屏蔽黑名单用户“${t}”回复黑名单用户“${r}”的子评论。` - ); - } - l[e.id] = t; - if (o) { - e.is_delete = true; - e.can_reply = false; - e.can_like = false; - e.author.exposed_medal = {}; - e.author.name = "[黑名单用户]"; - e.author.avatar_url = - "https://picx.zhimg.com/v2-abed1a8c04700ba7d72b45195223e0ff_xll.jpg"; - } - if (i) { - e["reply_to_author"].name = "[黑名单用户]"; - e["reply_to_author"].exposed_medal = {}; - e["reply_to_author"].avatar_url = - "https://picx.zhimg.com/v2-abed1a8c04700ba7d72b45195223e0ff_xll.jpg"; - } - } - if (e.child_comments) { - let i = []; - e.child_comments.forEach((e) => { - const t = e.author.name; - const r = - typeof e["reply_to_author"] != "undefined" - ? e["reply_to_author"].name - : ""; - const n = typeof s[t] != "undefined"; - const o = typeof s[r] != "undefined"; - if (n || o) { - if (n === true) { - $.notification.debug(`屏蔽黑名单用户“${t}”的子评论。`); - l[e.id] = t; - e.is_delete = true; - e.can_reply = false; - e.can_like = false; - e.author.name = "[黑名单用户]"; - e.author.exposed_medal = {}; - e.author.avatar_url = - "https://picx.zhimg.com/v2-abed1a8c04700ba7d72b45195223e0ff_xll.jpg"; - } - if (o === true) { - $.logger.debug(`修改前的子评论数据:\n${JSON.stringify(e)}`); - e["reply_to_author"].name = "[黑名单用户]"; - e["reply_to_author"].exposed_medal = {}; - e["reply_to_author"].avatar_url = - "https://picx.zhimg.com/v2-abed1a8c04700ba7d72b45195223e0ff_xll.jpg"; - $.notification.debug( - `隐藏“${t}”回复黑名单用户“${r}”的名称与头像。` - ); - $.logger.debug(`修改后的子评论数据:\n${JSON.stringify(e)}`); - } + if (!!$.response.body) { + let obj = JSON.parse($.response.body); + obj["config"]["homepage_feed_tab"]["tab_infos"] = obj["config"]["homepage_feed_tab"]["tab_infos"].filter(e => { + if (e["tab_type"] === "activity_tab") { + e["end_time"] = (new Date - 12e4).toString().slice(0, 10); + return true + } else { + return false } - i.push(e); - }); - e.child_comments = i; - } - a.push(e); - }); - } - t.data = a; - } - const r = JSON.stringify(t); - $.logger.debug(`过滤后的评论数据:\n${r}`); - e = { body: r }; - } - } catch (e) { - $.logger.error(`去除评论广告出现异常:${e}`); - } - return e; -} -function removeArticleAd() { - let t = null; - try { - if (!!$.response.body) { - let e = JSON.parse($.response.body); - e["ad_info"] = {}; - const r = JSON.stringify(e); - $.logger.debug(`过滤后的文章数据:\n${r}`); - t = { body: r }; - } - } catch (e) { - $.logger.error(`去除文章广告出现异常:${e}`); - } - return t; -} -function removeMarketingMsg() { - let t = null; - try { - let e = JSON.parse($.response.body); - let r = []; - for (let t of e["data"]) { - if (t["detail_title"] === "官方帐号消息") { - let e = t["unread_count"]; - if (e > 0) { - t["content"]["text"] = "未读消息" + e + "条"; - } else { - t["content"]["text"] = "全部消息已读"; - } - t["is_read"] = true; - t["unread_count"] = 0; - r.push(t); - } else if (t["detail_title"] !== "活动助手") { - r.push(t); - } - } - e["data"] = r; - t = { body: JSON.stringify(e) }; - } catch (e) { - $.logger.error(`屏蔽官方营销消息出现异常:${e}`); - } - return t; -} -function removeHotListAds() { - let t = null; - try { - if (!!$.response.body) { - let e = JSON.parse($.response.body); - if ("data" in e) { - e["data"] = e["data"].filter((e) => { - return ( - e["type"] === "hot_list_feed" || e["type"] === "hot_list_feed_video" - ); - }); - } - t = { body: JSON.stringify(e) }; - } - } catch (e) { - $.logger.error(`去除热榜广告出现异常:${e}`); - } - return t; -} -function removeKeywordAds() { - let t = null; - try { - if (!!$.response.body) { - $.logger.debug(`预置关键字返回:${$.response.body}`); - let e = JSON.parse($.response.body); - if (e.hasOwnProperty("preset_words") && e["preset_words"]["words"]) { - e["preset_words"]["words"] = e["preset_words"]["words"].filter((e) => { - return e["type"] !== "ad"; - }); - t = { body: JSON.stringify(e) }; - } - } - } catch (e) { - $.logger.error(`去除预置关键字广告出现异常:${e}`); - } - return t; -} -function removeNextBlackUserAnswer() { - let t = null; - try { - if (!!$.response.body) { - let e = JSON.parse($.response.body); - const n = $.data.read(blackAnswersIdKey, []); - if (n.length > 0) { - let r = []; - e.data.forEach((e) => { - const t = n.includes(e.id.toString()); - if (t === false) { - e.ad_info = { data: "" }; - r.push(e); - } else { - $.notification.debug( - `屏蔽翻页过程中出现的黑名单用户回答Id:${e.id}` - ); - } - }); - for (let e = 0; e < r.length; e++) { - if (r[e]["extra"] && r[e]["extra"]["question_index"]) { - r[e]["extra"]["question_index"] = e + 1; - } - if (r[e]["strategy_info"]) { - r[e]["strategy_info"]["global_index"] = e + 1; - r[e]["strategy_info"]["strategy_index"] = e + 1; - } - } - e.data = r; - } - t = { body: JSON.stringify(e) }; - } - } catch (e) { - $.logger.error(`屏蔽下翻黑名单用户的回答出现异常:${e}`); - } - return t; -} -function modifyAnswersNextData() { - let o = null; - try { - if (!!$.response.body) { - let e = JSON.parse($.response.body); - let t = getUserInfo(); - let r = $.data.read(blockedUsersKey, {}, t.id); - $.logger.debug(`脚本黑名单用户:\n${JSON.stringify(r)}`); - let n = []; - e.data.data.forEach((e) => { - e["ad_info"] = { data: "" }; - const t = typeof r[e.data.author.name] != "undefined"; - $.logger.debug(`用户${e.data.author.name}是否在黑名单中:${t}`); - if ( - $.data.read("zhihu_settings_blocked_users", false) === false || - t === false - ) { - n.push(e); - } - }); - e.data.data = n; - o = { body: JSON.stringify(e) }; - } - } catch (e) { - $.logger.error(`屏蔽回答信息流黑名单用户及广告:${e}`); - } - return o; -} -function changeUserCredit() { - $.notification.debug("开始修改用户盐值"); - let t = null; - try { - if (!!$.response.body) { - const r = parseInt($.data.read(userCreditScoreKey, 780)); - $.logger.debug(`准备修改用户盐值为${r}`); - let e = JSON.parse($.response.body); - if (e["credit_basis"].total_score < r) { - e["credit_basis"].total_score = r; - $.logger.debug(`已修改用户盐值为:${r}`); - } - t = { body: JSON.stringify(e) }; - } - } catch (e) { - $.logger.error(`修改用户盐值出现异常:${e}`); - } - return t; -} -(async () => { - let e = null; - if ($.isResponse) { - switch (true) { - case /^https:\/\/api\.zhihu\.com\/people\/self$/.test($.request.url): - e = processUserInfo(); - break; - case $.data.read("zhihu_settings_app_conf", false) === true && - /^https?:\/\/appcloud2\.zhihu\.com\/v\d+\/config/.test($.request.url): - e = modifyAppConfig(); - break; - case $.data.read("zhihu_settings_app_conf", false) === true && - /^https?:\/\/m-cloud\.zhihu\.com\/api\/cloud\/config\/all\?/.test( - $.request.url - ): - e = modifyMCloudConfig(); - break; - case /^https?:\/\/api\.zhihu\.com\/user-credit\/basis/.test( - $.request.url - ): - e = changeUserCredit(); - break; - case /^https:\/\/api\.zhihu\.com\/topstory\/recommend/.test( - $.request.url - ): - e = await removeRecommend(); - break; - case /^https?:\/\/api\.zhihu\.com\/(v4\/)?questions\/\d+/.test( - $.request.url - ): - e = removeQuestions(); - break; - case /^https?:\/\/api\.zhihu\.com\/next-data\?/.test($.request.url): - e = modifyAnswersNextData(); - break; - case $.data.read("zhihu_settings_sys_msg", true) !== false && - /^https?:\/\/api\.zhihu\.com\/notifications\/v3\/message/.test( - $.request.url - ): - e = removeMarketingMsg(); - break; - case /^https?:\/\/api\.zhihu\.com\/comment_v5\/(answers|pins|comments?|articles)\/\d+\/(root|child)_comment/.test( - $.request.url - ): - e = removeComment(); - break; - case /^https?:\/\/www\.zhihu\.com\/api\/v\d\/articles\/\d+\/recommendation\?/.test( - $.request.url - ): - e = removeArticleAd(); - break; - case /^https?:\/\/www\.zhihu\.com\/api\/v4\/comment_v5\/answers\/\d+\/abstract_comment\?/.test( - $.request.url - ): - e = removeComment(); - break; - case $.data.read("zhihu_settings_answer_tip", true) === true && - /^https?:\/\/www\.zhihu\.com\/appview\/v2\/answer\/.*(entry=(?!(preload-topstory|preload-search|preload-subscription)))?/.test( - $.request.url - ): - e = modifyAnswer(); - break; - case $.data.read("zhihu_settings_blocked_users", false) !== false && - /^https?:\/\/api\.zhihu\.com\/next\?/.test($.request.url): - e = removeNextBlackUserAnswer(); - break; - case $.data.read("zhihu_settings_blocked_users", true) === true && - /^https?:\/\/api\.zhihu\.com\/people\/((?!self).)*$/.test( - $.request.url - ): - e = autoInsertBlackList(); - break; - case /^https?:\/\/api\.zhihu\.com\/moments_v3\?/.test($.request.url): - e = removeMoments(); - break; - case $.data.read("zhihu_settings_hot_list", true) === true && - /^https?:\/\/api\.zhihu\.com\/topstory\/hot-lists(\?|\/)/.test( - $.request.url - ): - e = removeHotListAds(); - break; - case $.data.read("zhihu_settings_preset_words", true) === true && - /^https?:\/\/api\.zhihu\.com\/search\/preset_words\?/.test( - $.request.url - ): - e = removeKeywordAds(); - break; - case $.data.read("zhihu_settings_blocked_users", false) !== false && - /^https?:\/\/api\.zhihu\.com\/settings\/blocked_users/.test( - $.request.url - ): - manageBlackUser(); - break; - default: - $.logger.debug("没有匹配到任何请求,请确认配置正确。"); - break; - } - } else if ($.isRequest) { - if ( - $.data.read("zhihu_settings_blocked_keywords", false) !== false && - /^https?:\/\/api\.zhihu\.com\/feed-root\/block/.test($.request.url) === - true - ) { - e = unlockBlockedKeywords(e); - } - } else { - $.data.del(currentUserInfoKey); - $.data.del(blockedUsersKey); - $.data.del(keywordBlockKey); - $.notification.post("哲也同学数据清理完毕"); - } - if (e) { - $.done(e); - } else { - $.done(); - } -})(); -function MagicJS(e = "MagicJS", t = "INFO") { - const n = () => { - const e = typeof $loon !== "undefined"; - const t = typeof $task !== "undefined"; - const r = typeof module !== "undefined"; - const n = typeof $httpClient !== "undefined" && !e; - const o = typeof $storm !== "undefined"; - const i = - typeof $environment !== "undefined" && - typeof $environment["stash-build"] !== "undefined"; - const s = n || e || o || i; - const a = typeof importModule !== "undefined"; - return { - isLoon: e, - isQuanX: t, - isNode: r, - isSurge: n, - isStorm: o, - isStash: i, - isSurgeLike: s, - isScriptable: a, - get name() { - if (e) { - return "Loon"; - } else if (t) { - return "QuantumultX"; - } else if (r) { - return "NodeJS"; - } else if (n) { - return "Surge"; - } else if (a) { - return "Scriptable"; - } else { - return "unknown"; - } - }, - get build() { - if (n) { - return $environment["surge-build"]; - } else if (i) { - return $environment["stash-build"]; - } else if (o) { - return $storm.buildVersion; - } - }, - get language() { - if (n || i) { - return $environment["language"]; - } - }, - get version() { - if (n) { - return $environment["surge-version"]; - } else if (i) { - return $environment["stash-version"]; - } else if (o) { - return $storm.appVersion; - } else if (r) { - return process.version; - } - }, - get system() { - if (n) { - return $environment["system"]; - } else if (r) { - return process.platform; - } - }, - get systemVersion() { - if (o) { - return $storm.systemVersion; - } - }, - get deviceName() { - if (o) { - return $storm.deviceName; - } - }, - }; - }; - const o = (r, e = "INFO") => { - let n = e; - const o = { - SNIFFER: 6, - DEBUG: 5, - INFO: 4, - NOTIFY: 3, - WARNING: 2, - ERROR: 1, - CRITICAL: 0, - NONE: -1, - }; - const i = { - SNIFFER: "", - DEBUG: "", - INFO: "", - NOTIFY: "", - WARNING: "❗ ", - ERROR: "❌ ", - CRITICAL: "❌ ", - NONE: "", - }; - const t = (e, t = "INFO") => { - if (!(o[n] < o[t.toUpperCase()])) - console.log(`[${t}] [${r}]\n${i[t.toUpperCase()]}${e}\n`); - }; - const s = (e) => { - n = e; - }; - return { - getLevel: () => { - return n; - }, - setLevel: s, - sniffer: (e) => { - t(e, "SNIFFER"); - }, - debug: (e) => { - t(e, "DEBUG"); - }, - info: (e) => { - t(e, "INFO"); - }, - notify: (e) => { - t(e, "NOTIFY"); - }, - warning: (e) => { - t(e, "WARNING"); - }, - error: (e) => { - t(e, "ERROR"); - }, - retry: (e) => { - t(e, "RETRY"); - }, - }; - }; - return new (class { - constructor(e, t) { - this._startTime = Date.now(); - this.version = "3.0.0"; - this.scriptName = e; - this.env = n(); - this.logger = o(e, t); - this.http = - typeof MagicHttp === "function" - ? MagicHttp(this.env, this.logger) - : undefined; - this.data = - typeof MagicData === "function" - ? MagicData(this.env, this.logger) - : undefined; - this.notification = - typeof MagicNotification === "function" - ? MagicNotification(this.scriptName, this.env, this.logger, this.http) - : undefined; - this.utils = - typeof MagicUtils === "function" - ? MagicUtils(this.env, this.logger) - : undefined; - this.qinglong = - typeof MagicQingLong === "function" - ? MagicQingLong(this.env, this.data, this.logger) - : undefined; - if (typeof this.data !== "undefined") { - let e = this.data.read("magic_loglevel"); - const r = this.data.read("magic_bark_url"); - if (e) { - this.logger.setLevel(e.toUpperCase()); - } - if (r) { - this.notification.setBark(r); - } - } - } - get isRequest() { - return ( - typeof $request !== "undefined" && typeof $response === "undefined" - ); - } - get isResponse() { - return typeof $response !== "undefined"; - } - get isDebug() { - return this.logger.level === "DEBUG"; - } - get request() { - return typeof $request !== "undefined" ? $request : undefined; - } - get response() { - if (typeof $response !== "undefined") { - if ($response.hasOwnProperty("status")) - $response["statusCode"] = $response["status"]; - if ($response.hasOwnProperty("statusCode")) - $response["status"] = $response["statusCode"]; - return $response; - } else { - return undefined; - } - } - done = (e = {}) => { - this._endTime = Date.now(); - let t = (this._endTime - this._startTime) / 1e3; - this.logger.info(`SCRIPT COMPLETED: ${t} S.`); - if (typeof $done !== "undefined") { - $done(e); - } - }; - })(e, t); -} -function MagicNotification(i, s, a, l) { - let c = null; - let d = null; - const e = (t) => { - try { - let e = t.replace(/\/+$/g, ""); - c = `${/^https?:\/\/([^/]*)/.exec(e)[0]}/push`; - d = /\/([^\/]+)\/?$/.exec(e)[1]; - } catch (e) { - a.error(`Bark url error: ${e}.`); - } - }; - function t(e = i, t = "", r = "", n = "") { - const o = (r) => { - try { - let t = {}; - if (typeof r === "string") { - if (s.isLoon) t = { openUrl: r }; - else if (s.isQuanX) t = { "open-url": r }; - else if (s.isSurge) t = { url: r }; - } else if (typeof r === "object") { - if (s.isLoon) { - t["openUrl"] = !!r["open-url"] ? r["open-url"] : ""; - t["mediaUrl"] = !!r["media-url"] ? r["media-url"] : ""; - } else if (s.isQuanX) { - t = !!r["open-url"] || !!r["media-url"] ? r : {}; - } else if (s.isSurge) { - let e = r["open-url"] || r["openUrl"]; - t = e ? { url: e } : {}; - } - } - return t; - } catch (e) { - a.error(`通知选项转换失败${e}`); - } - return r; - }; - n = o(n); - if (arguments.length === 1) { - e = i; - (t = ""), (r = arguments[0]); - } - a.notify( - `title:${e}\nsubTitle:${t}\nbody:${r}\noptions:${ - typeof n === "object" ? JSON.stringify(n) : n - }` - ); - if (s.isSurge) { - $notification.post(e, t, r, n); - } else if (s.isLoon) { - if (!!n) $notification.post(e, t, r, n); - else $notification.post(e, t, r); - } else if (s.isQuanX) { - $notify(e, t, r, n); - } - if (c && d) { - u(e, t, r); - } - } - function r(e = i, t = "", r = "", n = "") { - if (a.getLevel() === "DEBUG") { - if (arguments.length === 1) { - e = i; - t = ""; - r = arguments[0]; - } - this.post(e, t, r, n); - } - } - function u(e = i, t = "", r = "", n = "") { - if (typeof l === "undefined" || typeof l.post === "undefined") { - throw "Bark notification needs to import MagicHttp module."; - } - let o = { - url: c, - headers: { "content-type": "application/json; charset=utf-8" }, - body: { title: e, body: t ? `${t}\n${r}` : r, device_key: d }, - }; - l.post(o).catch((e) => { - a.error(`Bark notify error: ${e}`); - }); - } - return { post: t, debug: r, bark: u, setBark: e }; -} -function MagicData(s, a) { - let l = { fs: undefined, data: {} }; - if (s.isNode) { - l.fs = require("fs"); - try { - l.fs.accessSync( - "./magic.json", - l.fs.constants.R_OK | l.fs.constants.W_OK - ); - } catch (e) { - l.fs.writeFileSync("./magic.json", "{}", { encoding: "utf8" }); - } - l.data = require("./magic.json"); - } - const c = (e, t) => { - if (typeof t === "object") { - return false; - } else { - return e === t; - } - }; - const d = (e) => { - if (e === "true") { - return true; - } else if (e === "false") { - return false; - } else if (typeof e === "undefined") { - return null; - } else { - return e; - } - }; - const u = (e, t, r, n) => { - if (r) { - try { - if (typeof e === "string") e = JSON.parse(e); - if (e["magic_session"] === true) { - e = e[r]; - } else { - e = null; - } - } catch { - e = null; - } - } - if (typeof e === "string" && e !== "null") { - try { - e = JSON.parse(e); - } catch {} - } - if (n === false && !!e && e["magic_session"] === true) { - e = null; - } - if ( - (e === null || typeof e === "undefined") && - t !== null && - typeof t !== "undefined" - ) { - e = t; - } - e = d(e); - return e; - }; - const i = (t) => { - if (typeof t === "string") { - let e = {}; - try { - e = JSON.parse(t); - const r = typeof e; - if ( - r !== "object" || - e instanceof Array || - r === "bool" || - e === null - ) { - e = {}; - } - } catch {} - return e; - } else if ( - t instanceof Array || - t === null || - typeof t === "undefined" || - t !== t || - typeof t === "boolean" - ) { - return {}; - } else { - return t; - } - }; - const f = (e, t = null, r = "", n = false, o = null) => { - let i = o || l.data; - if (!!i && typeof i[e] !== "undefined" && i[e] !== null) { - val = i[e]; - } else { - val = !!r ? {} : null; - } - val = u(val, t, r, n); - return val; - }; - const g = (e, t = null, r = "", n = false, o = null) => { - let i = ""; - if (o || s.isNode) { - i = f(e, t, r, n, o); - } else { - if (s.isSurgeLike) { - i = $persistentStore.read(e); - } else if (s.isQuanX) { - i = $prefs.valueForKey(e); - } - i = u(i, t, r, n); - } - a.debug( - `READ DATA [${e}]${!!r ? `[${r}]` : ""} <${typeof i}>\n${JSON.stringify( - i - )}` - ); - return i; - }; - const p = (t, r, n = "", e = null) => { - let o = e || l.data; - o = i(o); - if (!!n) { - let e = i(o[t]); - e["magic_session"] = true; - e[n] = r; - o[t] = e; - } else { - o[t] = r; - } - if (e !== null) { - e = o; - } - return o; - }; - const h = (e, t, r = "", n = null) => { - if (typeof t === "undefined" || t !== t) { - return false; - } - if (!s.isNode && (typeof t === "boolean" || typeof t === "number")) { - t = String(t); - } - let o = ""; - if (n || s.isNode) { - o = p(e, t, r, n); - } else { - if (!r) { - o = t; - } else { - if (s.isSurgeLike) { - o = !!$persistentStore.read(e) ? $persistentStore.read(e) : o; - } else if (s.isQuanX) { - o = !!$prefs.valueForKey(e) ? $prefs.valueForKey(e) : o; - } - o = i(o); - o["magic_session"] = true; - o[r] = t; - } - } - if (!!o && typeof o === "object") { - o = JSON.stringify(o, null, 4); - } - a.debug( - `WRITE DATA [${e}]${r ? `[${r}]` : ""} <${typeof t}>\n${JSON.stringify( - t - )}` - ); - if (!n) { - if (s.isSurgeLike) { - return $persistentStore.write(o, e); - } else if (s.isQuanX) { - return $prefs.setValueForKey(o, e); - } else if (s.isNode) { - try { - l.fs.writeFileSync("./magic.json", o); - return true; - } catch (e) { - a.error(e); - return false; - } - } - } - return true; - }; - const e = (t, r, n, o = c, i = null) => { - r = d(r); - const e = g(t, null, n, false, i); - if (o(e, r) === true) { - return false; - } else { - const s = h(t, r, n, i); - let e = g(t, null, n, false, i); - if (o === c && typeof e === "object") { - return s; - } - return o(r, e); - } - }; - const y = (e, t, r) => { - let n = r || l.data; - n = i(n); - if (!!t) { - obj = i(n[e]); - delete obj[t]; - n[e] = obj; - } else { - delete n[e]; - } - if (!!r) { - r = n; - } - return n; - }; - const t = (e, t = "", r = null) => { - let n = {}; - if (r || s.isNode) { - n = y(e, t, r); - if (!r) { - l.fs.writeFileSync("./magic.json", JSON.stringify(n, null, 4)); - } else { - r = n; - } - } else { - if (!t) { - if (s.isStorm) { - return $persistentStore.remove(e); - } else if (s.isSurgeLike) { - return $persistentStore.write(null, e); - } else if (s.isQuanX) { - return $prefs.removeValueForKey(e); - } - } else { - if (s.isSurgeLike) { - n = $persistentStore.read(e); - } else if (s.isQuanX) { - n = $prefs.valueForKey(e); - } - n = i(n); - delete n[t]; - const o = JSON.stringify(n, null, 4); - h(e, o); - } - } - a.debug(`DELETE KEY [${e}]${!!t ? `[${t}]` : ""}`); - }; - const r = (e, t = null) => { - let r = []; - let n = g(e, null, null, true, t); - n = i(n); - if (n["magic_session"] !== true) { - r = []; - } else { - r = Object.keys(n).filter((e) => e !== "magic_session"); - } - a.debug( - `READ ALL SESSIONS [${e}] <${typeof r}>\n${JSON.stringify(r, null, 4)}` - ); - return r; - }; - const n = (e, t = null) => { - let r = {}; - let n = g(e, null, null, true, t); - n = i(n); - if (n["magic_session"] === true) { - r = { ...n }; - delete r["magic_session"]; - } - a.debug( - `READ ALL SESSIONS [${e}] <${typeof r}>\n${JSON.stringify(r, null, 4)}` - ); - return r; - }; - return { - read: g, - write: h, - del: t, - update: e, - allSessions: n, - allSessionNames: r, - defaultValueComparator: c, - convertToObject: i, - }; -} -function MagicHttp(c, d) { - let r; - if (c.isNode) { - const a = require("axios"); - r = a.create(); - } - class e { - constructor(e = true) { - this.handlers = []; - this.isRequest = e; - } - use(e, t, r) { - if (typeof e === "function") { - d.debug(`Register fulfilled ${e.name}`); - } - if (typeof t === "function") { - d.debug(`Register rejected ${t.name}`); - } - this.handlers.push({ - fulfilled: e, - rejected: t, - synchronous: - r && typeof r.synchronous === "boolean" ? r.synchronous : false, - runWhen: r ? r.runWhen : null, - }); - return this.handlers.length - 1; - } - eject(e) { - if (this.handlers[e]) { - this.handlers[e] = null; - } - } - forEach(t) { - this.handlers.forEach((e) => { - if (e !== null) { - t(e); - } - }); - } - } - function o(e) { - let r = { ...e }; - if (!!r.params) { - if (!c.isNode) { - let e = Object.keys(r.params) - .map((e) => { - const t = encodeURIComponent(e); - r.url = r.url.replace(new RegExp(`${e}=[^&]*`, "ig"), ""); - r.url = r.url.replace(new RegExp(`${t}=[^&]*`, "ig"), ""); - return `${t}=${encodeURIComponent(r.params[e])}`; - }) - .join("&"); - if (r.url.indexOf("?") < 0) r.url += "?"; - if (!/(&|\?)$/g.test(r.url)) { - r.url += "&"; - } - r.url += e; - delete r.params; - d.debug(`Params to QueryString: ${r.url}`); - } - } - return r; - } - const u = (e, t) => { - let r = - typeof t === "object" ? { headers: {}, ...t } : { url: t, headers: {} }; - if (!r.method) { - r["method"] = e; - } - r = o(r); - if (r["rewrite"] === true) { - if (c.isSurge) { - r.headers["X-Surge-Skip-Scripting"] = false; - delete r["rewrite"]; - } else if (c.isQuanX) { - r["hints"] = false; - delete r["rewrite"]; - } - } - if (c.isSurgeLike) { - const n = r.headers["content-type"] || r.headers["Content-Type"]; - if ( - r["method"] !== "GET" && - n && - n.indexOf("application/json") >= 0 && - r.body instanceof Array - ) { - r.body = JSON.stringify(r.body); - d.debug(`Convert Array object to String: ${r.body}`); - } - } else if (c.isQuanX) { - if (r.hasOwnProperty("body") && typeof r["body"] !== "string") - r["body"] = JSON.stringify(r["body"]); - r["method"] = e; - } else if (c.isNode) { - if (e === "POST" || e === "PUT" || e === "PATCH" || e === "DELETE") { - r.data = r.data || r.body; - } else if (e === "GET") { - r.params = r.params || r.body; - } - delete r.body; - } - return r; - }; - const f = (t, r = null) => { - if (t) { - let e = { - ...t, - config: t.config || r, - status: t.statusCode || t.status, - body: t.body || t.data, - headers: t.headers || t.header, - }; - if (typeof e.body === "string") { - try { - e.body = JSON.parse(e.body); - } catch {} - } - delete e.data; - return e; - } else { - return t; - } - }; - const t = (r) => { - return Object.keys(r).reduce((e, t) => { - e[t.toLowerCase()] = r[t]; - return e; - }, {}); - }; - const n = (n) => { - return Object.keys(n).reduce((e, t) => { - const r = t - .split("-") - .map((e) => e[0].toUpperCase() + e.slice(1)) - .join("-"); - e[r] = n[t]; - return e; - }, {}); - }; - const g = (e, t = null) => { - if (!!e && e.status >= 400) { - d.debug(`Raise exception when status code is ${e.status}`); - return { - name: "RequestException", - message: `Request failed with status code ${e.status}`, - config: t || e.config, - response: e, - }; - } - }; - const i = { request: new e(), response: new e(false) }; - let p = []; - let h = []; - let y = true; - function $(e) { - e = o(e); - d.debug(`HTTP ${e["method"].toUpperCase()}:\n${JSON.stringify(e)}`); - return e; - } - function m(e) { - try { - e = !!e ? f(e) : e; - d.sniffer( - `HTTP ${e.config["method"].toUpperCase()}:\n${JSON.stringify( - e.config - )}\nSTATUS CODE:\n${e.status}\nRESPONSE:\n${ - typeof e.body === "object" ? JSON.stringify(e.body) : e.body - }` - ); - const t = g(e); - if (!!t) { - return Promise.reject(t); - } - return e; - } catch (t) { - d.error(t); - return e; - } - } - const _ = (t) => { - try { - p = []; - h = []; - i.request.forEach((e) => { - if (typeof e.runWhen === "function" && e.runWhen(t) === false) { - return; - } - y = y && e.synchronous; - p.unshift(e.fulfilled, e.rejected); - }); - i.response.forEach((e) => { - h.push(e.fulfilled, e.rejected); - }); - } catch (e) { - d.error(`Failed to register interceptors: ${e}.`); - } - }; - const s = (e, n) => { - let o; - const t = e.toUpperCase(); - n = u(t, n); - if (c.isNode) { - o = r; - } else { - if (c.isSurgeLike) { - o = (i) => { - return new Promise((n, o) => { - $httpClient[e.toLowerCase()](i, (t, r, e) => { - if (t) { - let e = { - name: t.name || t, - message: t.message || t, - stack: t.stack || t, - config: i, - response: f(r), - }; - o(e); - } else { - r.config = i; - r.body = e; - n(r); - } }); - }); - }; - } else { - o = (o) => { - return new Promise((r, n) => { - $task - .fetch(o) - .then((e) => { - e = f(e, o); - const t = g(e, o); - if (t) { - return Promise.reject(t); - } - r(e); - }) - .catch((e) => { - let t = { - name: e.message || e.error, - message: e.message || e.error, - stack: e.error, - config: o, - response: !!e.response ? f(e.response) : null, - }; - n(t); - }); - }); - }; - } - } - let i; - _(n); - const s = [$, undefined]; - const a = [m, undefined]; - if (!y) { - d.debug("Interceptors are executed in asynchronous mode"); - let r = [o, undefined]; - Array.prototype.unshift.apply(r, s); - Array.prototype.unshift.apply(r, p); - r = r.concat(a); - r = r.concat(h); - i = Promise.resolve(n); - while (r.length) { - try { - let e = r.shift(); - let t = r.shift(); - if (!c.isNode && n["timeout"] && e === o) { - e = l; - } - if (typeof e === "function") { - d.debug(`Executing request fulfilled ${e.name}`); - } - if (typeof t === "function") { - d.debug(`Executing request rejected ${t.name}`); - } - i = i.then(e, t); - } catch (e) { - d.error(`request exception: ${e}`); + obj["config"]["zvideo_max_number"] = 1; + obj["config"]["is_show_followguide_alert"] = false; + delete obj["config"]["hp_channel_tab"]; + if (obj["config"]["zombie_conf"]) { + obj["config"]["zombie_conf"]["zombieEnable"] = false + } + if (obj["config"]["gray_mode"]) { + obj["config"]["gray_mode"]["enable"] = false; + obj["config"]["gray_mode"]["start_time"] = "4092566400"; + obj["config"]["gray_mode"]["end_time"] = "4092566400" + } + if (obj["config"].hasOwnProperty("zhcnh_thread_sync")) { + $.logger.debug(JSON.stringify(obj["config"]["zhcnh_thread_sync"])); + obj["config"]["zhcnh_thread_sync"]["LocalDNSSetHostWhiteList"] = []; + obj["config"]["zhcnh_thread_sync"]["isOpenLocalDNS"] = "0"; + obj["config"]["zhcnh_thread_sync"]["ZHBackUpIP_Switch_Open"] = "0"; + obj["config"]["zhcnh_thread_sync"]["dns_ip_detector_operation_lock"] = "1"; + obj["config"]["zhcnh_thread_sync"]["ZHHTTPSessionManager_setupZHHTTPHeaderField"] = "1" + } + response = {body: JSON.stringify(obj)} } - } - return i; - } else { - d.debug("Interceptors are executed in synchronous mode"); - Array.prototype.unshift.apply(p, s); - p = p.concat([$, undefined]); - while (p.length) { - let e = p.shift(); - let t = p.shift(); - try { - if (typeof e === "function") { - d.debug(`Executing request fulfilled ${e.name}`); - } - n = e(n); - } catch (e) { - if (typeof t === "function") { - d.debug(`Executing request rejected ${t.name}`); - } - t(e); - break; - } - } - try { - if (!c.isNode && n["timeout"]) { - i = l(n); - } else { - i = o(n); - } - } catch (e) { - return Promise.reject(e); - } - Array.prototype.unshift.apply(h, a); - while (h.length) { - i = i.then(h.shift(), h.shift()); - } - return i; + } catch (err) { + $.logger.error(`优化软件配置出现异常:${err}`) } - function l(r) { - try { - const e = new Promise((e, t) => { - setTimeout(() => { - let e = { - message: `timeout of ${r["timeout"]}ms exceeded.`, - config: r, - }; - t(e); - }, r["timeout"]); - }); - return Promise.race([o(r), e]); - } catch (e) { - d.error(`Request Timeout exception: ${e}.`); - } - } - }; - return { - request: s, - interceptors: i, - convertHeadersToLowerCase: t, - convertHeadersToCamelCase: n, - modifyResponse: f, - get: (e) => { - return s("GET", e); - }, - post: (e) => { - return s("POST", e); - }, - put: (e) => { - return s("PUT", e); - }, - patch: (e) => { - return s("PATCH", e); - }, - delete: (e) => { - return s("DELETE", e); - }, - head: (e) => { - return s("HEAD", e); - }, - options: (e) => { - return s("OPTIONS", e); - }, - }; + return response } + +function modifyMCloudConfig() { + let response = null; + try { + if (!!$.response.body) { + let obj = JSON.parse($.response.body); + if (obj.data && obj.data["configs"]) { + obj.data["configs"].forEach(element => { + if (element["configKey"] === "feed_gray_theme") { + element["configValue"].start_time = "1669824000"; + element["configValue"].end_time = "1669824001"; + element.status = false + } + }) + } + const body = JSON.stringify(obj); + $.logger.debug(body); + response = {body: body} + } + } catch (err) { + $.logger.error(`优化软件配置出现异常:${err}`) + } + return response +} + +function unlockBlockedKeywords() { + let response = null; + try { + const userInfo = getUserInfo(); + if ($.request.method === "GET") { + let keywords = $.data.read(keywordBlockKey, null, userInfo.id); + if (!keywords) { + keywords = [] + } + let headers = { + "Cache-Control": "no-cache, no-store, must-revalidate, private, max-age=0", + Connection: "keep-alive", + "Content-Type": "application/json;charset=utf-8", + Pragma: "no-cache", + "Referrer-Policy": "no-referrer-when-downgrade", + Server: "CLOUD ELB 1.0.0", + Vary: "Accept-Encoding", + "X-Cache-Lookup": "Cache Miss", + "x-cdn-provider": "tencent" + }; + let body = JSON.stringify({ + success: true, + is_vip: true, + kw_min_length: 2, + kw_max_length: 100, + kw_max_count: keywordMaxCount, + data: keywords + }); + if ($.env.isQuanX) { + response = {body: body, headers: headers, status: "HTTP/1.1 200 OK"} + } else { + response = {response: {body: body, headers: headers, status: 200}} + } + $.logger.debug(`获取本地脚本屏蔽关键词:\n${keywords.join("、")}`) + } else if ($.request.method === "POST") { + if (!!$.request.body) { + let headers = { + "Cache-Control": "no-cache, no-store, must-revalidate, private, max-age=0", + Connection: "keep-alive", + "Content-Type": "application/json;charset=utf-8", + Pragma: "no-cache", + "Referrer-Policy": "no-referrer-when-downgrade", + Server: "CLOUD ELB 1.0.0", + Vary: "Accept-Encoding", + "X-Cache-Lookup": "Cache Miss", + "x-cdn-provider": "tencent" + }; + let keyword = decodeURIComponent($.request.body).match(/keyword=(.*)/)[1]; + let keywords = $.data.read(keywordBlockKey, null, userInfo.id); + if (!keywords) { + keywords = [] + } + let keywordExists = false; + for (let i = 0; i < keywords.length; i++) { + if (keyword === keywords[i]) { + keywordExists = true; + break + } + } + if (keywordExists === false) { + keywords.push(keyword); + $.data.write(keywordBlockKey, keywords, userInfo.id); + let body = JSON.stringify({success: true}); + if ($.env.isQuanX) { + response = {body: body, headers: headers, status: "HTTP/1.1 200 OK"} + } else { + response = {response: {body: body, headers: headers, status: 200}} + } + $.logger.debug(`添加本地脚本屏蔽关键词“${keyword}”`) + } else { + let body = JSON.stringify({error: {message: "关键词已存在", code: 100002}}); + if ($.env.isQuanX) { + response = {body: body, headers: headers, status: "HTTP/1.1 400 Bad Request"} + } else { + response = {response: {body: body, headers: headers, status: 400}} + } + } + } + } else if ($.request.method === "DELETE") { + let keyword = decodeURIComponent($.request.url).match(/keyword=(.*)/)[1]; + let keywords = $.data.read(keywordBlockKey, null, userInfo.id); + if (!keywords) { + keywords = [] + } + keywords = keywords.filter(e => { + return e !== keyword + }); + $.data.write(keywordBlockKey, keywords, userInfo.id); + let headers = { + "Cache-Control": "no-cache, no-store, must-revalidate, private, max-age=0", + Connection: "keep-alive", + "Content-Type": "application/json;charset=utf-8", + Pragma: "no-cache", + "Referrer-Policy": "no-referrer-when-downgrade", + Server: "CLOUD ELB 1.0.0", + Vary: "Accept-Encoding", + "X-Cache-Lookup": "Cache Miss", + "x-cdn-provider": "tencent" + }; + let body = JSON.stringify({success: true}); + if ($.env.isQuanX) { + response = {body: body, headers: headers, status: "HTTP/1.1 200 OK"} + } else { + response = {response: {body: body, headers: headers, status: 200}} + } + $.logger.debug(`删除本地脚本屏蔽关键词:“${keyword}”`) + } + } catch (err) { + $.logger.debug(`关键词屏蔽操作出现异常:${err}`) + } + return response +} + +function processUserInfo() { + let response = null; + try { + let obj = JSON.parse($.response.body); + $.data.write(blackAnswersIdKey, []); + $.logger.debug(`用户登录用户信息,接口响应:${$.response.body}`); + if (obj && obj["id"] && obj.hasOwnProperty("vip_info") && obj["vip_info"].hasOwnProperty("is_vip")) { + const userInfo = { + id: obj["id"], + is_vip: obj["vip_info"]["is_vip"] ? obj["vip_info"]["is_vip"] !== undefined : false + }; + $.logger.debug(`当前用户id:${obj["id"]},是否为VIP:${obj["vip_info"]["is_vip"]}`); + $.data.write(currentUserInfoKey, userInfo); + if ($.data.read("zhihu_settings_fake_vip") !== false && obj["vip_info"]["is_vip"] === false) { + obj["vip_info"]["is_vip"] = true; + obj["vip_info"]["vip_type"] = 2; + obj["vip_info"]["vip_icon"] = { + url: "https://picx.zhimg.com/v2-aa8a1823abfc46f14136f01d55224925.jpg?source=88ceefae", + night_mode_url: "https://picx.zhimg.com/v2-aa8a1823abfc46f14136f01d55224925.jpg?source=88ceefae" + }; + obj["vip_info"]["vip_icon_v2"] = { + url: "https://picx.zhimg.com/v2-aa8a1823abfc46f14136f01d55224925.jpg?source=88ceefae", + night_mode_url: "https://picx.zhimg.com/v2-aa8a1823abfc46f14136f01d55224925.jpg?source=88ceefae" + }; + obj["vip_info"]["entrance"] = { + icon: { + url: "https://pic3.zhimg.com/v2-5b7012c8c22fd520f5677305e1e551bf.png", + night_mode_url: "https://pic4.zhimg.com/v2-e51e3252d7a2cb016a70879defd5da0b.png" + }, + title: "盐选会员 为你严选好内容", + expires_day: "2099-12-31", + sub_title: null, + button_text: "首月 9 元", + jump_url: "zhihu://vip/purchase", + button_jump_url: "zhihu://vip/purchase", + sub_title_new: null, + identity: "super_svip" + }; + obj["vip_info"]["entrance_new"] = { + left_button: { + title: "精选会员内容", + description: "为您严选好内容", + jump_url: "zhihu://market/home" + }, + right_button: { + title: "开通盐选会员", + description: "畅享 10w+ 场优质内容等特权", + jump_url: "zhihu://vip/purchase" + } + }; + obj["vip_info"]["entrance_v2"] = { + title: "我的超级盐选会员", + sub_title: "畅享 5000W+ 优质内容", + jump_url: "zhihu://market/home", + button_text: "查看会员", + sub_title_color: "#F8E2C4", + sub_title_list: ["畅享 5000W+ 优质内容"], + card_jump_url: "zhihu://market/home" + }; + $.logger.debug("设置用户为本地盐选会员"); + response = {body: JSON.stringify(obj)} + } + } else { + $.logger.warning(`没有获取到本次登录用户信息,如未对功能造成影响,请忽略此日志。`) + } + } catch (err) { + $.logger.error(`获取当前用户信息出现异常:${err}`) + } + return response +} + +function manageBlackUser() { + const userInfo = getUserInfo(); + let defaultBlockedUsers = {}; + let customBlockedUsers = $.data.read(blockedUsersKey, "", userInfo.id); + customBlockedUsers = typeof customBlockedUsers === "object" && !!customBlockedUsers ? customBlockedUsers : {}; + defaultAnswerBlockedUsers.forEach(element => { + customBlockedUsers[element] = "00000000000000000000000000000000"; + defaultBlockedUsers[element] = "00000000000000000000000000000000" + }); + $.logger.debug(`当前用户id:${userInfo.id},脚本黑名单:${JSON.stringify(customBlockedUsers)}`); + if ($.request.method === "GET") { + try { + if ($.request.url.indexOf("offset") < 0) { + customBlockedUsers = defaultBlockedUsers; + $.logger.debug("脚本黑名单已清空,请滑动至黑名单末尾保证重新获取完成。"); + $.notification.post("开始同步黑名单数据,请滑动至黑名单末尾,直至弹出“同步成功”的通知。") + } + let obj = JSON.parse($.response.body); + if (!!obj["data"]) { + $.logger.debug(`本次滑动获取的黑名单信息:${JSON.stringify(obj["data"])}`); + obj["data"].forEach(element => { + if (element["name"] !== "[已重置]") { + customBlockedUsers[element["name"]] = element["id"] + } + }); + $.data.write(blockedUsersKey, customBlockedUsers, userInfo.id); + if (obj["paging"]["is_end"] === true) { + $.notification.post(`同步黑名单数据成功!当前黑名单共${Object.keys(customBlockedUsers).length - defaultAnswerBlockedUsers.length}人。\n脚本内置黑名单${defaultAnswerBlockedUsers.length}人。`); + $.logger.debug(`脚本黑名单内容:${JSON.stringify(customBlockedUsers)}。`) + } + } else { + $.logger.warning(`获取黑名单失败,接口响应不合法:${$.response.body}`) + } + } catch (err) { + $.data.del(blockedUsersKey); + $.logger.error(`获取黑名单失败,异常信息:${err}`); + $.notification.post("获取黑名单失败,执行异常,已清空黑名单。") + } + } else if ($.request.method === "POST") { + try { + let obj = JSON.parse($.response.body); + if (obj.hasOwnProperty("name") && obj.hasOwnProperty("id")) { + $.logger.debug(`当前需要加入黑名单的用户Id:${obj["id"]},用户名:${obj["name"]}`); + if (obj["id"]) { + customBlockedUsers[obj["name"]] = obj["id"]; + $.data.write(blockedUsersKey, customBlockedUsers, userInfo.id); + $.logger.debug(`${obj["name"]}写入脚本黑名单成功,当前脚本黑名单数据:${JSON.stringify(customBlockedUsers)}`); + $.notification.post(`已将用户“${obj["name"]}”写入脚本黑名单。`) + } else { + $.logger.error(`${obj["name"]}写入脚本黑名单失败,没有获取到用户Id。`); + $.notification.post(`将用户“${obj["name"]}”写入脚本黑名单失败!`) + } + } else { + $.logger.warning(`写入黑名单失败,接口响应不合法:${$.response.body}`); + $.notification.post("写入脚本黑名单失败,接口返回不合法。") + } + } catch (err) { + $.logger.error(`写入黑名单失败,异常信息:${err}`); + $.notification.post("写入脚本黑名单失败,执行异常,请查阅日志。") + } + } else if ($.request.method === "DELETE") { + try { + let obj = JSON.parse($.response.body); + if (obj.success) { + let user_id = $.request.url.match(/^https?:\/\/api\.zhihu\.com\/settings\/blocked_users\/([0-9a-zA-Z]*)/)[1]; + if (user_id) { + $.logger.debug(`当前需要移出黑名单的用户Id:${user_id}`); + for (let username in customBlockedUsers) { + if (customBlockedUsers[username] === user_id) { + delete customBlockedUsers[username]; + $.data.write(blockedUsersKey, customBlockedUsers, userInfo.id); + $.logger.debug(`${username}移出脚本黑名单成功,当前脚本黑名单数据:${JSON.stringify(customBlockedUsers)}`); + $.notification.post(`已将用户“${username}”移出脚本黑名单!`); + break + } + } + } else { + $.logger.error("将用户移出脚本黑名单失败!\n建议从设置中刷新黑名单数据。"); + $.notification.post(`将用户移出脚本黑名单失败,没有获取到用户Id。\n建议从设置中刷新黑名单数据。`) + } + } else { + $.logger.warning(`移出黑名单失败,接口响应不合法:${$.response.body}`); + $.notification.post("移出脚本黑名单失败,接口返回不合法。") + } + } catch (err) { + $.logger.error(`移出黑名单失败,异常信息:${err}`); + $.notification.post("移出脚本黑名单失败,执行异常,请查阅日志。") + } + } +} + +function autoInsertBlackList() { + let response = null; + try { + let obj = JSON.parse($.response.body); + delete obj["mcn_user_info"]; + response = {body: JSON.stringify(obj)}; + if (obj.name && obj.id && obj["is_blocking"] === true) { + const userInfo = getUserInfo(); + let customBlockedUsers = $.data.read(blockedUsersKey, "", userInfo.id); + customBlockedUsers = typeof customBlockedUsers === "object" && !!customBlockedUsers ? customBlockedUsers : {}; + if (!customBlockedUsers[obj.name]) { + $.logger.debug(`当前需要加入黑名单的用户Id:${obj["id"]},用户名:${obj["name"]}`); + customBlockedUsers[obj["name"]] = obj["id"]; + $.data.write(blockedUsersKey, customBlockedUsers, userInfo.id); + $.logger.debug(`${obj["name"]}写入脚本黑名单成功,当前脚本黑名单数据:${JSON.stringify(customBlockedUsers)}`); + $.notification.post(`已自动将用户“${obj["name"]}”写入脚本黑名单。`) + } + } + } catch (err) { + $.logger.error(`去除MCN信息出现异常:${err}`) + } + return response +} + +function removeMoments() { + let response = null; + try { + let obj = JSON.parse($.response.body.replace(/(\w+"+\s?):\s?(\d{15,})/g, '$1:"$2"')); + const user_info = getUserInfo(); + let customBlockedUsers = $.data.read(blockedUsersKey, "", user_info.id); + customBlockedUsers = !!customBlockedUsers ? customBlockedUsers : {}; + let data; + const settings_remove_stream = $.data.read("zhihu_settings_moments_stream", false); + const settings_remove_recommend = $.data.read("zhihu_settings_moments_recommend", false); + const settings_remove_activity = $.data.read("zhihu_settings_moments_activity", false); + const settings_blocked_users = $.data.read("zhihu_settings_blocked_users", false); + data = obj.data.filter(item => { + const isBlackUserPin = settings_blocked_users && item.target && item.target["origin_pin"] && item.target["origin_pin"].author && typeof customBlockedUsers[item.target["origin_pin"].author.name] != "undefined"; + const isStream = settings_remove_stream && item["target_type"] === "zvideo"; + const isRecommend = settings_remove_recommend && item.type === "recommend_user_card_list"; + const isActivity = settings_remove_activity && item.type === "message_activity_card"; + return !(isBlackUserPin || isStream || isRecommend || isActivity) + }); + obj["data"] = data; + response = {body: JSON.stringify(obj)} + } catch (err) { + $.logger.error(`关注列表去广告出现异常:${err}`) + } + return response +} + +function _setRecommendTag(item, text, color = "GBK02A") { + if (!item["common_card"]["footline"]) { + item["common_card"]["footline"] = {elements: []} + } + item["common_card"]["footline"]["elements"].unshift({ + tag: { + text: text, + color: color, + type: "MASK_ROUNDED_RECTANGLE" + } + }) +} + +async function _checkPaidContentByCloud(filteredUrls, newData) { + const zheyeServer = $.data.read(zheyeServerKey); + if (!zheyeServer) { + $.notification.post("未设置服务端地址,无法进行付费/推广内容探测。\n请配置服务端地址,或使用本地探测。") + } else { + $.logger.debug(`向云端请求以下链接\n${filteredUrls.join("\n")}`); + const url = `${zheyeServer}/api/v1/answer/links`; + $.logger.debug(`服务端地址\n${url}`); + await $.http.post({url: url, headers: {"Content-Type": "application/json"}, body: filteredUrls}).then(resp => { + $.logger.debug(`云端探测结果<${typeof resp.body}>\n${JSON.stringify(resp.body)}`); + for (let i = 0; i < resp.body.length; i++) { + try { + let tagText = resp.body[i]; + if (tagText !== "") { + _setRecommendTag(newData[i], tagText, "GBK02A") + } + } catch (err) { + $.logger.error(err) + } + } + }).catch(err => { + $.logger.error(`云端请求出现异常\n${JSON.stringify(err)}`) + }) + } +} + +async function _checkPaidContentByLocal(filteredUrls, newData) { + $.logger.debug(`将在本地请求以下链接\n${filteredUrls.join("\n")}`); + let requestPromise = []; + + function _requestAnswerContent(i) { + return new Promise(resolve => { + const url = filteredUrls[i]; + if (!url || url === "" || !url.startsWith("https://www.zhihu.com/appview/v2/answer")) { + resolve("") + } else { + $.http.get({url: filteredUrls[i], timeout: 1e3}).then(resp => { + const body = resp.body; + if ((body.indexOf("查看完整内容") >= 0 || body.indexOf("查看全部章节") >= 0) && body.indexOf("paid") >= 0) { + resolve("付费内容") + } else if (body.indexOf("ad-link-card") >= 0 || body.indexOf("xg.zhihu.com") >= 0 || body.indexOf("营销平台") >= 0) { + resolve("营销推广") + } else if (body.indexOf("mcn-link-card") >= 0) { + resolve("购物推广") + } else { + resolve("") + } + }).catch(err => { + $.logger.error(`本地请求出现异常\n${JSON.stringify(err)}`); + resolve("") + }) + } + }) + } + + for (let i = 0; i < filteredUrls.length; i++) { + requestPromise.push(_requestAnswerContent(i)) + } + await Promise.all(requestPromise).then(result => { + $.logger.debug(`本地探测结果<${result.length}>\n${JSON.stringify(result)}`); + for (let i = 0; i < result.length; i++) { + try { + let tagText = result[i]; + if (tagText !== "") { + _setRecommendTag(newData[i], tagText, "GBK02A") + } + } catch (err) { + $.logger.error(err) + } + } + }) +} + +async function removeRecommend() { + let response = null; + try { + const settings_remove_pin = $.data.read("zhihu_settings_recommend_pin", false); + const settings_recommend_stream = $.data.read("zhihu_settings_recommend_stream", false); + const settings_remove_article = $.data.read("zhihu_settings_remove_article", false); + const settings_blocked_users = $.data.read("zhihu_settings_blocked_users", false); + const settings_blocked_keywords = $.data.read("zhihu_settings_blocked_keywords", true); + const settings_check_paid_content = $.data.read("zhihu_settings_check_paid_content", false); + const settings_request_content = $.data.read("zhihu_settings_request_content", "local"); + const user_info = getUserInfo(); + let keywords = $.data.read(keywordBlockKey, "", user_info.id); + keywords = settings_blocked_keywords && !!keywords ? keywords : []; + let customBlockedUsers = $.data.read(blockedUsersKey, "", user_info.id); + customBlockedUsers = settings_blocked_users && !!customBlockedUsers ? customBlockedUsers : {}; + const dataFilter = element => { + const elementStr = JSON.stringify(element); + const isAd = element["card_type"] === "slot_event_card" || element["card_type"] === "slot_video_event_card" || element.hasOwnProperty("ad") || element["brief"] && element["brief"].indexOf("slot_card") >= 0 || element["extra"] && element["extra"]["type"] === "Training"; + const isStream = isAd !== true && elementStr.search(/"(type|style)+"\s?:\s?"(drama|zvideo|Video|BIG_IMAGE)+"/i) >= 0; + const removeStream = isStream && settings_recommend_stream; + const isPin = isStream !== true && elementStr.search(/"(type|style)+"\s?:\s?"pin"/i) >= 0; + const removePin = isPin && settings_remove_pin; + const isArticle = elementStr.search(/"(type|style)+"\s?:\s?"article"/i) >= 0; + const removeArticle = isArticle && settings_remove_article; + let matchKeyword = false; + if (isStream !== true && settings_blocked_keywords) { + for (let i = 0; i < keywords.length; i++) { + if (elementStr.search(keywords[i]) >= 0) { + if ($.isDebug) { + let elementTitle = element["common_card"]["feed_content"]["title"]["panel_text"]; + let elementContent = element["common_card"]["feed_content"]["content"]["panel_text"]; + let actionUrl = ""; + try { + actionUrl = element["common_card"]["feed_content"]["title"]["action"]["intent_url"] + } catch { + } + $.logger.debug(`匹配关键字:\n${keywords[i]}\n标题:\n${elementTitle}\n内容:\n${elementContent}`); + $.notification.debug(scriptName, `关键字:${keywords[i]}`, `${elementTitle}\n${elementContent}`, actionUrl) + } + matchKeyword = true; + break + } + } + } + let isBlockedUser; + try { + isBlockedUser = matchKeyword !== true && settings_blocked_users && customBlockedUsers && element["common_card"]["feed_content"]["source_line"]["elements"][1]["text"]["panel_text"] in customBlockedUsers + } catch { + isBlockedUser = false + } + return !(isAd || removePin || removeArticle || removeStream || matchKeyword || isBlockedUser) + }; + let obj = JSON.parse($.response.body.replace(/(\w+"+\s?):\s?(\d{15,})/g, '$1:"$2"')); + let newData = obj["data"].filter(dataFilter); + if (settings_check_paid_content === true) { + let filteredUrls = []; + for (let i = 0; i < newData.length; i++) { + if (newData[i]) { + try { + let url = newData[i]["common_card"]["feed_content"]["title"]["action"]["intent_url"]; + url = url.replace(/^https:\/\/zhihu\.com\/question\/\d+\/answer\//, "https://www.zhihu.com/appview/v2/answer/"); + filteredUrls.push(url) + } catch { + filteredUrls.push("") + } + } + } + if (filteredUrls.length > 0 && settings_request_content === "cloud") { + await _checkPaidContentByCloud(filteredUrls, newData) + } else if (filteredUrls.length > 0 && settings_request_content === "local") { + await _checkPaidContentByLocal(filteredUrls, newData) + } + } + obj["data"] = newData; + response = {body: JSON.stringify(obj)} + } catch (err) { + $.logger.error(`推荐列表去广告出现异常:${err}`) + } + return response +} + +function removeQuestions() { + let response = null; + try { + const userInfo = getUserInfo(); + let customBlockedUsers = $.data.read(blockedUsersKey, "", userInfo.id); + customBlockedUsers = !!customBlockedUsers ? customBlockedUsers : {}; + let obj = JSON.parse($.response.body); + const settingsBlockedUsers = $.data.read("zhihu_settings_blocked_users", false); + $.logger.debug(`当前黑名单列表: ${JSON.stringify(customBlockedUsers)}`); + let blackUserAnswersId = $.data.read(blackAnswersIdKey, []); + delete obj["ad_info"]; + if (obj["data"]) { + let newData = []; + for (let element of obj.data) { + let blackUserName = ""; + const answerId = element.target.id.toString(); + try { + if ("target" in element) { + blackUserName = element["target"]["author"]["name"] + } + } catch (ex) { + $.logger.error(`获取回答列表用户名出现异常:${ex}`) + } + const isBlackUser = typeof customBlockedUsers[blackUserName] != "undefined"; + const removeBlackUserAnswer = settingsBlockedUsers && isBlackUser; + if ("target" in element) { + element["target"]["visible_only_to_author"] = false; + element["target"]["is_visible"] = true; + element["target"]["is_copyable"] = true + } + if (!removeBlackUserAnswer) { + newData.push(element) + } else if (removeBlackUserAnswer === true && blackUserAnswersId.includes(answerId) === false) { + blackUserAnswersId.push(answerId); + $.notification.debug(`记录黑名单用户${blackUserName}的回答Id:${answerId}`) + } + } + obj.data = newData + } + $.data.write(blackAnswersIdKey, blackUserAnswersId); + const body = JSON.stringify(obj); + $.logger.debug(`修改后的回答列表数据:${body}`); + response = {body: body} + } catch (err) { + $.logger.error(`回答列表去广告出现异常:${err}`) + } + return response +} + +function modifyAnswer() { + let response = null; + try { + let html = $.response.body; + let insertText = ""; + if ((html.indexOf("查看完整内容") >= 0 || html.indexOf("查看全部章节") >= 0) && html.indexOf("paid") >= 0) { + insertText = '
本文为付费内容
' + } else if (html.indexOf("ad-link-card") >= 0 || html.indexOf("xg.zhihu.com") >= 0 || html.indexOf("营销平台") >= 0) { + insertText = '
本文含有营销推广
' + } else if (html.indexOf("mcn-link-card") >= 0) { + insertText = '
本文含有购物推广
' + } else if (Math.floor(Math.random() * 200) === 7) { + insertText = '
本文为免费内容
' + } + if (insertText !== "") { + const matchStr = html.match(/(richText[^<]*>)(.)/)[1]; + const start = html.lastIndexOf(matchStr) + matchStr.length; + response = {body: html.slice(0, start) + insertText + html.slice(start)} + } + } catch (err) { + $.logger.error(`付费内容提醒出现异常:${err}`) + } + return response +} + +function removeComment() { + let response = null; + try { + if (!!$.response.body) { + let obj = JSON.parse($.response.body); + obj["ad_info"] = {}; + if ($.data.read("zhihu_settings_blocked_users", false) === true) { + let user_info = getUserInfo(); + let customBlockedUsers = $.data.read(blockedUsersKey, "", user_info.id); + customBlockedUsers = !!customBlockedUsers ? customBlockedUsers : {}; + let newComments = []; + let blockCommentIdObj = {}; + if (typeof obj.root != "undefined") { + const rootUserName = obj.root.author.name; + const isBlackRootUser = typeof customBlockedUsers[rootUserName] != "undefined"; + if (isBlackRootUser === true) { + obj.root.is_delete = true; + obj.root.can_reply = false; + obj.root.can_like = false; + obj.root.author.name = "黑名单用户"; + obj.root.author.avatar_url = "https://picx.zhimg.com/v2-abed1a8c04700ba7d72b45195223e0ff_xll.jpg" + } + } + if (typeof obj.data != "undefined") { + obj.data.forEach(comment => { + const commentUserName = comment.author.name; + let replyUserName = ""; + if (comment["reply_to_author"] && comment["reply_to_author"].name) { + replyUserName = comment["reply_to_author"].name + } + const isSubComment = replyUserName !== ""; + const isBlackCommentUser = typeof customBlockedUsers[commentUserName] != "undefined"; + const isBlackReplyUser = typeof customBlockedUsers[replyUserName] != "undefined"; + if (isBlackCommentUser === true || isBlackReplyUser === true) { + if (isBlackCommentUser && !isSubComment && $.request.url.indexOf("root_comment") > 0) { + $.notification.debug(`屏蔽黑名单用户“${commentUserName}”的主评论。`) + } else if (!isBlackCommentUser && isSubComment && !isBlackReplyUser && $.request.url.indexOf("child_comment") > 0) { + $.notification.debug(`屏蔽黑名单用户“${commentUserName}”的子评论。`) + } else if (isBlackCommentUser && !isBlackReplyUser && $.request.url.indexOf("child_comment") > 0) { + $.notification.debug(`屏蔽黑名单用户“${commentUserName}”回复“${replyUserName}”的子评论。`) + } else if (isBlackCommentUser && isBlackReplyUser && $.request.url.indexOf("child_comment") > 0) { + $.notification.debug(`屏蔽黑名单用户“${commentUserName}”回复黑名单用户“${replyUserName}”的子评论。`) + } + blockCommentIdObj[comment.id] = commentUserName; + if (isBlackCommentUser) { + comment.is_delete = true; + comment.can_reply = false; + comment.can_like = false; + comment.author.exposed_medal = {}; + comment.author.name = "[黑名单用户]"; + comment.author.avatar_url = "https://picx.zhimg.com/v2-abed1a8c04700ba7d72b45195223e0ff_xll.jpg" + } + if (isBlackReplyUser) { + comment["reply_to_author"].name = "[黑名单用户]"; + comment["reply_to_author"].exposed_medal = {}; + comment["reply_to_author"].avatar_url = "https://picx.zhimg.com/v2-abed1a8c04700ba7d72b45195223e0ff_xll.jpg" + } + } + if (comment.child_comments) { + let newChildComments = []; + comment.child_comments.forEach(childComment => { + const childCommentUserName = childComment.author.name; + const childCommentReplyUserName = typeof childComment["reply_to_author"] != "undefined" ? childComment["reply_to_author"].name : ""; + const isChildBlackCommentUser = typeof customBlockedUsers[childCommentUserName] != "undefined"; + const isChildBlackReplyUser = typeof customBlockedUsers[childCommentReplyUserName] != "undefined"; + if (isChildBlackCommentUser || isChildBlackReplyUser) { + if (isChildBlackCommentUser === true) { + $.notification.debug(`屏蔽黑名单用户“${childCommentUserName}”的子评论。`); + blockCommentIdObj[childComment.id] = childCommentUserName; + childComment.is_delete = true; + childComment.can_reply = false; + childComment.can_like = false; + childComment.author.name = "[黑名单用户]"; + childComment.author.exposed_medal = {}; + childComment.author.avatar_url = "https://picx.zhimg.com/v2-abed1a8c04700ba7d72b45195223e0ff_xll.jpg" + } + if (isChildBlackReplyUser === true) { + $.logger.debug(`修改前的子评论数据:\n${JSON.stringify(childComment)}`); + childComment["reply_to_author"].name = "[黑名单用户]"; + childComment["reply_to_author"].exposed_medal = {}; + childComment["reply_to_author"].avatar_url = "https://picx.zhimg.com/v2-abed1a8c04700ba7d72b45195223e0ff_xll.jpg"; + $.notification.debug(`隐藏“${childCommentUserName}”回复黑名单用户“${childCommentReplyUserName}”的名称与头像。`); + $.logger.debug(`修改后的子评论数据:\n${JSON.stringify(childComment)}`) + } + } + newChildComments.push(childComment) + }); + comment.child_comments = newChildComments + } + newComments.push(comment) + }) + } + obj.data = newComments + } + const body = JSON.stringify(obj); + $.logger.debug(`过滤后的评论数据:\n${body}`); + response = {body: body} + } + } catch (err) { + $.logger.error(`去除评论广告出现异常:${err}`) + } + return response +} + +function removeArticleAd() { + let response = null; + try { + if (!!$.response.body) { + let obj = JSON.parse($.response.body); + obj["ad_info"] = {}; + const body = JSON.stringify(obj); + $.logger.debug(`过滤后的文章数据:\n${body}`); + response = {body: body} + } + } catch (err) { + $.logger.error(`去除文章广告出现异常:${err}`) + } + return response +} + +function removeMarketingMsg() { + let response = null; + try { + let obj = JSON.parse($.response.body); + let newItems = []; + for (let item of obj["data"]) { + if (item["detail_title"] === "官方帐号消息") { + let unread_count = item["unread_count"]; + if (unread_count > 0) { + item["content"]["text"] = "未读消息" + unread_count + "条" + } else { + item["content"]["text"] = "全部消息已读" + } + item["is_read"] = true; + item["unread_count"] = 0; + newItems.push(item) + } else if (item["detail_title"] !== "活动助手") { + newItems.push(item) + } + } + obj["data"] = newItems; + response = {body: JSON.stringify(obj)} + } catch (err) { + $.logger.error(`屏蔽官方营销消息出现异常:${err}`) + } + return response +} + +function removeHotListAds() { + let response = null; + try { + if (!!$.response.body) { + let obj = JSON.parse($.response.body); + if ("data" in obj) { + obj["data"] = obj["data"].filter(e => { + return e["type"] === "hot_list_feed" || e["type"] === "hot_list_feed_video" + }) + } + response = {body: JSON.stringify(obj)} + } + } catch (err) { + $.logger.error(`去除热榜广告出现异常:${err}`) + } + return response +} + +function removeKeywordAds() { + let response = null; + try { + if (!!$.response.body) { + $.logger.debug(`预置关键字返回:${$.response.body}`); + let obj = JSON.parse($.response.body); + if (obj.hasOwnProperty("preset_words") && obj["preset_words"]["words"]) { + obj["preset_words"]["words"] = obj["preset_words"]["words"].filter(element => { + return element["type"] !== "ad" + }); + response = {body: JSON.stringify(obj)} + } + } + } catch (err) { + $.logger.error(`去除预置关键字广告出现异常:${err}`) + } + return response +} + +function removeNextBlackUserAnswer() { + let response = null; + try { + if (!!$.response.body) { + let obj = JSON.parse($.response.body); + const blackUserAnswersId = $.data.read(blackAnswersIdKey, []); + if (blackUserAnswersId.length > 0) { + let newData = []; + obj.data.forEach(element => { + const tag = blackUserAnswersId.includes(element.id.toString()); + if (tag === false) { + element.ad_info = {data: ""}; + newData.push(element) + } else { + $.notification.debug(`屏蔽翻页过程中出现的黑名单用户回答Id:${element.id}`) + } + }); + for (let i = 0; i < newData.length; i++) { + if (newData[i]["extra"] && newData[i]["extra"]["question_index"]) { + newData[i]["extra"]["question_index"] = i + 1 + } + if (newData[i]["strategy_info"]) { + newData[i]["strategy_info"]["global_index"] = i + 1; + newData[i]["strategy_info"]["strategy_index"] = i + 1 + } + } + obj.data = newData + } + response = {body: JSON.stringify(obj)} + } + } catch (err) { + $.logger.error(`屏蔽下翻黑名单用户的回答出现异常:${err}`) + } + return response +} + +function modifyAnswersNextData() { + let response = null; + try { + if (!!$.response.body) { + let obj = JSON.parse($.response.body); + let user_info = getUserInfo(); + let customBlockedUsers = $.data.read(blockedUsersKey, {}, user_info.id); + $.logger.debug(`脚本黑名单用户:\n${JSON.stringify(customBlockedUsers)}`); + let newData = []; + obj.data.data.forEach(element => { + const isAd = element["resource_type"] === "ad" || element["extra"]["recommend_start"] === true || element["next_guide"]["change_type"] === 1 || element["next_guide"]["title"] === "推荐的相关内容"; + if (isAd === true) { + return + } + element["ad_info"] = {data: ""}; + const isBlackUser = typeof customBlockedUsers[element.data.author.name] != "undefined"; + $.logger.debug(`用户${element.data.author.name}是否在黑名单中:${isBlackUser}`); + if ($.data.read("zhihu_settings_blocked_users", false) === false || isBlackUser === false) { + newData.push(element) + } + }); + obj.data.data = newData; + response = {body: JSON.stringify(obj)} + } + } catch (err) { + $.logger.error(`屏蔽回答信息流黑名单用户及广告:${err}`) + } + return response +} + +function modifyAnswersNextBff() { + let response = null; + try { + if (!!$.response.body) { + let obj = JSON.parse($.response.body); + let user_info = getUserInfo(); + let customBlockedUsers = $.data.read(blockedUsersKey, {}, user_info.id); + $.logger.debug(`脚本黑名单用户:\n${JSON.stringify(customBlockedUsers)}`); + let newData = []; + obj.data.forEach(element => { + const isAd = element["origin_data"]["resource_type"] !== "normal"; + if (isAd === true) { + return + } + element["origin_data"]["ad_info"] = {data: ""}; + const authorName = element["origin_data"]["data"]["author"]["name"]; + const isBlackUser = typeof customBlockedUsers[authorName] != "undefined"; + $.logger.debug(`用户${authorName}是否在黑名单中:${isBlackUser}`); + if ($.data.read("zhihu_settings_blocked_users", false) === false || isBlackUser === false) { + newData.push(element) + } + }); + obj.data = newData; + response = {body: JSON.stringify(obj)} + } + } catch (err) { + $.logger.error(`屏蔽回答信息流黑名单用户及广告:${err}`) + } + return response +} + +function modifyAnswersNextRender() { + let response = null; + try { + if (!!$.response.body) { + let obj = JSON.parse($.response.body); + let user_info = getUserInfo(); + let customBlockedUsers = $.data.read(blockedUsersKey, {}, user_info.id); + $.logger.debug(`脚本黑名单用户:\n${JSON.stringify(customBlockedUsers)}`); + let newData = []; + obj.data.forEach(element => { + const isAd = element["ad_info"] && element["ad_info"]["data"] !== "" || element["biz_type_list"] && element["biz_type_list"].length !== 1 || element["biz_type_list"] && element["biz_type_list"][0] !== "answer" || element["type"] === "ad"; + if (isAd === true) { + return + } + const authorName = element["author"]["fullname"]; + const isBlackUser = typeof customBlockedUsers[authorName] != "undefined"; + $.logger.debug(`用户${authorName}是否在黑名单中:${isBlackUser}`); + if ($.data.read("zhihu_settings_blocked_users", false) === false || isBlackUser === false) { + newData.push(element) + } + }); + obj.data = newData; + response = {body: JSON.stringify(obj)} + } + } catch (err) { + $.logger.error(`屏蔽回答信息流黑名单用户及广告:${err}`) + } + return response +} + +function changeUserCredit() { + $.notification.debug("开始修改用户盐值"); + let response = null; + try { + if (!!$.response.body) { + const score = parseInt($.data.read(userCreditScoreKey, 780)); + $.logger.debug(`准备修改用户盐值为${score}`); + let obj = JSON.parse($.response.body); + if (obj["credit_basis"].total_score < score) { + obj["credit_basis"].total_score = score; + $.logger.debug(`已修改用户盐值为:${score}`) + } + response = {body: JSON.stringify(obj)} + } + } catch (err) { + $.logger.error(`修改用户盐值出现异常:${err}`) + } + return response +} + +(async () => { + let response = null; + if ($.isResponse) { + switch (true) { + case/^https:\/\/api\.zhihu\.com\/people\/self$/.test($.request.url): + response = processUserInfo(); + break; + case $.data.read("zhihu_settings_app_conf", false) === true && /^https?:\/\/appcloud2\.zhihu\.com\/v\d+\/config/.test($.request.url): + response = modifyAppConfig(); + break; + case $.data.read("zhihu_settings_app_conf", false) === true && /^https?:\/\/m-cloud\.zhihu\.com\/api\/cloud\/config\/all\?/.test($.request.url): + response = modifyMCloudConfig(); + break; + case/^https?:\/\/api\.zhihu\.com\/user-credit\/basis/.test($.request.url): + response = changeUserCredit(); + break; + case/^https:\/\/api\.zhihu\.com\/topstory\/recommend/.test($.request.url): + response = await removeRecommend(); + break; + case/^https?:\/\/api\.zhihu\.com\/(v4\/)?questions\/\d+/.test($.request.url): + response = removeQuestions(); + break; + case/^https?:\/\/api\.zhihu\.com\/next-data\?/.test($.request.url): + response = modifyAnswersNextData(); + break; + case/^https?:\/\/api\.zhihu\.com\/next-bff\?/.test($.request.url): + response = modifyAnswersNextBff(); + break; + case/^https?:\/\/api\.zhihu\.com\/next-render\?/.test($.request.url): + response = modifyAnswersNextRender(); + break; + case $.data.read("zhihu_settings_sys_msg", true) !== false && /^https?:\/\/api\.zhihu\.com\/notifications\/v3\/message/.test($.request.url): + response = removeMarketingMsg(); + break; + case/^https?:\/\/api\.zhihu\.com\/comment_v5\/(answers|pins|comments?|articles)\/\d+\/(root|child)_comment/.test($.request.url): + response = removeComment(); + break; + case/^https?:\/\/www\.zhihu\.com\/api\/v\d\/articles\/\d+\/recommendation\?/.test($.request.url): + response = removeArticleAd(); + break; + case/^https?:\/\/www\.zhihu\.com\/api\/v4\/comment_v5\/answers\/\d+\/abstract_comment\?/.test($.request.url): + response = removeComment(); + break; + case $.data.read("zhihu_settings_answer_tip", true) === true && /^https?:\/\/www\.zhihu\.com\/appview\/v2\/answer\/.*(entry=(?!(preload-topstory|preload-search|preload-subscription)))?/.test($.request.url): + response = modifyAnswer(); + break; + case $.data.read("zhihu_settings_blocked_users", false) !== false && /^https?:\/\/api\.zhihu\.com\/next\?/.test($.request.url): + response = removeNextBlackUserAnswer(); + break; + case $.data.read("zhihu_settings_blocked_users", true) === true && /^https?:\/\/api\.zhihu\.com\/people\/((?!self).)*$/.test($.request.url): + response = autoInsertBlackList(); + break; + case/^https?:\/\/api\.zhihu\.com\/moments_v3\?/.test($.request.url): + response = removeMoments(); + break; + case $.data.read("zhihu_settings_hot_list", true) === true && /^https?:\/\/api\.zhihu\.com\/topstory\/hot-lists(\?|\/)/.test($.request.url): + response = removeHotListAds(); + break; + case $.data.read("zhihu_settings_preset_words", true) === true && /^https?:\/\/api\.zhihu\.com\/search\/preset_words\?/.test($.request.url): + response = removeKeywordAds(); + break; + case $.data.read("zhihu_settings_blocked_users", false) !== false && /^https?:\/\/api\.zhihu\.com\/settings\/blocked_users/.test($.request.url): + manageBlackUser(); + break; + default: + $.logger.debug("没有匹配到任何请求,请确认配置正确。"); + break + } + } else if ($.isRequest) { + if ($.data.read("zhihu_settings_blocked_keywords", false) !== false && /^https?:\/\/api\.zhihu\.com\/feed-root\/block/.test($.request.url) === true) { + response = unlockBlockedKeywords(response) + } + } else { + $.data.del(currentUserInfoKey); + $.data.del(blockedUsersKey); + $.data.del(keywordBlockKey); + $.notification.post("哲也同学数据清理完毕") + } + if (response) { + $.done(response) + } else { + $.done() + } +})(); + +function MagicJS(scriptName = "MagicJS", logLevel = "INFO") { + const MagicEnvironment = () => { + const isLoon = typeof $loon !== "undefined"; + const isQuanX = typeof $task !== "undefined"; + const isNode = typeof module !== "undefined"; + const isSurge = typeof $httpClient !== "undefined" && !isLoon; + const isStorm = typeof $storm !== "undefined"; + const isStash = typeof $environment !== "undefined" && typeof $environment["stash-build"] !== "undefined"; + const isSurgeLike = isSurge || isLoon || isStorm || isStash; + const isScriptable = typeof importModule !== "undefined"; + return { + isLoon: isLoon, + isQuanX: isQuanX, + isNode: isNode, + isSurge: isSurge, + isStorm: isStorm, + isStash: isStash, + isSurgeLike: isSurgeLike, + isScriptable: isScriptable, + get name() { + if (isLoon) { + return "Loon" + } else if (isQuanX) { + return "QuantumultX" + } else if (isNode) { + return "NodeJS" + } else if (isSurge) { + return "Surge" + } else if (isScriptable) { + return "Scriptable" + } else { + return "unknown" + } + }, + get build() { + if (isSurge) { + return $environment["surge-build"] + } else if (isStash) { + return $environment["stash-build"] + } else if (isStorm) { + return $storm.buildVersion + } + }, + get language() { + if (isSurge || isStash) { + return $environment["language"] + } + }, + get version() { + if (isSurge) { + return $environment["surge-version"] + } else if (isStash) { + return $environment["stash-version"] + } else if (isStorm) { + return $storm.appVersion + } else if (isNode) { + return process.version + } + }, + get system() { + if (isSurge) { + return $environment["system"] + } else if (isNode) { + return process.platform + } + }, + get systemVersion() { + if (isStorm) { + return $storm.systemVersion + } + }, + get deviceName() { + if (isStorm) { + return $storm.deviceName + } + } + } + }; + const MagicLogger = (scriptName, logLevel = "INFO") => { + let _level = logLevel; + const logLevels = {SNIFFER: 6, DEBUG: 5, INFO: 4, NOTIFY: 3, WARNING: 2, ERROR: 1, CRITICAL: 0, NONE: -1}; + const logEmoji = { + SNIFFER: "", + DEBUG: "", + INFO: "", + NOTIFY: "", + WARNING: "❗ ", + ERROR: "❌ ", + CRITICAL: "❌ ", + NONE: "" + }; + const _log = (msg, level = "INFO") => { + if (!(logLevels[_level] < logLevels[level.toUpperCase()])) console.log(`[${level}] [${scriptName}]\n${logEmoji[level.toUpperCase()]}${msg}\n`) + }; + const setLevel = logLevel => { + _level = logLevel + }; + return { + getLevel: () => { + return _level + }, setLevel: setLevel, sniffer: msg => { + _log(msg, "SNIFFER") + }, debug: msg => { + _log(msg, "DEBUG") + }, info: msg => { + _log(msg, "INFO") + }, notify: msg => { + _log(msg, "NOTIFY") + }, warning: msg => { + _log(msg, "WARNING") + }, error: msg => { + _log(msg, "ERROR") + }, retry: msg => { + _log(msg, "RETRY") + } + } + }; + return new class { + constructor(scriptName, logLevel) { + this._startTime = Date.now(); + this.version = "3.0.0"; + this.scriptName = scriptName; + this.env = MagicEnvironment(); + this.logger = MagicLogger(scriptName, logLevel); + this.http = typeof MagicHttp === "function" ? MagicHttp(this.env, this.logger) : undefined; + this.data = typeof MagicData === "function" ? MagicData(this.env, this.logger) : undefined; + this.notification = typeof MagicNotification === "function" ? MagicNotification(this.scriptName, this.env, this.logger, this.http) : undefined; + this.utils = typeof MagicUtils === "function" ? MagicUtils(this.env, this.logger) : undefined; + this.qinglong = typeof MagicQingLong === "function" ? MagicQingLong(this.env, this.data, this.logger) : undefined; + if (typeof this.data !== "undefined") { + let magicLoglevel = this.data.read("magic_loglevel"); + const barkUrl = this.data.read("magic_bark_url"); + if (magicLoglevel) { + this.logger.setLevel(magicLoglevel.toUpperCase()) + } + if (barkUrl) { + this.notification.setBark(barkUrl) + } + } + } + + get isRequest() { + return typeof $request !== "undefined" && typeof $response === "undefined" + } + + get isResponse() { + return typeof $response !== "undefined" + } + + get isDebug() { + return this.logger.level === "DEBUG" + } + + get request() { + return typeof $request !== "undefined" ? $request : undefined + } + + get response() { + if (typeof $response !== "undefined") { + if ($response.hasOwnProperty("status")) $response["statusCode"] = $response["status"]; + if ($response.hasOwnProperty("statusCode")) $response["status"] = $response["statusCode"]; + return $response + } else { + return undefined + } + } + + done = (value = {}) => { + this._endTime = Date.now(); + let span = (this._endTime - this._startTime) / 1e3; + this.logger.info(`SCRIPT COMPLETED: ${span} S.`); + if (typeof $done !== "undefined") { + $done(value) + } + } + }(scriptName, logLevel) +} + +function MagicNotification(scriptName, env, logger, http) { + let _barkUrl = null; + let _barkKey = null; + const setBark = url => { + try { + let _url = url.replace(/\/+$/g, ""); + _barkUrl = `${/^https?:\/\/([^/]*)/.exec(_url)[0]}/push`; + _barkKey = /\/([^\/]+)\/?$/.exec(_url)[1] + } catch (ex) { + logger.error(`Bark url error: ${ex}.`) + } + }; + + function post(title = scriptName, subTitle = "", body = "", opts = "") { + const _adaptOpts = _opts => { + try { + let newOpts = {}; + if (typeof _opts === "string") { + if (env.isLoon) newOpts = {openUrl: _opts}; else if (env.isQuanX) newOpts = {"open-url": _opts}; else if (env.isSurge) newOpts = {url: _opts} + } else if (typeof _opts === "object") { + if (env.isLoon) { + newOpts["openUrl"] = !!_opts["open-url"] ? _opts["open-url"] : ""; + newOpts["mediaUrl"] = !!_opts["media-url"] ? _opts["media-url"] : "" + } else if (env.isQuanX) { + newOpts = !!_opts["open-url"] || !!_opts["media-url"] ? _opts : {} + } else if (env.isSurge) { + let openUrl = _opts["open-url"] || _opts["openUrl"]; + newOpts = openUrl ? {url: openUrl} : {} + } + } + return newOpts + } catch (err) { + logger.error(`通知选项转换失败${err}`) + } + return _opts + }; + opts = _adaptOpts(opts); + if (arguments.length === 1) { + title = scriptName; + subTitle = "", body = arguments[0] + } + logger.notify(`title:${title}\nsubTitle:${subTitle}\nbody:${body}\noptions:${typeof opts === "object" ? JSON.stringify(opts) : opts}`); + if (env.isSurge) { + $notification.post(title, subTitle, body, opts) + } else if (env.isLoon) { + if (!!opts) $notification.post(title, subTitle, body, opts); else $notification.post(title, subTitle, body) + } else if (env.isQuanX) { + $notify(title, subTitle, body, opts) + } + if (_barkUrl && _barkKey) { + bark(title, subTitle, body) + } + } + + function debug(title = scriptName, subTitle = "", body = "", opts = "") { + if (logger.getLevel() === "DEBUG") { + if (arguments.length === 1) { + title = scriptName; + subTitle = ""; + body = arguments[0] + } + this.post(title, subTitle, body, opts) + } + } + + function bark(title = scriptName, subTitle = "", body = "", opts = "") { + if (typeof http === "undefined" || typeof http.post === "undefined") { + throw "Bark notification needs to import MagicHttp module." + } + let options = { + url: _barkUrl, + headers: {"content-type": "application/json; charset=utf-8"}, + body: {title: title, body: subTitle ? `${subTitle}\n${body}` : body, device_key: _barkKey} + }; + http.post(options).catch(ex => { + logger.error(`Bark notify error: ${ex}`) + }) + } + + return {post: post, debug: debug, bark: bark, setBark: setBark} +} + +function MagicData(env, logger) { + let node = {fs: undefined, data: {}}; + if (env.isNode) { + node.fs = require("fs"); + try { + node.fs.accessSync("./magic.json", node.fs.constants.R_OK | node.fs.constants.W_OK) + } catch (err) { + node.fs.writeFileSync("./magic.json", "{}", {encoding: "utf8"}) + } + node.data = require("./magic.json") + } + const defaultValueComparator = (oldVal, newVal) => { + if (typeof newVal === "object") { + return false + } else { + return oldVal === newVal + } + }; + const _typeConvertor = val => { + if (val === "true") { + return true + } else if (val === "false") { + return false + } else if (typeof val === "undefined") { + return null + } else { + return val + } + }; + const _valConvertor = (val, default_, session, read_no_session) => { + if (session) { + try { + if (typeof val === "string") val = JSON.parse(val); + if (val["magic_session"] === true) { + val = val[session] + } else { + val = null + } + } catch { + val = null + } + } + if (typeof val === "string" && val !== "null") { + try { + val = JSON.parse(val) + } catch { + } + } + if (read_no_session === false && !!val && val["magic_session"] === true) { + val = null + } + if ((val === null || typeof val === "undefined") && default_ !== null && typeof default_ !== "undefined") { + val = default_ + } + val = _typeConvertor(val); + return val + }; + const convertToObject = obj => { + if (typeof obj === "string") { + let data = {}; + try { + data = JSON.parse(obj); + const type = typeof data; + if (type !== "object" || data instanceof Array || type === "bool" || data === null) { + data = {} + } + } catch { + } + return data + } else if (obj instanceof Array || obj === null || typeof obj === "undefined" || obj !== obj || typeof obj === "boolean") { + return {} + } else { + return obj + } + }; + const readForNode = (key, default_ = null, session = "", read_no_session = false, externalData = null) => { + let data = externalData || node.data; + if (!!data && typeof data[key] !== "undefined" && data[key] !== null) { + val = data[key] + } else { + val = !!session ? {} : null + } + val = _valConvertor(val, default_, session, read_no_session); + return val + }; + const read = (key, default_ = null, session = "", read_no_session = false, externalData = null) => { + let val = ""; + if (externalData || env.isNode) { + val = readForNode(key, default_, session, read_no_session, externalData) + } else { + if (env.isSurgeLike) { + val = $persistentStore.read(key) + } else if (env.isQuanX) { + val = $prefs.valueForKey(key) + } + val = _valConvertor(val, default_, session, read_no_session) + } + logger.debug(`READ DATA [${key}]${!!session ? `[${session}]` : ""} <${typeof val}>\n${JSON.stringify(val)}`); + return val + }; + const writeForNode = (key, val, session = "", externalData = null) => { + let data = externalData || node.data; + data = convertToObject(data); + if (!!session) { + let obj = convertToObject(data[key]); + obj["magic_session"] = true; + obj[session] = val; + data[key] = obj + } else { + data[key] = val + } + if (externalData !== null) { + externalData = data + } + return data + }; + const write = (key, val, session = "", externalData = null) => { + if (typeof val === "undefined" || val !== val) { + return false + } + if (!env.isNode && (typeof val === "boolean" || typeof val === "number")) { + val = String(val) + } + let data = ""; + if (externalData || env.isNode) { + data = writeForNode(key, val, session, externalData) + } else { + if (!session) { + data = val + } else { + if (env.isSurgeLike) { + data = !!$persistentStore.read(key) ? $persistentStore.read(key) : data + } else if (env.isQuanX) { + data = !!$prefs.valueForKey(key) ? $prefs.valueForKey(key) : data + } + data = convertToObject(data); + data["magic_session"] = true; + data[session] = val + } + } + if (!!data && typeof data === "object") { + data = JSON.stringify(data, null, 4) + } + logger.debug(`WRITE DATA [${key}]${session ? `[${session}]` : ""} <${typeof val}>\n${JSON.stringify(val)}`); + if (!externalData) { + if (env.isSurgeLike) { + return $persistentStore.write(data, key) + } else if (env.isQuanX) { + return $prefs.setValueForKey(data, key) + } else if (env.isNode) { + try { + node.fs.writeFileSync("./magic.json", data); + return true + } catch (err) { + logger.error(err); + return false + } + } + } + return true + }; + const update = (key, val, session, comparator = defaultValueComparator, externalData = null) => { + val = _typeConvertor(val); + const oldValue = read(key, null, session, false, externalData); + if (comparator(oldValue, val) === true) { + return false + } else { + const result = write(key, val, session, externalData); + let newVal = read(key, null, session, false, externalData); + if (comparator === defaultValueComparator && typeof newVal === "object") { + return result + } + return comparator(val, newVal) + } + }; + const delForNode = (key, session, externalData) => { + let data = externalData || node.data; + data = convertToObject(data); + if (!!session) { + obj = convertToObject(data[key]); + delete obj[session]; + data[key] = obj + } else { + delete data[key] + } + if (!!externalData) { + externalData = data + } + return data + }; + const del = (key, session = "", externalData = null) => { + let data = {}; + if (externalData || env.isNode) { + data = delForNode(key, session, externalData); + if (!externalData) { + node.fs.writeFileSync("./magic.json", JSON.stringify(data, null, 4)) + } else { + externalData = data + } + } else { + if (!session) { + if (env.isStorm) { + return $persistentStore.remove(key) + } else if (env.isSurgeLike) { + return $persistentStore.write(null, key) + } else if (env.isQuanX) { + return $prefs.removeValueForKey(key) + } + } else { + if (env.isSurgeLike) { + data = $persistentStore.read(key) + } else if (env.isQuanX) { + data = $prefs.valueForKey(key) + } + data = convertToObject(data); + delete data[session]; + const json = JSON.stringify(data, null, 4); + write(key, json) + } + } + logger.debug(`DELETE KEY [${key}]${!!session ? `[${session}]` : ""}`) + }; + const allSessionNames = (key, externalData = null) => { + let _sessions = []; + let data = read(key, null, null, true, externalData); + data = convertToObject(data); + if (data["magic_session"] !== true) { + _sessions = [] + } else { + _sessions = Object.keys(data).filter(key => key !== "magic_session") + } + logger.debug(`READ ALL SESSIONS [${key}] <${typeof _sessions}>\n${JSON.stringify(_sessions, null, 4)}`); + return _sessions + }; + const allSessions = (key, externalData = null) => { + let _sessions = {}; + let data = read(key, null, null, true, externalData); + data = convertToObject(data); + if (data["magic_session"] === true) { + _sessions = {...data}; + delete _sessions["magic_session"] + } + logger.debug(`READ ALL SESSIONS [${key}] <${typeof _sessions}>\n${JSON.stringify(_sessions, null, 4)}`); + return _sessions + }; + return { + read: read, + write: write, + del: del, + update: update, + allSessions: allSessions, + allSessionNames: allSessionNames, + defaultValueComparator: defaultValueComparator, + convertToObject: convertToObject + } +} + +function MagicHttp(env, logger) { + let axiosInstance; + if (env.isNode) { + const axios = require("axios"); + axiosInstance = axios.create() + } + + class InterceptorManager { + constructor(isRequest = true) { + this.handlers = []; + this.isRequest = isRequest + } + + use(fulfilled, rejected, options) { + if (typeof fulfilled === "function") { + logger.debug(`Register fulfilled ${fulfilled.name}`) + } + if (typeof rejected === "function") { + logger.debug(`Register rejected ${rejected.name}`) + } + this.handlers.push({ + fulfilled: fulfilled, + rejected: rejected, + synchronous: options && typeof options.synchronous === "boolean" ? options.synchronous : false, + runWhen: options ? options.runWhen : null + }); + return this.handlers.length - 1 + } + + eject(id) { + if (this.handlers[id]) { + this.handlers[id] = null + } + } + + forEach(fn) { + this.handlers.forEach(element => { + if (element !== null) { + fn(element) + } + }) + } + } + + function paramsToQueryString(config) { + let _config = {...config}; + if (!!_config.params) { + if (!env.isNode) { + let qs = Object.keys(_config.params).map(key => { + const encodeKey = encodeURIComponent(key); + _config.url = _config.url.replace(new RegExp(`${key}=[^&]*`, "ig"), ""); + _config.url = _config.url.replace(new RegExp(`${encodeKey}=[^&]*`, "ig"), ""); + return `${encodeKey}=${encodeURIComponent(_config.params[key])}` + }).join("&"); + if (_config.url.indexOf("?") < 0) _config.url += "?"; + if (!/(&|\?)$/g.test(_config.url)) { + _config.url += "&" + } + _config.url += qs; + delete _config.params; + logger.debug(`Params to QueryString: ${_config.url}`) + } + } + return _config + } + + const mergeConfig = (method, configOrUrl) => { + let config = typeof configOrUrl === "object" ? {headers: {}, ...configOrUrl} : {url: configOrUrl, headers: {}}; + if (!config.method) { + config["method"] = method + } + config = paramsToQueryString(config); + if (config["rewrite"] === true) { + if (env.isSurge) { + config.headers["X-Surge-Skip-Scripting"] = false; + delete config["rewrite"] + } else if (env.isQuanX) { + config["hints"] = false; + delete config["rewrite"] + } + } + if (env.isSurgeLike) { + const contentType = config.headers["content-type"] || config.headers["Content-Type"]; + if (config["method"] !== "GET" && contentType && contentType.indexOf("application/json") >= 0 && config.body instanceof Array) { + config.body = JSON.stringify(config.body); + logger.debug(`Convert Array object to String: ${config.body}`) + } + } else if (env.isQuanX) { + if (config.hasOwnProperty("body") && typeof config["body"] !== "string") config["body"] = JSON.stringify(config["body"]); + config["method"] = method + } else if (env.isNode) { + if (method === "POST" || method === "PUT" || method === "PATCH" || method === "DELETE") { + config.data = config.data || config.body + } else if (method === "GET") { + config.params = config.params || config.body + } + delete config.body + } + return config + }; + const modifyResponse = (resp, config = null) => { + if (resp) { + let _resp = { + ...resp, + config: resp.config || config, + status: resp.statusCode || resp.status, + body: resp.body || resp.data, + headers: resp.headers || resp.header + }; + if (typeof _resp.body === "string") { + try { + _resp.body = JSON.parse(_resp.body) + } catch { + } + } + delete _resp.data; + return _resp + } else { + return resp + } + }; + const convertHeadersToLowerCase = headers => { + return Object.keys(headers).reduce((acc, key) => { + acc[key.toLowerCase()] = headers[key]; + return acc + }, {}) + }; + const convertHeadersToCamelCase = headers => { + return Object.keys(headers).reduce((acc, key) => { + const newKey = key.split("-").map(word => word[0].toUpperCase() + word.slice(1)).join("-"); + acc[newKey] = headers[key]; + return acc + }, {}) + }; + const raiseExceptionByStatusCode = (resp, config = null) => { + if (!!resp && resp.status >= 400) { + logger.debug(`Raise exception when status code is ${resp.status}`); + return { + name: "RequestException", + message: `Request failed with status code ${resp.status}`, + config: config || resp.config, + response: resp + } + } + }; + const interceptors = {request: new InterceptorManager, response: new InterceptorManager(false)}; + let requestInterceptorChain = []; + let responseInterceptorChain = []; + let synchronousRequestInterceptors = true; + + function interceptConfig(config) { + config = paramsToQueryString(config); + logger.debug(`HTTP ${config["method"].toUpperCase()}:\n${JSON.stringify(config)}`); + return config + } + + function interceptResponse(resp) { + try { + resp = !!resp ? modifyResponse(resp) : resp; + logger.sniffer(`HTTP ${resp.config["method"].toUpperCase()}:\n${JSON.stringify(resp.config)}\nSTATUS CODE:\n${resp.status}\nRESPONSE:\n${typeof resp.body === "object" ? JSON.stringify(resp.body) : resp.body}`); + const err = raiseExceptionByStatusCode(resp); + if (!!err) { + return Promise.reject(err) + } + return resp + } catch (err) { + logger.error(err); + return resp + } + } + + const registerInterceptors = config => { + try { + requestInterceptorChain = []; + responseInterceptorChain = []; + interceptors.request.forEach(interceptor => { + if (typeof interceptor.runWhen === "function" && interceptor.runWhen(config) === false) { + return + } + synchronousRequestInterceptors = synchronousRequestInterceptors && interceptor.synchronous; + requestInterceptorChain.unshift(interceptor.fulfilled, interceptor.rejected) + }); + interceptors.response.forEach(interceptor => { + responseInterceptorChain.push(interceptor.fulfilled, interceptor.rejected) + }) + } catch (err) { + logger.error(`Failed to register interceptors: ${err}.`) + } + }; + const request = (method, config) => { + let dispatchRequest; + const _method = method.toUpperCase(); + config = mergeConfig(_method, config); + if (env.isNode) { + dispatchRequest = axiosInstance + } else { + if (env.isSurgeLike) { + dispatchRequest = config => { + return new Promise((resolve, reject) => { + $httpClient[method.toLowerCase()](config, (err, resp, body) => { + if (err) { + let newErr = { + name: err.name || err, + message: err.message || err, + stack: err.stack || err, + config: config, + response: modifyResponse(resp) + }; + reject(newErr) + } else { + resp.config = config; + resp.body = body; + resolve(resp) + } + }) + }) + } + } else { + dispatchRequest = config => { + return new Promise((resolve, reject) => { + $task.fetch(config).then(resp => { + resp = modifyResponse(resp, config); + const err = raiseExceptionByStatusCode(resp, config); + if (err) { + return Promise.reject(err) + } + resolve(resp) + }).catch(err => { + let newErr = { + name: err.message || err.error, + message: err.message || err.error, + stack: err.error, + config: config, + response: !!err.response ? modifyResponse(err.response) : null + }; + reject(newErr) + }) + }) + } + } + } + let promise; + registerInterceptors(config); + const defaultRequestInterceptors = [interceptConfig, undefined]; + const defaultResponseInterceptors = [interceptResponse, undefined]; + if (!synchronousRequestInterceptors) { + logger.debug("Interceptors are executed in asynchronous mode"); + let chain = [dispatchRequest, undefined]; + Array.prototype.unshift.apply(chain, defaultRequestInterceptors); + Array.prototype.unshift.apply(chain, requestInterceptorChain); + chain = chain.concat(defaultResponseInterceptors); + chain = chain.concat(responseInterceptorChain); + promise = Promise.resolve(config); + while (chain.length) { + try { + let onFulfilled = chain.shift(); + let onRejected = chain.shift(); + if (!env.isNode && config["timeout"] && onFulfilled === dispatchRequest) { + onFulfilled = requestTimeout + } + if (typeof onFulfilled === "function") { + logger.debug(`Executing request fulfilled ${onFulfilled.name}`) + } + if (typeof onRejected === "function") { + logger.debug(`Executing request rejected ${onRejected.name}`) + } + promise = promise.then(onFulfilled, onRejected) + } catch (err) { + logger.error(`request exception: ${err}`) + } + } + return promise + } else { + logger.debug("Interceptors are executed in synchronous mode"); + Array.prototype.unshift.apply(requestInterceptorChain, defaultRequestInterceptors); + requestInterceptorChain = requestInterceptorChain.concat([interceptConfig, undefined]); + while (requestInterceptorChain.length) { + let onFulfilled = requestInterceptorChain.shift(); + let onRejected = requestInterceptorChain.shift(); + try { + if (typeof onFulfilled === "function") { + logger.debug(`Executing request fulfilled ${onFulfilled.name}`) + } + config = onFulfilled(config) + } catch (error) { + if (typeof onRejected === "function") { + logger.debug(`Executing request rejected ${onRejected.name}`) + } + onRejected(error); + break + } + } + try { + if (!env.isNode && config["timeout"]) { + promise = requestTimeout(config) + } else { + promise = dispatchRequest(config) + } + } catch (err) { + return Promise.reject(err) + } + Array.prototype.unshift.apply(responseInterceptorChain, defaultResponseInterceptors); + while (responseInterceptorChain.length) { + promise = promise.then(responseInterceptorChain.shift(), responseInterceptorChain.shift()) + } + return promise + } + + function requestTimeout(config) { + try { + const timer = new Promise((_, reject) => { + setTimeout(() => { + let err = {message: `timeout of ${config["timeout"]}ms exceeded.`, config: config}; + reject(err) + }, config["timeout"]) + }); + return Promise.race([dispatchRequest(config), timer]) + } catch (err) { + logger.error(`Request Timeout exception: ${err}.`) + } + } + }; + return { + request: request, + interceptors: interceptors, + convertHeadersToLowerCase: convertHeadersToLowerCase, + convertHeadersToCamelCase: convertHeadersToCamelCase, + modifyResponse: modifyResponse, + get: configOrUrl => { + return request("GET", configOrUrl) + }, + post: configOrUrl => { + return request("POST", configOrUrl) + }, + put: configOrUrl => { + return request("PUT", configOrUrl) + }, + patch: configOrUrl => { + return request("PATCH", configOrUrl) + }, + delete: configOrUrl => { + return request("DELETE", configOrUrl) + }, + head: configOrUrl => { + return request("HEAD", configOrUrl) + }, + options: configOrUrl => { + return request("OPTIONS", configOrUrl) + } + } +} \ No newline at end of file diff --git a/Scripts/AdBlock/Zhihu/Zhihu.min.js b/Scripts/AdBlock/Zhihu/Zhihu.min.js index 8fa1c48..05fbd92 100644 --- a/Scripts/AdBlock/Zhihu/Zhihu.min.js +++ b/Scripts/AdBlock/Zhihu/Zhihu.min.js @@ -1 +1 @@ -const scriptName="哲也同学";const blockedUsersKey="zhihu_blocked_users";const currentUserInfoKey="zhihu_current_userinfo";const keywordBlockKey="zhihu_keyword_block";const blackAnswersIdKey="zhihu_black_answers";const userCreditScoreKey="zhihu_credit_score";const zheyeServerKey="zheye_server_url";const defaultAnswerBlockedUsers=["会员推荐","盐选推荐"];const keywordMaxCount=1e3;const $=MagicJS(scriptName,"INFO");function getUserInfo(){let t={id:"default",is_vip:false};try{let e=$.data.read(currentUserInfoKey);if(typeof e==="string")e=JSON.parse(e);if(!!e&&e.hasOwnProperty("id")){return e}else{return t}}catch(e){$.logger.error(`获取用户信息出现异常:${e}`);return t}}function modifyAppConfig(){let t=null;try{if(!!$.response.body){let e=JSON.parse($.response.body);e["config"]["homepage_feed_tab"]["tab_infos"]=e["config"]["homepage_feed_tab"]["tab_infos"].filter(e=>{if(e["tab_type"]==="activity_tab"){e["end_time"]=(new Date-12e4).toString().slice(0,10);return true}else{return false}});e["config"]["zvideo_max_number"]=1;e["config"]["is_show_followguide_alert"]=false;delete e["config"]["hp_channel_tab"];if(e["config"]["zombie_conf"]){e["config"]["zombie_conf"]["zombieEnable"]=false}if(e["config"]["gray_mode"]){e["config"]["gray_mode"]["enable"]=false;e["config"]["gray_mode"]["start_time"]="4092566400";e["config"]["gray_mode"]["end_time"]="4092566400"}if(e["config"].hasOwnProperty("zhcnh_thread_sync")){$.logger.debug(JSON.stringify(e["config"]["zhcnh_thread_sync"]));e["config"]["zhcnh_thread_sync"]["LocalDNSSetHostWhiteList"]=[];e["config"]["zhcnh_thread_sync"]["isOpenLocalDNS"]="0";e["config"]["zhcnh_thread_sync"]["ZHBackUpIP_Switch_Open"]="0";e["config"]["zhcnh_thread_sync"]["dns_ip_detector_operation_lock"]="1";e["config"]["zhcnh_thread_sync"]["ZHHTTPSessionManager_setupZHHTTPHeaderField"]="1"}t={body:JSON.stringify(e)}}}catch(e){$.logger.error(`优化软件配置出现异常:${e}`)}return t}function modifyMCloudConfig(){let t=null;try{if(!!$.response.body){let e=JSON.parse($.response.body);if(e.data&&e.data["configs"]){e.data["configs"].forEach(e=>{if(e["configKey"]==="feed_gray_theme"){e["configValue"].start_time="1669824000";e["configValue"].end_time="1669824001";e.status=false}})}const r=JSON.stringify(e);$.logger.debug(r);t={body:r}}}catch(e){$.logger.error(`优化软件配置出现异常:${e}`)}return t}function unlockBlockedKeywords(){let i=null;try{const s=getUserInfo();if($.request.method==="GET"){let e=$.data.read(keywordBlockKey,null,s.id);if(!e){e=[]}let t={"Cache-Control":"no-cache, no-store, must-revalidate, private, max-age=0",Connection:"keep-alive","Content-Type":"application/json;charset=utf-8",Pragma:"no-cache","Referrer-Policy":"no-referrer-when-downgrade",Server:"CLOUD ELB 1.0.0",Vary:"Accept-Encoding","X-Cache-Lookup":"Cache Miss","x-cdn-provider":"tencent"};let r=JSON.stringify({success:true,is_vip:true,kw_min_length:2,kw_max_length:100,kw_max_count:keywordMaxCount,data:e});if($.env.isQuanX){i={body:r,headers:t,status:"HTTP/1.1 200 OK"}}else{i={response:{body:r,headers:t,status:200}}}$.logger.debug(`获取本地脚本屏蔽关键词:\n${e.join("、")}`)}else if($.request.method==="POST"){if(!!$.request.body){let t={"Cache-Control":"no-cache, no-store, must-revalidate, private, max-age=0",Connection:"keep-alive","Content-Type":"application/json;charset=utf-8",Pragma:"no-cache","Referrer-Policy":"no-referrer-when-downgrade",Server:"CLOUD ELB 1.0.0",Vary:"Accept-Encoding","X-Cache-Lookup":"Cache Miss","x-cdn-provider":"tencent"};let r=decodeURIComponent($.request.body).match(/keyword=(.*)/)[1];let n=$.data.read(keywordBlockKey,null,s.id);if(!n){n=[]}let o=false;for(let e=0;e{return e!==t});$.data.write(keywordBlockKey,e,s.id);let r={"Cache-Control":"no-cache, no-store, must-revalidate, private, max-age=0",Connection:"keep-alive","Content-Type":"application/json;charset=utf-8",Pragma:"no-cache","Referrer-Policy":"no-referrer-when-downgrade",Server:"CLOUD ELB 1.0.0",Vary:"Accept-Encoding","X-Cache-Lookup":"Cache Miss","x-cdn-provider":"tencent"};let n=JSON.stringify({success:true});if($.env.isQuanX){i={body:n,headers:r,status:"HTTP/1.1 200 OK"}}else{i={response:{body:n,headers:r,status:200}}}$.logger.debug(`删除本地脚本屏蔽关键词:“${t}”`)}}catch(e){$.logger.debug(`关键词屏蔽操作出现异常:${e}`)}return i}function processUserInfo(){let t=null;try{let e=JSON.parse($.response.body);$.data.write(blackAnswersIdKey,[]);$.logger.debug(`用户登录用户信息,接口响应:${$.response.body}`);if(e&&e["id"]&&e.hasOwnProperty("vip_info")&&e["vip_info"].hasOwnProperty("is_vip")){const r={id:e["id"],is_vip:e["vip_info"]["is_vip"]?e["vip_info"]["is_vip"]!==undefined:false};$.logger.debug(`当前用户id:${e["id"]},是否为VIP:${e["vip_info"]["is_vip"]}`);$.data.write(currentUserInfoKey,r);if($.data.read("zhihu_settings_fake_vip")!==false&&e["vip_info"]["is_vip"]===false){e["vip_info"]["is_vip"]=true;e["vip_info"]["vip_type"]=2;e["vip_info"]["vip_icon"]={url:"https://picx.zhimg.com/v2-aa8a1823abfc46f14136f01d55224925.jpg?source=88ceefae",night_mode_url:"https://picx.zhimg.com/v2-aa8a1823abfc46f14136f01d55224925.jpg?source=88ceefae"};e["vip_info"]["vip_icon_v2"]={url:"https://picx.zhimg.com/v2-aa8a1823abfc46f14136f01d55224925.jpg?source=88ceefae",night_mode_url:"https://picx.zhimg.com/v2-aa8a1823abfc46f14136f01d55224925.jpg?source=88ceefae"};e["vip_info"]["entrance"]={icon:{url:"https://pic3.zhimg.com/v2-5b7012c8c22fd520f5677305e1e551bf.png",night_mode_url:"https://pic4.zhimg.com/v2-e51e3252d7a2cb016a70879defd5da0b.png"},title:"盐选会员 为你严选好内容",expires_day:"2099-12-31",sub_title:null,button_text:"首月 9 元",jump_url:"zhihu://vip/purchase",button_jump_url:"zhihu://vip/purchase",sub_title_new:null,identity:"super_svip"};e["vip_info"]["entrance_new"]={left_button:{title:"精选会员内容",description:"为您严选好内容",jump_url:"zhihu://market/home"},right_button:{title:"开通盐选会员",description:"畅享 10w+ 场优质内容等特权",jump_url:"zhihu://vip/purchase"}};e["vip_info"]["entrance_v2"]={title:"我的超级盐选会员",sub_title:"畅享 5000W+ 优质内容",jump_url:"zhihu://market/home",button_text:"查看会员",sub_title_color:"#F8E2C4",sub_title_list:["畅享 5000W+ 优质内容"],card_jump_url:"zhihu://market/home"};$.logger.debug("设置用户为本地盐选会员");t={body:JSON.stringify(e)}}}else{$.logger.warning(`没有获取到本次登录用户信息,如未对功能造成影响,请忽略此日志。`)}}catch(e){$.logger.error(`获取当前用户信息出现异常:${e}`)}return t}function manageBlackUser(){const r=getUserInfo();let t={};let n=$.data.read(blockedUsersKey,"",r.id);n=typeof n==="object"&&!!n?n:{};defaultAnswerBlockedUsers.forEach(e=>{n[e]="00000000000000000000000000000000";t[e]="00000000000000000000000000000000"});$.logger.debug(`当前用户id:${r.id},脚本黑名单:${JSON.stringify(n)}`);if($.request.method==="GET"){try{if($.request.url.indexOf("offset")<0){n=t;$.logger.debug("脚本黑名单已清空,请滑动至黑名单末尾保证重新获取完成。");$.notification.post("开始同步黑名单数据,请滑动至黑名单末尾,直至弹出“同步成功”的通知。")}let e=JSON.parse($.response.body);if(!!e["data"]){$.logger.debug(`本次滑动获取的黑名单信息:${JSON.stringify(e["data"])}`);e["data"].forEach(e=>{if(e["name"]!=="[已重置]"){n[e["name"]]=e["id"]}});$.data.write(blockedUsersKey,n,r.id);if(e["paging"]["is_end"]===true){$.notification.post(`同步黑名单数据成功!当前黑名单共${Object.keys(n).length-defaultAnswerBlockedUsers.length}人。\n脚本内置黑名单${defaultAnswerBlockedUsers.length}人。`);$.logger.debug(`脚本黑名单内容:${JSON.stringify(n)}。`)}}else{$.logger.warning(`获取黑名单失败,接口响应不合法:${$.response.body}`)}}catch(e){$.data.del(blockedUsersKey);$.logger.error(`获取黑名单失败,异常信息:${e}`);$.notification.post("获取黑名单失败,执行异常,已清空黑名单。")}}else if($.request.method==="POST"){try{let e=JSON.parse($.response.body);if(e.hasOwnProperty("name")&&e.hasOwnProperty("id")){$.logger.debug(`当前需要加入黑名单的用户Id:${e["id"]},用户名:${e["name"]}`);if(e["id"]){n[e["name"]]=e["id"];$.data.write(blockedUsersKey,n,r.id);$.logger.debug(`${e["name"]}写入脚本黑名单成功,当前脚本黑名单数据:${JSON.stringify(n)}`);$.notification.post(`已将用户“${e["name"]}”写入脚本黑名单。`)}else{$.logger.error(`${e["name"]}写入脚本黑名单失败,没有获取到用户Id。`);$.notification.post(`将用户“${e["name"]}”写入脚本黑名单失败!`)}}else{$.logger.warning(`写入黑名单失败,接口响应不合法:${$.response.body}`);$.notification.post("写入脚本黑名单失败,接口返回不合法。")}}catch(e){$.logger.error(`写入黑名单失败,异常信息:${e}`);$.notification.post("写入脚本黑名单失败,执行异常,请查阅日志。")}}else if($.request.method==="DELETE"){try{let e=JSON.parse($.response.body);if(e.success){let t=$.request.url.match(/^https?:\/\/api\.zhihu\.com\/settings\/blocked_users\/([0-9a-zA-Z]*)/)[1];if(t){$.logger.debug(`当前需要移出黑名单的用户Id:${t}`);for(let e in n){if(n[e]===t){delete n[e];$.data.write(blockedUsersKey,n,r.id);$.logger.debug(`${e}移出脚本黑名单成功,当前脚本黑名单数据:${JSON.stringify(n)}`);$.notification.post(`已将用户“${e}”移出脚本黑名单!`);break}}}else{$.logger.error("将用户移出脚本黑名单失败!\n建议从设置中刷新黑名单数据。");$.notification.post(`将用户移出脚本黑名单失败,没有获取到用户Id。\n建议从设置中刷新黑名单数据。`)}}else{$.logger.warning(`移出黑名单失败,接口响应不合法:${$.response.body}`);$.notification.post("移出脚本黑名单失败,接口返回不合法。")}}catch(e){$.logger.error(`移出黑名单失败,异常信息:${e}`);$.notification.post("移出脚本黑名单失败,执行异常,请查阅日志。")}}}function autoInsertBlackList(){let e=null;try{let t=JSON.parse($.response.body);delete t["mcn_user_info"];e={body:JSON.stringify(t)};if(t.name&&t.id&&t["is_blocking"]===true){const r=getUserInfo();let e=$.data.read(blockedUsersKey,"",r.id);e=typeof e==="object"&&!!e?e:{};if(!e[t.name]){$.logger.debug(`当前需要加入黑名单的用户Id:${t["id"]},用户名:${t["name"]}`);e[t["name"]]=t["id"];$.data.write(blockedUsersKey,e,r.id);$.logger.debug(`${t["name"]}写入脚本黑名单成功,当前脚本黑名单数据:${JSON.stringify(e)}`);$.notification.post(`已自动将用户“${t["name"]}”写入脚本黑名单。`)}}}catch(e){$.logger.error(`去除MCN信息出现异常:${e}`)}return e}function removeMoments(){let r=null;try{let e=JSON.parse($.response.body.replace(/(\w+"+\s?):\s?(\d{15,})/g,'$1:"$2"'));const n=getUserInfo();let i=$.data.read(blockedUsersKey,"",n.id);i=!!i?i:{};let t;const s=$.data.read("zhihu_settings_moments_stream",false);const a=$.data.read("zhihu_settings_moments_recommend",false);const l=$.data.read("zhihu_settings_moments_activity",false);const c=$.data.read("zhihu_settings_blocked_users",false);t=e.data.filter(e=>{const t=c&&e.target&&e.target["origin_pin"]&&e.target["origin_pin"].author&&typeof i[e.target["origin_pin"].author.name]!="undefined";const r=s&&e["target_type"]==="zvideo";const n=a&&e.type==="recommend_user_card_list";const o=l&&e.type==="message_activity_card";return!(t||r||n||o)});e["data"]=t;r={body:JSON.stringify(e)}}catch(e){$.logger.error(`关注列表去广告出现异常:${e}`)}return r}function _setRecommendTag(e,t,r="GBK02A"){if(!e["common_card"]["footline"]){e["common_card"]["footline"]={elements:[]}}e["common_card"]["footline"]["elements"].unshift({tag:{text:t,color:r,type:"MASK_ROUNDED_RECTANGLE"}})}async function _checkPaidContentByCloud(e,n){const t=$.data.read(zheyeServerKey);if(!t){$.notification.post("未设置服务端地址,无法进行付费/推广内容探测。\n请配置服务端地址,或使用本地探测。")}else{$.logger.debug(`向云端请求以下链接\n${e.join("\n")}`);const r=`${t}/api/v1/answer/links`;$.logger.debug(`服务端地址\n${r}`);await $.http.post({url:r,headers:{"Content-Type":"application/json"},body:e}).then(r=>{$.logger.debug(`云端探测结果<${typeof r.body}>\n${JSON.stringify(r.body)}`);for(let t=0;t{$.logger.error(`云端请求出现异常\n${JSON.stringify(e)}`)})}}async function _checkPaidContentByLocal(n,o){$.logger.debug(`将在本地请求以下链接\n${n.join("\n")}`);let t=[];function r(t){return new Promise(r=>{const e=n[t];if(!e||e===""||!e.startsWith("https://www.zhihu.com/appview/v2/answer")){r("")}else{$.http.get({url:n[t],timeout:1e3}).then(e=>{const t=e.body;if((t.indexOf("查看完整内容")>=0||t.indexOf("查看全部章节")>=0)&&t.indexOf("paid")>=0){r("付费内容")}else if(t.indexOf("ad-link-card")>=0||t.indexOf("xg.zhihu.com")>=0||t.indexOf("营销平台")>=0){r("营销推广")}else if(t.indexOf("mcn-link-card")>=0){r("购物推广")}else{r("")}}).catch(e=>{$.logger.error(`本地请求出现异常\n${JSON.stringify(e)}`);r("")})}})}for(let e=0;e{$.logger.debug(`本地探测结果<${r.length}>\n${JSON.stringify(r)}`);for(let t=0;t{const e=JSON.stringify(o);const t=o["card_type"]==="slot_event_card"||o["card_type"]==="slot_video_event_card"||o.hasOwnProperty("ad")||o["brief"]&&o["brief"].indexOf("slot_card")>=0||o["extra"]&&o["extra"]["type"]==="Training";const r=t!==true&&e.search(/"(type|style)+"\s?:\s?"(drama|zvideo|Video|BIG_IMAGE)+"/i)>=0;const n=r&&p;const i=r!==true&&e.search(/"(type|style)+"\s?:\s?"pin"/i)>=0;const s=i&&g;const a=e.search(/"(type|style)+"\s?:\s?"article"/i)>=0;const l=a&&h;let c=false;if(r!==true&&m){for(let n=0;n=0){if($.isDebug){let e=o["common_card"]["feed_content"]["title"]["panel_text"];let t=o["common_card"]["feed_content"]["content"]["panel_text"];let r="";try{r=o["common_card"]["feed_content"]["title"]["action"]["intent_url"]}catch{}$.logger.debug(`匹配关键字:\n${u[n]}\n标题:\n${e}\n内容:\n${t}`);$.notification.debug(scriptName,`关键字:${u[n]}`,`${e}\n${t}`,r)}c=true;break}}}let d;try{d=c!==true&&y&&f&&o["common_card"]["feed_content"]["source_line"]["elements"][1]["text"]["panel_text"]in f}catch{d=false}return!(t||s||l||n||c||d)};let e=JSON.parse($.response.body.replace(/(\w+"+\s?):\s?(\d{15,})/g,'$1:"$2"'));let n=e["data"].filter(s);if(r===true){let r=[];for(let t=0;t0&&o==="cloud"){await _checkPaidContentByCloud(r,n)}else if(r.length>0&&o==="local"){await _checkPaidContentByLocal(r,n)}}e["data"]=n;t={body:JSON.stringify(e)}}catch(e){$.logger.error(`推荐列表去广告出现异常:${e}`)}return t}function removeQuestions(){let t=null;try{const r=getUserInfo();let n=$.data.read(blockedUsersKey,"",r.id);n=!!n?n:{};let e=JSON.parse($.response.body);const i=$.data.read("zhihu_settings_blocked_users",false);$.logger.debug(`当前黑名单列表: ${JSON.stringify(n)}`);let o=$.data.read(blackAnswersIdKey,[]);delete e["ad_info"];if(e["data"]){let r=[];for(let t of e.data){let e="";const a=t.target.id.toString();try{if("target"in t){e=t["target"]["author"]["name"]}}catch(e){$.logger.error(`获取回答列表用户名出现异常:${e}`)}const l=typeof n[e]!="undefined";const c=i&&l;if("target"in t){t["target"]["visible_only_to_author"]=false;t["target"]["is_visible"]=true;t["target"]["is_copyable"]=true}if(!c){r.push(t)}else if(c===true&&o.includes(a)===false){o.push(a);$.notification.debug(`记录黑名单用户${e}的回答Id:${a}`)}}e.data=r}$.data.write(blackAnswersIdKey,o);const s=JSON.stringify(e);$.logger.debug(`修改后的回答列表数据:${s}`);t={body:s}}catch(e){$.logger.error(`回答列表去广告出现异常:${e}`)}return t}function modifyAnswer(){let r=null;try{let e=$.response.body;let t="";if((e.indexOf("查看完整内容")>=0||e.indexOf("查看全部章节")>=0)&&e.indexOf("paid")>=0){t='
本文为付费内容
'}else if(e.indexOf("ad-link-card")>=0||e.indexOf("xg.zhihu.com")>=0||e.indexOf("营销平台")>=0){t='
本文含有营销推广
'}else if(e.indexOf("mcn-link-card")>=0){t='
本文含有购物推广
'}else if(Math.floor(Math.random()*200)===7){t='
本文为免费内容
'}if(t!==""){const n=e.match(/(richText[^<]*>)(.)/)[1];const o=e.lastIndexOf(n)+n.length;r={body:e.slice(0,o)+t+e.slice(o)}}}catch(e){$.logger.error(`付费内容提醒出现异常:${e}`)}return r}function removeComment(){let e=null;try{if(!!$.response.body){let t=JSON.parse($.response.body);t["ad_info"]={};if($.data.read("zhihu_settings_blocked_users",false)===true){let e=getUserInfo();let s=$.data.read(blockedUsersKey,"",e.id);s=!!s?s:{};let a=[];let l={};if(typeof t.root!="undefined"){const n=t.root.author.name;const o=typeof s[n]!="undefined";if(o===true){t.root.is_delete=true;t.root.can_reply=false;t.root.can_like=false;t.root.author.name="黑名单用户";t.root.author.avatar_url="https://picx.zhimg.com/v2-abed1a8c04700ba7d72b45195223e0ff_xll.jpg"}}if(typeof t.data!="undefined"){t.data.forEach(e=>{const t=e.author.name;let r="";if(e["reply_to_author"]&&e["reply_to_author"].name){r=e["reply_to_author"].name}const n=r!=="";const o=typeof s[t]!="undefined";const i=typeof s[r]!="undefined";if(o===true||i===true){if(o&&!n&&$.request.url.indexOf("root_comment")>0){$.notification.debug(`屏蔽黑名单用户“${t}”的主评论。`)}else if(!o&&n&&!i&&$.request.url.indexOf("child_comment")>0){$.notification.debug(`屏蔽黑名单用户“${t}”的子评论。`)}else if(o&&!i&&$.request.url.indexOf("child_comment")>0){$.notification.debug(`屏蔽黑名单用户“${t}”回复“${r}”的子评论。`)}else if(o&&i&&$.request.url.indexOf("child_comment")>0){$.notification.debug(`屏蔽黑名单用户“${t}”回复黑名单用户“${r}”的子评论。`)}l[e.id]=t;if(o){e.is_delete=true;e.can_reply=false;e.can_like=false;e.author.exposed_medal={};e.author.name="[黑名单用户]";e.author.avatar_url="https://picx.zhimg.com/v2-abed1a8c04700ba7d72b45195223e0ff_xll.jpg"}if(i){e["reply_to_author"].name="[黑名单用户]";e["reply_to_author"].exposed_medal={};e["reply_to_author"].avatar_url="https://picx.zhimg.com/v2-abed1a8c04700ba7d72b45195223e0ff_xll.jpg"}}if(e.child_comments){let i=[];e.child_comments.forEach(e=>{const t=e.author.name;const r=typeof e["reply_to_author"]!="undefined"?e["reply_to_author"].name:"";const n=typeof s[t]!="undefined";const o=typeof s[r]!="undefined";if(n||o){if(n===true){$.notification.debug(`屏蔽黑名单用户“${t}”的子评论。`);l[e.id]=t;e.is_delete=true;e.can_reply=false;e.can_like=false;e.author.name="[黑名单用户]";e.author.exposed_medal={};e.author.avatar_url="https://picx.zhimg.com/v2-abed1a8c04700ba7d72b45195223e0ff_xll.jpg"}if(o===true){$.logger.debug(`修改前的子评论数据:\n${JSON.stringify(e)}`);e["reply_to_author"].name="[黑名单用户]";e["reply_to_author"].exposed_medal={};e["reply_to_author"].avatar_url="https://picx.zhimg.com/v2-abed1a8c04700ba7d72b45195223e0ff_xll.jpg";$.notification.debug(`隐藏“${t}”回复黑名单用户“${r}”的名称与头像。`);$.logger.debug(`修改后的子评论数据:\n${JSON.stringify(e)}`)}}i.push(e)});e.child_comments=i}a.push(e)})}t.data=a}const r=JSON.stringify(t);$.logger.debug(`过滤后的评论数据:\n${r}`);e={body:r}}}catch(e){$.logger.error(`去除评论广告出现异常:${e}`)}return e}function removeArticleAd(){let t=null;try{if(!!$.response.body){let e=JSON.parse($.response.body);e["ad_info"]={};const r=JSON.stringify(e);$.logger.debug(`过滤后的文章数据:\n${r}`);t={body:r}}}catch(e){$.logger.error(`去除文章广告出现异常:${e}`)}return t}function removeMarketingMsg(){let t=null;try{let e=JSON.parse($.response.body);let r=[];for(let t of e["data"]){if(t["detail_title"]==="官方帐号消息"){let e=t["unread_count"];if(e>0){t["content"]["text"]="未读消息"+e+"条"}else{t["content"]["text"]="全部消息已读"}t["is_read"]=true;t["unread_count"]=0;r.push(t)}else if(t["detail_title"]!=="活动助手"){r.push(t)}}e["data"]=r;t={body:JSON.stringify(e)}}catch(e){$.logger.error(`屏蔽官方营销消息出现异常:${e}`)}return t}function removeHotListAds(){let t=null;try{if(!!$.response.body){let e=JSON.parse($.response.body);if("data"in e){e["data"]=e["data"].filter(e=>{return e["type"]==="hot_list_feed"||e["type"]==="hot_list_feed_video"})}t={body:JSON.stringify(e)}}}catch(e){$.logger.error(`去除热榜广告出现异常:${e}`)}return t}function removeKeywordAds(){let t=null;try{if(!!$.response.body){$.logger.debug(`预置关键字返回:${$.response.body}`);let e=JSON.parse($.response.body);if(e.hasOwnProperty("preset_words")&&e["preset_words"]["words"]){e["preset_words"]["words"]=e["preset_words"]["words"].filter(e=>{return e["type"]!=="ad"});t={body:JSON.stringify(e)}}}}catch(e){$.logger.error(`去除预置关键字广告出现异常:${e}`)}return t}function removeNextBlackUserAnswer(){let t=null;try{if(!!$.response.body){let e=JSON.parse($.response.body);const n=$.data.read(blackAnswersIdKey,[]);if(n.length>0){let r=[];e.data.forEach(e=>{const t=n.includes(e.id.toString());if(t===false){e.ad_info={data:""};r.push(e)}else{$.notification.debug(`屏蔽翻页过程中出现的黑名单用户回答Id:${e.id}`)}});for(let e=0;e{e["ad_info"]={data:""};const t=typeof r[e.data.author.name]!="undefined";$.logger.debug(`用户${e.data.author.name}是否在黑名单中:${t}`);if($.data.read("zhihu_settings_blocked_users",false)===false||t===false){n.push(e)}});e.data.data=n;o={body:JSON.stringify(e)}}}catch(e){$.logger.error(`屏蔽回答信息流黑名单用户及广告:${e}`)}return o}function changeUserCredit(){$.notification.debug("开始修改用户盐值");let t=null;try{if(!!$.response.body){const r=parseInt($.data.read(userCreditScoreKey,780));$.logger.debug(`准备修改用户盐值为${r}`);let e=JSON.parse($.response.body);if(e["credit_basis"].total_score{let e=null;if($.isResponse){switch(true){case/^https:\/\/api\.zhihu\.com\/people\/self$/.test($.request.url):e=processUserInfo();break;case $.data.read("zhihu_settings_app_conf",false)===true&&/^https?:\/\/appcloud2\.zhihu\.com\/v\d+\/config/.test($.request.url):e=modifyAppConfig();break;case $.data.read("zhihu_settings_app_conf",false)===true&&/^https?:\/\/m-cloud\.zhihu\.com\/api\/cloud\/config\/all\?/.test($.request.url):e=modifyMCloudConfig();break;case/^https?:\/\/api\.zhihu\.com\/user-credit\/basis/.test($.request.url):e=changeUserCredit();break;case/^https:\/\/api\.zhihu\.com\/topstory\/recommend/.test($.request.url):e=await removeRecommend();break;case/^https?:\/\/api\.zhihu\.com\/(v4\/)?questions\/\d+/.test($.request.url):e=removeQuestions();break;case/^https?:\/\/api\.zhihu\.com\/next-data\?/.test($.request.url):e=modifyAnswersNextData();break;case $.data.read("zhihu_settings_sys_msg",true)!==false&&/^https?:\/\/api\.zhihu\.com\/notifications\/v3\/message/.test($.request.url):e=removeMarketingMsg();break;case/^https?:\/\/api\.zhihu\.com\/comment_v5\/(answers|pins|comments?|articles)\/\d+\/(root|child)_comment/.test($.request.url):e=removeComment();break;case/^https?:\/\/www\.zhihu\.com\/api\/v\d\/articles\/\d+\/recommendation\?/.test($.request.url):e=removeArticleAd();break;case/^https?:\/\/www\.zhihu\.com\/api\/v4\/comment_v5\/answers\/\d+\/abstract_comment\?/.test($.request.url):e=removeComment();break;case $.data.read("zhihu_settings_answer_tip",true)===true&&/^https?:\/\/www\.zhihu\.com\/appview\/v2\/answer\/.*(entry=(?!(preload-topstory|preload-search|preload-subscription)))?/.test($.request.url):e=modifyAnswer();break;case $.data.read("zhihu_settings_blocked_users",false)!==false&&/^https?:\/\/api\.zhihu\.com\/next\?/.test($.request.url):e=removeNextBlackUserAnswer();break;case $.data.read("zhihu_settings_blocked_users",true)===true&&/^https?:\/\/api\.zhihu\.com\/people\/((?!self).)*$/.test($.request.url):e=autoInsertBlackList();break;case/^https?:\/\/api\.zhihu\.com\/moments_v3\?/.test($.request.url):e=removeMoments();break;case $.data.read("zhihu_settings_hot_list",true)===true&&/^https?:\/\/api\.zhihu\.com\/topstory\/hot-lists(\?|\/)/.test($.request.url):e=removeHotListAds();break;case $.data.read("zhihu_settings_preset_words",true)===true&&/^https?:\/\/api\.zhihu\.com\/search\/preset_words\?/.test($.request.url):e=removeKeywordAds();break;case $.data.read("zhihu_settings_blocked_users",false)!==false&&/^https?:\/\/api\.zhihu\.com\/settings\/blocked_users/.test($.request.url):manageBlackUser();break;default:$.logger.debug("没有匹配到任何请求,请确认配置正确。");break}}else if($.isRequest){if($.data.read("zhihu_settings_blocked_keywords",false)!==false&&/^https?:\/\/api\.zhihu\.com\/feed-root\/block/.test($.request.url)===true){e=unlockBlockedKeywords(e)}}else{$.data.del(currentUserInfoKey);$.data.del(blockedUsersKey);$.data.del(keywordBlockKey);$.notification.post("哲也同学数据清理完毕")}if(e){$.done(e)}else{$.done()}})();function MagicJS(e="MagicJS",t="INFO"){const n=()=>{const e=typeof $loon!=="undefined";const t=typeof $task!=="undefined";const r=typeof module!=="undefined";const n=typeof $httpClient!=="undefined"&&!e;const o=typeof $storm!=="undefined";const i=typeof $environment!=="undefined"&&typeof $environment["stash-build"]!=="undefined";const s=n||e||o||i;const a=typeof importModule!=="undefined";return{isLoon:e,isQuanX:t,isNode:r,isSurge:n,isStorm:o,isStash:i,isSurgeLike:s,isScriptable:a,get name(){if(e){return"Loon"}else if(t){return"QuantumultX"}else if(r){return"NodeJS"}else if(n){return"Surge"}else if(a){return"Scriptable"}else{return"unknown"}},get build(){if(n){return $environment["surge-build"]}else if(i){return $environment["stash-build"]}else if(o){return $storm.buildVersion}},get language(){if(n||i){return $environment["language"]}},get version(){if(n){return $environment["surge-version"]}else if(i){return $environment["stash-version"]}else if(o){return $storm.appVersion}else if(r){return process.version}},get system(){if(n){return $environment["system"]}else if(r){return process.platform}},get systemVersion(){if(o){return $storm.systemVersion}},get deviceName(){if(o){return $storm.deviceName}}}};const o=(r,e="INFO")=>{let n=e;const o={SNIFFER:6,DEBUG:5,INFO:4,NOTIFY:3,WARNING:2,ERROR:1,CRITICAL:0,NONE:-1};const i={SNIFFER:"",DEBUG:"",INFO:"",NOTIFY:"",WARNING:"❗ ",ERROR:"❌ ",CRITICAL:"❌ ",NONE:""};const t=(e,t="INFO")=>{if(!(o[n]{n=e};return{getLevel:()=>{return n},setLevel:s,sniffer:e=>{t(e,"SNIFFER")},debug:e=>{t(e,"DEBUG")},info:e=>{t(e,"INFO")},notify:e=>{t(e,"NOTIFY")},warning:e=>{t(e,"WARNING")},error:e=>{t(e,"ERROR")},retry:e=>{t(e,"RETRY")}}};return new class{constructor(e,t){this._startTime=Date.now();this.version="3.0.0";this.scriptName=e;this.env=n();this.logger=o(e,t);this.http=typeof MagicHttp==="function"?MagicHttp(this.env,this.logger):undefined;this.data=typeof MagicData==="function"?MagicData(this.env,this.logger):undefined;this.notification=typeof MagicNotification==="function"?MagicNotification(this.scriptName,this.env,this.logger,this.http):undefined;this.utils=typeof MagicUtils==="function"?MagicUtils(this.env,this.logger):undefined;this.qinglong=typeof MagicQingLong==="function"?MagicQingLong(this.env,this.data,this.logger):undefined;if(typeof this.data!=="undefined"){let e=this.data.read("magic_loglevel");const r=this.data.read("magic_bark_url");if(e){this.logger.setLevel(e.toUpperCase())}if(r){this.notification.setBark(r)}}}get isRequest(){return typeof $request!=="undefined"&&typeof $response==="undefined"}get isResponse(){return typeof $response!=="undefined"}get isDebug(){return this.logger.level==="DEBUG"}get request(){return typeof $request!=="undefined"?$request:undefined}get response(){if(typeof $response!=="undefined"){if($response.hasOwnProperty("status"))$response["statusCode"]=$response["status"];if($response.hasOwnProperty("statusCode"))$response["status"]=$response["statusCode"];return $response}else{return undefined}}done=(e={})=>{this._endTime=Date.now();let t=(this._endTime-this._startTime)/1e3;this.logger.info(`SCRIPT COMPLETED: ${t} S.`);if(typeof $done!=="undefined"){$done(e)}}}(e,t)}function MagicNotification(i,s,a,l){let c=null;let d=null;const e=t=>{try{let e=t.replace(/\/+$/g,"");c=`${/^https?:\/\/([^/]*)/.exec(e)[0]}/push`;d=/\/([^\/]+)\/?$/.exec(e)[1]}catch(e){a.error(`Bark url error: ${e}.`)}};function t(e=i,t="",r="",n=""){const o=r=>{try{let t={};if(typeof r==="string"){if(s.isLoon)t={openUrl:r};else if(s.isQuanX)t={"open-url":r};else if(s.isSurge)t={url:r}}else if(typeof r==="object"){if(s.isLoon){t["openUrl"]=!!r["open-url"]?r["open-url"]:"";t["mediaUrl"]=!!r["media-url"]?r["media-url"]:""}else if(s.isQuanX){t=!!r["open-url"]||!!r["media-url"]?r:{}}else if(s.isSurge){let e=r["open-url"]||r["openUrl"];t=e?{url:e}:{}}}return t}catch(e){a.error(`通知选项转换失败${e}`)}return r};n=o(n);if(arguments.length===1){e=i;t="",r=arguments[0]}a.notify(`title:${e}\nsubTitle:${t}\nbody:${r}\noptions:${typeof n==="object"?JSON.stringify(n):n}`);if(s.isSurge){$notification.post(e,t,r,n)}else if(s.isLoon){if(!!n)$notification.post(e,t,r,n);else $notification.post(e,t,r)}else if(s.isQuanX){$notify(e,t,r,n)}if(c&&d){u(e,t,r)}}function r(e=i,t="",r="",n=""){if(a.getLevel()==="DEBUG"){if(arguments.length===1){e=i;t="";r=arguments[0]}this.post(e,t,r,n)}}function u(e=i,t="",r="",n=""){if(typeof l==="undefined"||typeof l.post==="undefined"){throw"Bark notification needs to import MagicHttp module."}let o={url:c,headers:{"content-type":"application/json; charset=utf-8"},body:{title:e,body:t?`${t}\n${r}`:r,device_key:d}};l.post(o).catch(e=>{a.error(`Bark notify error: ${e}`)})}return{post:t,debug:r,bark:u,setBark:e}}function MagicData(s,a){let l={fs:undefined,data:{}};if(s.isNode){l.fs=require("fs");try{l.fs.accessSync("./magic.json",l.fs.constants.R_OK|l.fs.constants.W_OK)}catch(e){l.fs.writeFileSync("./magic.json","{}",{encoding:"utf8"})}l.data=require("./magic.json")}const c=(e,t)=>{if(typeof t==="object"){return false}else{return e===t}};const d=e=>{if(e==="true"){return true}else if(e==="false"){return false}else if(typeof e==="undefined"){return null}else{return e}};const u=(e,t,r,n)=>{if(r){try{if(typeof e==="string")e=JSON.parse(e);if(e["magic_session"]===true){e=e[r]}else{e=null}}catch{e=null}}if(typeof e==="string"&&e!=="null"){try{e=JSON.parse(e)}catch{}}if(n===false&&!!e&&e["magic_session"]===true){e=null}if((e===null||typeof e==="undefined")&&t!==null&&typeof t!=="undefined"){e=t}e=d(e);return e};const i=t=>{if(typeof t==="string"){let e={};try{e=JSON.parse(t);const r=typeof e;if(r!=="object"||e instanceof Array||r==="bool"||e===null){e={}}}catch{}return e}else if(t instanceof Array||t===null||typeof t==="undefined"||t!==t||typeof t==="boolean"){return{}}else{return t}};const f=(e,t=null,r="",n=false,o=null)=>{let i=o||l.data;if(!!i&&typeof i[e]!=="undefined"&&i[e]!==null){val=i[e]}else{val=!!r?{}:null}val=u(val,t,r,n);return val};const g=(e,t=null,r="",n=false,o=null)=>{let i="";if(o||s.isNode){i=f(e,t,r,n,o)}else{if(s.isSurgeLike){i=$persistentStore.read(e)}else if(s.isQuanX){i=$prefs.valueForKey(e)}i=u(i,t,r,n)}a.debug(`READ DATA [${e}]${!!r?`[${r}]`:""} <${typeof i}>\n${JSON.stringify(i)}`);return i};const p=(t,r,n="",e=null)=>{let o=e||l.data;o=i(o);if(!!n){let e=i(o[t]);e["magic_session"]=true;e[n]=r;o[t]=e}else{o[t]=r}if(e!==null){e=o}return o};const h=(e,t,r="",n=null)=>{if(typeof t==="undefined"||t!==t){return false}if(!s.isNode&&(typeof t==="boolean"||typeof t==="number")){t=String(t)}let o="";if(n||s.isNode){o=p(e,t,r,n)}else{if(!r){o=t}else{if(s.isSurgeLike){o=!!$persistentStore.read(e)?$persistentStore.read(e):o}else if(s.isQuanX){o=!!$prefs.valueForKey(e)?$prefs.valueForKey(e):o}o=i(o);o["magic_session"]=true;o[r]=t}}if(!!o&&typeof o==="object"){o=JSON.stringify(o,null,4)}a.debug(`WRITE DATA [${e}]${r?`[${r}]`:""} <${typeof t}>\n${JSON.stringify(t)}`);if(!n){if(s.isSurgeLike){return $persistentStore.write(o,e)}else if(s.isQuanX){return $prefs.setValueForKey(o,e)}else if(s.isNode){try{l.fs.writeFileSync("./magic.json",o);return true}catch(e){a.error(e);return false}}}return true};const e=(t,r,n,o=c,i=null)=>{r=d(r);const e=g(t,null,n,false,i);if(o(e,r)===true){return false}else{const s=h(t,r,n,i);let e=g(t,null,n,false,i);if(o===c&&typeof e==="object"){return s}return o(r,e)}};const y=(e,t,r)=>{let n=r||l.data;n=i(n);if(!!t){obj=i(n[e]);delete obj[t];n[e]=obj}else{delete n[e]}if(!!r){r=n}return n};const t=(e,t="",r=null)=>{let n={};if(r||s.isNode){n=y(e,t,r);if(!r){l.fs.writeFileSync("./magic.json",JSON.stringify(n,null,4))}else{r=n}}else{if(!t){if(s.isStorm){return $persistentStore.remove(e)}else if(s.isSurgeLike){return $persistentStore.write(null,e)}else if(s.isQuanX){return $prefs.removeValueForKey(e)}}else{if(s.isSurgeLike){n=$persistentStore.read(e)}else if(s.isQuanX){n=$prefs.valueForKey(e)}n=i(n);delete n[t];const o=JSON.stringify(n,null,4);h(e,o)}}a.debug(`DELETE KEY [${e}]${!!t?`[${t}]`:""}`)};const r=(e,t=null)=>{let r=[];let n=g(e,null,null,true,t);n=i(n);if(n["magic_session"]!==true){r=[]}else{r=Object.keys(n).filter(e=>e!=="magic_session")}a.debug(`READ ALL SESSIONS [${e}] <${typeof r}>\n${JSON.stringify(r,null,4)}`);return r};const n=(e,t=null)=>{let r={};let n=g(e,null,null,true,t);n=i(n);if(n["magic_session"]===true){r={...n};delete r["magic_session"]}a.debug(`READ ALL SESSIONS [${e}] <${typeof r}>\n${JSON.stringify(r,null,4)}`);return r};return{read:g,write:h,del:t,update:e,allSessions:n,allSessionNames:r,defaultValueComparator:c,convertToObject:i}}function MagicHttp(c,d){let r;if(c.isNode){const a=require("axios");r=a.create()}class e{constructor(e=true){this.handlers=[];this.isRequest=e}use(e,t,r){if(typeof e==="function"){d.debug(`Register fulfilled ${e.name}`)}if(typeof t==="function"){d.debug(`Register rejected ${t.name}`)}this.handlers.push({fulfilled:e,rejected:t,synchronous:r&&typeof r.synchronous==="boolean"?r.synchronous:false,runWhen:r?r.runWhen:null});return this.handlers.length-1}eject(e){if(this.handlers[e]){this.handlers[e]=null}}forEach(t){this.handlers.forEach(e=>{if(e!==null){t(e)}})}}function o(e){let r={...e};if(!!r.params){if(!c.isNode){let e=Object.keys(r.params).map(e=>{const t=encodeURIComponent(e);r.url=r.url.replace(new RegExp(`${e}=[^&]*`,"ig"),"");r.url=r.url.replace(new RegExp(`${t}=[^&]*`,"ig"),"");return`${t}=${encodeURIComponent(r.params[e])}`}).join("&");if(r.url.indexOf("?")<0)r.url+="?";if(!/(&|\?)$/g.test(r.url)){r.url+="&"}r.url+=e;delete r.params;d.debug(`Params to QueryString: ${r.url}`)}}return r}const u=(e,t)=>{let r=typeof t==="object"?{headers:{},...t}:{url:t,headers:{}};if(!r.method){r["method"]=e}r=o(r);if(r["rewrite"]===true){if(c.isSurge){r.headers["X-Surge-Skip-Scripting"]=false;delete r["rewrite"]}else if(c.isQuanX){r["hints"]=false;delete r["rewrite"]}}if(c.isSurgeLike){const n=r.headers["content-type"]||r.headers["Content-Type"];if(r["method"]!=="GET"&&n&&n.indexOf("application/json")>=0&&r.body instanceof Array){r.body=JSON.stringify(r.body);d.debug(`Convert Array object to String: ${r.body}`)}}else if(c.isQuanX){if(r.hasOwnProperty("body")&&typeof r["body"]!=="string")r["body"]=JSON.stringify(r["body"]);r["method"]=e}else if(c.isNode){if(e==="POST"||e==="PUT"||e==="PATCH"||e==="DELETE"){r.data=r.data||r.body}else if(e==="GET"){r.params=r.params||r.body}delete r.body}return r};const f=(t,r=null)=>{if(t){let e={...t,config:t.config||r,status:t.statusCode||t.status,body:t.body||t.data,headers:t.headers||t.header};if(typeof e.body==="string"){try{e.body=JSON.parse(e.body)}catch{}}delete e.data;return e}else{return t}};const t=r=>{return Object.keys(r).reduce((e,t)=>{e[t.toLowerCase()]=r[t];return e},{})};const n=n=>{return Object.keys(n).reduce((e,t)=>{const r=t.split("-").map(e=>e[0].toUpperCase()+e.slice(1)).join("-");e[r]=n[t];return e},{})};const g=(e,t=null)=>{if(!!e&&e.status>=400){d.debug(`Raise exception when status code is ${e.status}`);return{name:"RequestException",message:`Request failed with status code ${e.status}`,config:t||e.config,response:e}}};const i={request:new e,response:new e(false)};let p=[];let h=[];let y=true;function $(e){e=o(e);d.debug(`HTTP ${e["method"].toUpperCase()}:\n${JSON.stringify(e)}`);return e}function m(e){try{e=!!e?f(e):e;d.sniffer(`HTTP ${e.config["method"].toUpperCase()}:\n${JSON.stringify(e.config)}\nSTATUS CODE:\n${e.status}\nRESPONSE:\n${typeof e.body==="object"?JSON.stringify(e.body):e.body}`);const t=g(e);if(!!t){return Promise.reject(t)}return e}catch(t){d.error(t);return e}}const _=t=>{try{p=[];h=[];i.request.forEach(e=>{if(typeof e.runWhen==="function"&&e.runWhen(t)===false){return}y=y&&e.synchronous;p.unshift(e.fulfilled,e.rejected)});i.response.forEach(e=>{h.push(e.fulfilled,e.rejected)})}catch(e){d.error(`Failed to register interceptors: ${e}.`)}};const s=(e,n)=>{let o;const t=e.toUpperCase();n=u(t,n);if(c.isNode){o=r}else{if(c.isSurgeLike){o=i=>{return new Promise((n,o)=>{$httpClient[e.toLowerCase()](i,(t,r,e)=>{if(t){let e={name:t.name||t,message:t.message||t,stack:t.stack||t,config:i,response:f(r)};o(e)}else{r.config=i;r.body=e;n(r)}})})}}else{o=o=>{return new Promise((r,n)=>{$task.fetch(o).then(e=>{e=f(e,o);const t=g(e,o);if(t){return Promise.reject(t)}r(e)}).catch(e=>{let t={name:e.message||e.error,message:e.message||e.error,stack:e.error,config:o,response:!!e.response?f(e.response):null};n(t)})})}}}let i;_(n);const s=[$,undefined];const a=[m,undefined];if(!y){d.debug("Interceptors are executed in asynchronous mode");let r=[o,undefined];Array.prototype.unshift.apply(r,s);Array.prototype.unshift.apply(r,p);r=r.concat(a);r=r.concat(h);i=Promise.resolve(n);while(r.length){try{let e=r.shift();let t=r.shift();if(!c.isNode&&n["timeout"]&&e===o){e=l}if(typeof e==="function"){d.debug(`Executing request fulfilled ${e.name}`)}if(typeof t==="function"){d.debug(`Executing request rejected ${t.name}`)}i=i.then(e,t)}catch(e){d.error(`request exception: ${e}`)}}return i}else{d.debug("Interceptors are executed in synchronous mode");Array.prototype.unshift.apply(p,s);p=p.concat([$,undefined]);while(p.length){let e=p.shift();let t=p.shift();try{if(typeof e==="function"){d.debug(`Executing request fulfilled ${e.name}`)}n=e(n)}catch(e){if(typeof t==="function"){d.debug(`Executing request rejected ${t.name}`)}t(e);break}}try{if(!c.isNode&&n["timeout"]){i=l(n)}else{i=o(n)}}catch(e){return Promise.reject(e)}Array.prototype.unshift.apply(h,a);while(h.length){i=i.then(h.shift(),h.shift())}return i}function l(r){try{const e=new Promise((e,t)=>{setTimeout(()=>{let e={message:`timeout of ${r["timeout"]}ms exceeded.`,config:r};t(e)},r["timeout"])});return Promise.race([o(r),e])}catch(e){d.error(`Request Timeout exception: ${e}.`)}}};return{request:s,interceptors:i,convertHeadersToLowerCase:t,convertHeadersToCamelCase:n,modifyResponse:f,get:e=>{return s("GET",e)},post:e=>{return s("POST",e)},put:e=>{return s("PUT",e)},patch:e=>{return s("PATCH",e)},delete:e=>{return s("DELETE",e)},head:e=>{return s("HEAD",e)},options:e=>{return s("OPTIONS",e)}}} \ No newline at end of file +const scriptName="哲也同学";const blockedUsersKey="zhihu_blocked_users";const currentUserInfoKey="zhihu_current_userinfo";const keywordBlockKey="zhihu_keyword_block";const blackAnswersIdKey="zhihu_black_answers";const userCreditScoreKey="zhihu_credit_score";const zheyeServerKey="zheye_server_url";const defaultAnswerBlockedUsers=["会员推荐","盐选推荐"];const keywordMaxCount=1e3;const $=MagicJS(scriptName,"INFO");function getUserInfo(){let defaultUserInfo={id:"default",is_vip:false};try{let userInfo=$.data.read(currentUserInfoKey);if(typeof userInfo==="string")userInfo=JSON.parse(userInfo);if(!!userInfo&&userInfo.hasOwnProperty("id")){return userInfo}else{return defaultUserInfo}}catch(err){$.logger.error(`获取用户信息出现异常:${err}`);return defaultUserInfo}}function modifyAppConfig(){let response=null;try{if(!!$.response.body){let obj=JSON.parse($.response.body);obj["config"]["homepage_feed_tab"]["tab_infos"]=obj["config"]["homepage_feed_tab"]["tab_infos"].filter(e=>{if(e["tab_type"]==="activity_tab"){e["end_time"]=(new Date-12e4).toString().slice(0,10);return true}else{return false}});obj["config"]["zvideo_max_number"]=1;obj["config"]["is_show_followguide_alert"]=false;delete obj["config"]["hp_channel_tab"];if(obj["config"]["zombie_conf"]){obj["config"]["zombie_conf"]["zombieEnable"]=false}if(obj["config"]["gray_mode"]){obj["config"]["gray_mode"]["enable"]=false;obj["config"]["gray_mode"]["start_time"]="4092566400";obj["config"]["gray_mode"]["end_time"]="4092566400"}if(obj["config"].hasOwnProperty("zhcnh_thread_sync")){$.logger.debug(JSON.stringify(obj["config"]["zhcnh_thread_sync"]));obj["config"]["zhcnh_thread_sync"]["LocalDNSSetHostWhiteList"]=[];obj["config"]["zhcnh_thread_sync"]["isOpenLocalDNS"]="0";obj["config"]["zhcnh_thread_sync"]["ZHBackUpIP_Switch_Open"]="0";obj["config"]["zhcnh_thread_sync"]["dns_ip_detector_operation_lock"]="1";obj["config"]["zhcnh_thread_sync"]["ZHHTTPSessionManager_setupZHHTTPHeaderField"]="1"}response={body:JSON.stringify(obj)}}}catch(err){$.logger.error(`优化软件配置出现异常:${err}`)}return response}function modifyMCloudConfig(){let response=null;try{if(!!$.response.body){let obj=JSON.parse($.response.body);if(obj.data&&obj.data["configs"]){obj.data["configs"].forEach(element=>{if(element["configKey"]==="feed_gray_theme"){element["configValue"].start_time="1669824000";element["configValue"].end_time="1669824001";element.status=false}})}const body=JSON.stringify(obj);$.logger.debug(body);response={body:body}}}catch(err){$.logger.error(`优化软件配置出现异常:${err}`)}return response}function unlockBlockedKeywords(){let response=null;try{const userInfo=getUserInfo();if($.request.method==="GET"){let keywords=$.data.read(keywordBlockKey,null,userInfo.id);if(!keywords){keywords=[]}let headers={"Cache-Control":"no-cache, no-store, must-revalidate, private, max-age=0",Connection:"keep-alive","Content-Type":"application/json;charset=utf-8",Pragma:"no-cache","Referrer-Policy":"no-referrer-when-downgrade",Server:"CLOUD ELB 1.0.0",Vary:"Accept-Encoding","X-Cache-Lookup":"Cache Miss","x-cdn-provider":"tencent"};let body=JSON.stringify({success:true,is_vip:true,kw_min_length:2,kw_max_length:100,kw_max_count:keywordMaxCount,data:keywords});if($.env.isQuanX){response={body:body,headers:headers,status:"HTTP/1.1 200 OK"}}else{response={response:{body:body,headers:headers,status:200}}}$.logger.debug(`获取本地脚本屏蔽关键词:\n${keywords.join("、")}`)}else if($.request.method==="POST"){if(!!$.request.body){let headers={"Cache-Control":"no-cache, no-store, must-revalidate, private, max-age=0",Connection:"keep-alive","Content-Type":"application/json;charset=utf-8",Pragma:"no-cache","Referrer-Policy":"no-referrer-when-downgrade",Server:"CLOUD ELB 1.0.0",Vary:"Accept-Encoding","X-Cache-Lookup":"Cache Miss","x-cdn-provider":"tencent"};let keyword=decodeURIComponent($.request.body).match(/keyword=(.*)/)[1];let keywords=$.data.read(keywordBlockKey,null,userInfo.id);if(!keywords){keywords=[]}let keywordExists=false;for(let i=0;i{return e!==keyword});$.data.write(keywordBlockKey,keywords,userInfo.id);let headers={"Cache-Control":"no-cache, no-store, must-revalidate, private, max-age=0",Connection:"keep-alive","Content-Type":"application/json;charset=utf-8",Pragma:"no-cache","Referrer-Policy":"no-referrer-when-downgrade",Server:"CLOUD ELB 1.0.0",Vary:"Accept-Encoding","X-Cache-Lookup":"Cache Miss","x-cdn-provider":"tencent"};let body=JSON.stringify({success:true});if($.env.isQuanX){response={body:body,headers:headers,status:"HTTP/1.1 200 OK"}}else{response={response:{body:body,headers:headers,status:200}}}$.logger.debug(`删除本地脚本屏蔽关键词:“${keyword}”`)}}catch(err){$.logger.debug(`关键词屏蔽操作出现异常:${err}`)}return response}function processUserInfo(){let response=null;try{let obj=JSON.parse($.response.body);$.data.write(blackAnswersIdKey,[]);$.logger.debug(`用户登录用户信息,接口响应:${$.response.body}`);if(obj&&obj["id"]&&obj.hasOwnProperty("vip_info")&&obj["vip_info"].hasOwnProperty("is_vip")){const userInfo={id:obj["id"],is_vip:obj["vip_info"]["is_vip"]?obj["vip_info"]["is_vip"]!==undefined:false};$.logger.debug(`当前用户id:${obj["id"]},是否为VIP:${obj["vip_info"]["is_vip"]}`);$.data.write(currentUserInfoKey,userInfo);if($.data.read("zhihu_settings_fake_vip")!==false&&obj["vip_info"]["is_vip"]===false){obj["vip_info"]["is_vip"]=true;obj["vip_info"]["vip_type"]=2;obj["vip_info"]["vip_icon"]={url:"https://picx.zhimg.com/v2-aa8a1823abfc46f14136f01d55224925.jpg?source=88ceefae",night_mode_url:"https://picx.zhimg.com/v2-aa8a1823abfc46f14136f01d55224925.jpg?source=88ceefae"};obj["vip_info"]["vip_icon_v2"]={url:"https://picx.zhimg.com/v2-aa8a1823abfc46f14136f01d55224925.jpg?source=88ceefae",night_mode_url:"https://picx.zhimg.com/v2-aa8a1823abfc46f14136f01d55224925.jpg?source=88ceefae"};obj["vip_info"]["entrance"]={icon:{url:"https://pic3.zhimg.com/v2-5b7012c8c22fd520f5677305e1e551bf.png",night_mode_url:"https://pic4.zhimg.com/v2-e51e3252d7a2cb016a70879defd5da0b.png"},title:"盐选会员 为你严选好内容",expires_day:"2099-12-31",sub_title:null,button_text:"首月 9 元",jump_url:"zhihu://vip/purchase",button_jump_url:"zhihu://vip/purchase",sub_title_new:null,identity:"super_svip"};obj["vip_info"]["entrance_new"]={left_button:{title:"精选会员内容",description:"为您严选好内容",jump_url:"zhihu://market/home"},right_button:{title:"开通盐选会员",description:"畅享 10w+ 场优质内容等特权",jump_url:"zhihu://vip/purchase"}};obj["vip_info"]["entrance_v2"]={title:"我的超级盐选会员",sub_title:"畅享 5000W+ 优质内容",jump_url:"zhihu://market/home",button_text:"查看会员",sub_title_color:"#F8E2C4",sub_title_list:["畅享 5000W+ 优质内容"],card_jump_url:"zhihu://market/home"};$.logger.debug("设置用户为本地盐选会员");response={body:JSON.stringify(obj)}}}else{$.logger.warning(`没有获取到本次登录用户信息,如未对功能造成影响,请忽略此日志。`)}}catch(err){$.logger.error(`获取当前用户信息出现异常:${err}`)}return response}function manageBlackUser(){const userInfo=getUserInfo();let defaultBlockedUsers={};let customBlockedUsers=$.data.read(blockedUsersKey,"",userInfo.id);customBlockedUsers=typeof customBlockedUsers==="object"&&!!customBlockedUsers?customBlockedUsers:{};defaultAnswerBlockedUsers.forEach(element=>{customBlockedUsers[element]="00000000000000000000000000000000";defaultBlockedUsers[element]="00000000000000000000000000000000"});$.logger.debug(`当前用户id:${userInfo.id},脚本黑名单:${JSON.stringify(customBlockedUsers)}`);if($.request.method==="GET"){try{if($.request.url.indexOf("offset")<0){customBlockedUsers=defaultBlockedUsers;$.logger.debug("脚本黑名单已清空,请滑动至黑名单末尾保证重新获取完成。");$.notification.post("开始同步黑名单数据,请滑动至黑名单末尾,直至弹出“同步成功”的通知。")}let obj=JSON.parse($.response.body);if(!!obj["data"]){$.logger.debug(`本次滑动获取的黑名单信息:${JSON.stringify(obj["data"])}`);obj["data"].forEach(element=>{if(element["name"]!=="[已重置]"){customBlockedUsers[element["name"]]=element["id"]}});$.data.write(blockedUsersKey,customBlockedUsers,userInfo.id);if(obj["paging"]["is_end"]===true){$.notification.post(`同步黑名单数据成功!当前黑名单共${Object.keys(customBlockedUsers).length-defaultAnswerBlockedUsers.length}人。\n脚本内置黑名单${defaultAnswerBlockedUsers.length}人。`);$.logger.debug(`脚本黑名单内容:${JSON.stringify(customBlockedUsers)}。`)}}else{$.logger.warning(`获取黑名单失败,接口响应不合法:${$.response.body}`)}}catch(err){$.data.del(blockedUsersKey);$.logger.error(`获取黑名单失败,异常信息:${err}`);$.notification.post("获取黑名单失败,执行异常,已清空黑名单。")}}else if($.request.method==="POST"){try{let obj=JSON.parse($.response.body);if(obj.hasOwnProperty("name")&&obj.hasOwnProperty("id")){$.logger.debug(`当前需要加入黑名单的用户Id:${obj["id"]},用户名:${obj["name"]}`);if(obj["id"]){customBlockedUsers[obj["name"]]=obj["id"];$.data.write(blockedUsersKey,customBlockedUsers,userInfo.id);$.logger.debug(`${obj["name"]}写入脚本黑名单成功,当前脚本黑名单数据:${JSON.stringify(customBlockedUsers)}`);$.notification.post(`已将用户“${obj["name"]}”写入脚本黑名单。`)}else{$.logger.error(`${obj["name"]}写入脚本黑名单失败,没有获取到用户Id。`);$.notification.post(`将用户“${obj["name"]}”写入脚本黑名单失败!`)}}else{$.logger.warning(`写入黑名单失败,接口响应不合法:${$.response.body}`);$.notification.post("写入脚本黑名单失败,接口返回不合法。")}}catch(err){$.logger.error(`写入黑名单失败,异常信息:${err}`);$.notification.post("写入脚本黑名单失败,执行异常,请查阅日志。")}}else if($.request.method==="DELETE"){try{let obj=JSON.parse($.response.body);if(obj.success){let user_id=$.request.url.match(/^https?:\/\/api\.zhihu\.com\/settings\/blocked_users\/([0-9a-zA-Z]*)/)[1];if(user_id){$.logger.debug(`当前需要移出黑名单的用户Id:${user_id}`);for(let username in customBlockedUsers){if(customBlockedUsers[username]===user_id){delete customBlockedUsers[username];$.data.write(blockedUsersKey,customBlockedUsers,userInfo.id);$.logger.debug(`${username}移出脚本黑名单成功,当前脚本黑名单数据:${JSON.stringify(customBlockedUsers)}`);$.notification.post(`已将用户“${username}”移出脚本黑名单!`);break}}}else{$.logger.error("将用户移出脚本黑名单失败!\n建议从设置中刷新黑名单数据。");$.notification.post(`将用户移出脚本黑名单失败,没有获取到用户Id。\n建议从设置中刷新黑名单数据。`)}}else{$.logger.warning(`移出黑名单失败,接口响应不合法:${$.response.body}`);$.notification.post("移出脚本黑名单失败,接口返回不合法。")}}catch(err){$.logger.error(`移出黑名单失败,异常信息:${err}`);$.notification.post("移出脚本黑名单失败,执行异常,请查阅日志。")}}}function autoInsertBlackList(){let response=null;try{let obj=JSON.parse($.response.body);delete obj["mcn_user_info"];response={body:JSON.stringify(obj)};if(obj.name&&obj.id&&obj["is_blocking"]===true){const userInfo=getUserInfo();let customBlockedUsers=$.data.read(blockedUsersKey,"",userInfo.id);customBlockedUsers=typeof customBlockedUsers==="object"&&!!customBlockedUsers?customBlockedUsers:{};if(!customBlockedUsers[obj.name]){$.logger.debug(`当前需要加入黑名单的用户Id:${obj["id"]},用户名:${obj["name"]}`);customBlockedUsers[obj["name"]]=obj["id"];$.data.write(blockedUsersKey,customBlockedUsers,userInfo.id);$.logger.debug(`${obj["name"]}写入脚本黑名单成功,当前脚本黑名单数据:${JSON.stringify(customBlockedUsers)}`);$.notification.post(`已自动将用户“${obj["name"]}”写入脚本黑名单。`)}}}catch(err){$.logger.error(`去除MCN信息出现异常:${err}`)}return response}function removeMoments(){let response=null;try{let obj=JSON.parse($.response.body.replace(/(\w+"+\s?):\s?(\d{15,})/g,'$1:"$2"'));const user_info=getUserInfo();let customBlockedUsers=$.data.read(blockedUsersKey,"",user_info.id);customBlockedUsers=!!customBlockedUsers?customBlockedUsers:{};let data;const settings_remove_stream=$.data.read("zhihu_settings_moments_stream",false);const settings_remove_recommend=$.data.read("zhihu_settings_moments_recommend",false);const settings_remove_activity=$.data.read("zhihu_settings_moments_activity",false);const settings_blocked_users=$.data.read("zhihu_settings_blocked_users",false);data=obj.data.filter(item=>{const isBlackUserPin=settings_blocked_users&&item.target&&item.target["origin_pin"]&&item.target["origin_pin"].author&&typeof customBlockedUsers[item.target["origin_pin"].author.name]!="undefined";const isStream=settings_remove_stream&&item["target_type"]==="zvideo";const isRecommend=settings_remove_recommend&&item.type==="recommend_user_card_list";const isActivity=settings_remove_activity&&item.type==="message_activity_card";return!(isBlackUserPin||isStream||isRecommend||isActivity)});obj["data"]=data;response={body:JSON.stringify(obj)}}catch(err){$.logger.error(`关注列表去广告出现异常:${err}`)}return response}function _setRecommendTag(item,text,color="GBK02A"){if(!item["common_card"]["footline"]){item["common_card"]["footline"]={elements:[]}}item["common_card"]["footline"]["elements"].unshift({tag:{text:text,color:color,type:"MASK_ROUNDED_RECTANGLE"}})}async function _checkPaidContentByCloud(filteredUrls,newData){const zheyeServer=$.data.read(zheyeServerKey);if(!zheyeServer){$.notification.post("未设置服务端地址,无法进行付费/推广内容探测。\n请配置服务端地址,或使用本地探测。")}else{$.logger.debug(`向云端请求以下链接\n${filteredUrls.join("\n")}`);const url=`${zheyeServer}/api/v1/answer/links`;$.logger.debug(`服务端地址\n${url}`);await $.http.post({url:url,headers:{"Content-Type":"application/json"},body:filteredUrls}).then(resp=>{$.logger.debug(`云端探测结果<${typeof resp.body}>\n${JSON.stringify(resp.body)}`);for(let i=0;i{$.logger.error(`云端请求出现异常\n${JSON.stringify(err)}`)})}}async function _checkPaidContentByLocal(filteredUrls,newData){$.logger.debug(`将在本地请求以下链接\n${filteredUrls.join("\n")}`);let requestPromise=[];function _requestAnswerContent(i){return new Promise(resolve=>{const url=filteredUrls[i];if(!url||url===""||!url.startsWith("https://www.zhihu.com/appview/v2/answer")){resolve("")}else{$.http.get({url:filteredUrls[i],timeout:1e3}).then(resp=>{const body=resp.body;if((body.indexOf("查看完整内容")>=0||body.indexOf("查看全部章节")>=0)&&body.indexOf("paid")>=0){resolve("付费内容")}else if(body.indexOf("ad-link-card")>=0||body.indexOf("xg.zhihu.com")>=0||body.indexOf("营销平台")>=0){resolve("营销推广")}else if(body.indexOf("mcn-link-card")>=0){resolve("购物推广")}else{resolve("")}}).catch(err=>{$.logger.error(`本地请求出现异常\n${JSON.stringify(err)}`);resolve("")})}})}for(let i=0;i{$.logger.debug(`本地探测结果<${result.length}>\n${JSON.stringify(result)}`);for(let i=0;i{const elementStr=JSON.stringify(element);const isAd=element["card_type"]==="slot_event_card"||element["card_type"]==="slot_video_event_card"||element.hasOwnProperty("ad")||element["brief"]&&element["brief"].indexOf("slot_card")>=0||element["extra"]&&element["extra"]["type"]==="Training";const isStream=isAd!==true&&elementStr.search(/"(type|style)+"\s?:\s?"(drama|zvideo|Video|BIG_IMAGE)+"/i)>=0;const removeStream=isStream&&settings_recommend_stream;const isPin=isStream!==true&&elementStr.search(/"(type|style)+"\s?:\s?"pin"/i)>=0;const removePin=isPin&&settings_remove_pin;const isArticle=elementStr.search(/"(type|style)+"\s?:\s?"article"/i)>=0;const removeArticle=isArticle&&settings_remove_article;let matchKeyword=false;if(isStream!==true&&settings_blocked_keywords){for(let i=0;i=0){if($.isDebug){let elementTitle=element["common_card"]["feed_content"]["title"]["panel_text"];let elementContent=element["common_card"]["feed_content"]["content"]["panel_text"];let actionUrl="";try{actionUrl=element["common_card"]["feed_content"]["title"]["action"]["intent_url"]}catch{}$.logger.debug(`匹配关键字:\n${keywords[i]}\n标题:\n${elementTitle}\n内容:\n${elementContent}`);$.notification.debug(scriptName,`关键字:${keywords[i]}`,`${elementTitle}\n${elementContent}`,actionUrl)}matchKeyword=true;break}}}let isBlockedUser;try{isBlockedUser=matchKeyword!==true&&settings_blocked_users&&customBlockedUsers&&element["common_card"]["feed_content"]["source_line"]["elements"][1]["text"]["panel_text"]in customBlockedUsers}catch{isBlockedUser=false}return!(isAd||removePin||removeArticle||removeStream||matchKeyword||isBlockedUser)};let obj=JSON.parse($.response.body.replace(/(\w+"+\s?):\s?(\d{15,})/g,'$1:"$2"'));let newData=obj["data"].filter(dataFilter);if(settings_check_paid_content===true){let filteredUrls=[];for(let i=0;i0&&settings_request_content==="cloud"){await _checkPaidContentByCloud(filteredUrls,newData)}else if(filteredUrls.length>0&&settings_request_content==="local"){await _checkPaidContentByLocal(filteredUrls,newData)}}obj["data"]=newData;response={body:JSON.stringify(obj)}}catch(err){$.logger.error(`推荐列表去广告出现异常:${err}`)}return response}function removeQuestions(){let response=null;try{const userInfo=getUserInfo();let customBlockedUsers=$.data.read(blockedUsersKey,"",userInfo.id);customBlockedUsers=!!customBlockedUsers?customBlockedUsers:{};let obj=JSON.parse($.response.body);const settingsBlockedUsers=$.data.read("zhihu_settings_blocked_users",false);$.logger.debug(`当前黑名单列表: ${JSON.stringify(customBlockedUsers)}`);let blackUserAnswersId=$.data.read(blackAnswersIdKey,[]);delete obj["ad_info"];if(obj["data"]){let newData=[];for(let element of obj.data){let blackUserName="";const answerId=element.target.id.toString();try{if("target"in element){blackUserName=element["target"]["author"]["name"]}}catch(ex){$.logger.error(`获取回答列表用户名出现异常:${ex}`)}const isBlackUser=typeof customBlockedUsers[blackUserName]!="undefined";const removeBlackUserAnswer=settingsBlockedUsers&&isBlackUser;if("target"in element){element["target"]["visible_only_to_author"]=false;element["target"]["is_visible"]=true;element["target"]["is_copyable"]=true}if(!removeBlackUserAnswer){newData.push(element)}else if(removeBlackUserAnswer===true&&blackUserAnswersId.includes(answerId)===false){blackUserAnswersId.push(answerId);$.notification.debug(`记录黑名单用户${blackUserName}的回答Id:${answerId}`)}}obj.data=newData}$.data.write(blackAnswersIdKey,blackUserAnswersId);const body=JSON.stringify(obj);$.logger.debug(`修改后的回答列表数据:${body}`);response={body:body}}catch(err){$.logger.error(`回答列表去广告出现异常:${err}`)}return response}function modifyAnswer(){let response=null;try{let html=$.response.body;let insertText="";if((html.indexOf("查看完整内容")>=0||html.indexOf("查看全部章节")>=0)&&html.indexOf("paid")>=0){insertText='
本文为付费内容
'}else if(html.indexOf("ad-link-card")>=0||html.indexOf("xg.zhihu.com")>=0||html.indexOf("营销平台")>=0){insertText='
本文含有营销推广
'}else if(html.indexOf("mcn-link-card")>=0){insertText='
本文含有购物推广
'}else if(Math.floor(Math.random()*200)===7){insertText='
本文为免费内容
'}if(insertText!==""){const matchStr=html.match(/(richText[^<]*>)(.)/)[1];const start=html.lastIndexOf(matchStr)+matchStr.length;response={body:html.slice(0,start)+insertText+html.slice(start)}}}catch(err){$.logger.error(`付费内容提醒出现异常:${err}`)}return response}function removeComment(){let response=null;try{if(!!$.response.body){let obj=JSON.parse($.response.body);obj["ad_info"]={};if($.data.read("zhihu_settings_blocked_users",false)===true){let user_info=getUserInfo();let customBlockedUsers=$.data.read(blockedUsersKey,"",user_info.id);customBlockedUsers=!!customBlockedUsers?customBlockedUsers:{};let newComments=[];let blockCommentIdObj={};if(typeof obj.root!="undefined"){const rootUserName=obj.root.author.name;const isBlackRootUser=typeof customBlockedUsers[rootUserName]!="undefined";if(isBlackRootUser===true){obj.root.is_delete=true;obj.root.can_reply=false;obj.root.can_like=false;obj.root.author.name="黑名单用户";obj.root.author.avatar_url="https://picx.zhimg.com/v2-abed1a8c04700ba7d72b45195223e0ff_xll.jpg"}}if(typeof obj.data!="undefined"){obj.data.forEach(comment=>{const commentUserName=comment.author.name;let replyUserName="";if(comment["reply_to_author"]&&comment["reply_to_author"].name){replyUserName=comment["reply_to_author"].name}const isSubComment=replyUserName!=="";const isBlackCommentUser=typeof customBlockedUsers[commentUserName]!="undefined";const isBlackReplyUser=typeof customBlockedUsers[replyUserName]!="undefined";if(isBlackCommentUser===true||isBlackReplyUser===true){if(isBlackCommentUser&&!isSubComment&&$.request.url.indexOf("root_comment")>0){$.notification.debug(`屏蔽黑名单用户“${commentUserName}”的主评论。`)}else if(!isBlackCommentUser&&isSubComment&&!isBlackReplyUser&&$.request.url.indexOf("child_comment")>0){$.notification.debug(`屏蔽黑名单用户“${commentUserName}”的子评论。`)}else if(isBlackCommentUser&&!isBlackReplyUser&&$.request.url.indexOf("child_comment")>0){$.notification.debug(`屏蔽黑名单用户“${commentUserName}”回复“${replyUserName}”的子评论。`)}else if(isBlackCommentUser&&isBlackReplyUser&&$.request.url.indexOf("child_comment")>0){$.notification.debug(`屏蔽黑名单用户“${commentUserName}”回复黑名单用户“${replyUserName}”的子评论。`)}blockCommentIdObj[comment.id]=commentUserName;if(isBlackCommentUser){comment.is_delete=true;comment.can_reply=false;comment.can_like=false;comment.author.exposed_medal={};comment.author.name="[黑名单用户]";comment.author.avatar_url="https://picx.zhimg.com/v2-abed1a8c04700ba7d72b45195223e0ff_xll.jpg"}if(isBlackReplyUser){comment["reply_to_author"].name="[黑名单用户]";comment["reply_to_author"].exposed_medal={};comment["reply_to_author"].avatar_url="https://picx.zhimg.com/v2-abed1a8c04700ba7d72b45195223e0ff_xll.jpg"}}if(comment.child_comments){let newChildComments=[];comment.child_comments.forEach(childComment=>{const childCommentUserName=childComment.author.name;const childCommentReplyUserName=typeof childComment["reply_to_author"]!="undefined"?childComment["reply_to_author"].name:"";const isChildBlackCommentUser=typeof customBlockedUsers[childCommentUserName]!="undefined";const isChildBlackReplyUser=typeof customBlockedUsers[childCommentReplyUserName]!="undefined";if(isChildBlackCommentUser||isChildBlackReplyUser){if(isChildBlackCommentUser===true){$.notification.debug(`屏蔽黑名单用户“${childCommentUserName}”的子评论。`);blockCommentIdObj[childComment.id]=childCommentUserName;childComment.is_delete=true;childComment.can_reply=false;childComment.can_like=false;childComment.author.name="[黑名单用户]";childComment.author.exposed_medal={};childComment.author.avatar_url="https://picx.zhimg.com/v2-abed1a8c04700ba7d72b45195223e0ff_xll.jpg"}if(isChildBlackReplyUser===true){$.logger.debug(`修改前的子评论数据:\n${JSON.stringify(childComment)}`);childComment["reply_to_author"].name="[黑名单用户]";childComment["reply_to_author"].exposed_medal={};childComment["reply_to_author"].avatar_url="https://picx.zhimg.com/v2-abed1a8c04700ba7d72b45195223e0ff_xll.jpg";$.notification.debug(`隐藏“${childCommentUserName}”回复黑名单用户“${childCommentReplyUserName}”的名称与头像。`);$.logger.debug(`修改后的子评论数据:\n${JSON.stringify(childComment)}`)}}newChildComments.push(childComment)});comment.child_comments=newChildComments}newComments.push(comment)})}obj.data=newComments}const body=JSON.stringify(obj);$.logger.debug(`过滤后的评论数据:\n${body}`);response={body:body}}}catch(err){$.logger.error(`去除评论广告出现异常:${err}`)}return response}function removeArticleAd(){let response=null;try{if(!!$.response.body){let obj=JSON.parse($.response.body);obj["ad_info"]={};const body=JSON.stringify(obj);$.logger.debug(`过滤后的文章数据:\n${body}`);response={body:body}}}catch(err){$.logger.error(`去除文章广告出现异常:${err}`)}return response}function removeMarketingMsg(){let response=null;try{let obj=JSON.parse($.response.body);let newItems=[];for(let item of obj["data"]){if(item["detail_title"]==="官方帐号消息"){let unread_count=item["unread_count"];if(unread_count>0){item["content"]["text"]="未读消息"+unread_count+"条"}else{item["content"]["text"]="全部消息已读"}item["is_read"]=true;item["unread_count"]=0;newItems.push(item)}else if(item["detail_title"]!=="活动助手"){newItems.push(item)}}obj["data"]=newItems;response={body:JSON.stringify(obj)}}catch(err){$.logger.error(`屏蔽官方营销消息出现异常:${err}`)}return response}function removeHotListAds(){let response=null;try{if(!!$.response.body){let obj=JSON.parse($.response.body);if("data"in obj){obj["data"]=obj["data"].filter(e=>{return e["type"]==="hot_list_feed"||e["type"]==="hot_list_feed_video"})}response={body:JSON.stringify(obj)}}}catch(err){$.logger.error(`去除热榜广告出现异常:${err}`)}return response}function removeKeywordAds(){let response=null;try{if(!!$.response.body){$.logger.debug(`预置关键字返回:${$.response.body}`);let obj=JSON.parse($.response.body);if(obj.hasOwnProperty("preset_words")&&obj["preset_words"]["words"]){obj["preset_words"]["words"]=obj["preset_words"]["words"].filter(element=>{return element["type"]!=="ad"});response={body:JSON.stringify(obj)}}}}catch(err){$.logger.error(`去除预置关键字广告出现异常:${err}`)}return response}function removeNextBlackUserAnswer(){let response=null;try{if(!!$.response.body){let obj=JSON.parse($.response.body);const blackUserAnswersId=$.data.read(blackAnswersIdKey,[]);if(blackUserAnswersId.length>0){let newData=[];obj.data.forEach(element=>{const tag=blackUserAnswersId.includes(element.id.toString());if(tag===false){element.ad_info={data:""};newData.push(element)}else{$.notification.debug(`屏蔽翻页过程中出现的黑名单用户回答Id:${element.id}`)}});for(let i=0;i{const isAd=element["resource_type"]==="ad"||element["extra"]["recommend_start"]===true||element["next_guide"]["change_type"]===1||element["next_guide"]["title"]==="推荐的相关内容";if(isAd===true){return}element["ad_info"]={data:""};const isBlackUser=typeof customBlockedUsers[element.data.author.name]!="undefined";$.logger.debug(`用户${element.data.author.name}是否在黑名单中:${isBlackUser}`);if($.data.read("zhihu_settings_blocked_users",false)===false||isBlackUser===false){newData.push(element)}});obj.data.data=newData;response={body:JSON.stringify(obj)}}}catch(err){$.logger.error(`屏蔽回答信息流黑名单用户及广告:${err}`)}return response}function modifyAnswersNextBff(){let response=null;try{if(!!$.response.body){let obj=JSON.parse($.response.body);let user_info=getUserInfo();let customBlockedUsers=$.data.read(blockedUsersKey,{},user_info.id);$.logger.debug(`脚本黑名单用户:\n${JSON.stringify(customBlockedUsers)}`);let newData=[];obj.data.forEach(element=>{const isAd=element["origin_data"]["resource_type"]!=="normal";if(isAd===true){return}element["origin_data"]["ad_info"]={data:""};const authorName=element["origin_data"]["data"]["author"]["name"];const isBlackUser=typeof customBlockedUsers[authorName]!="undefined";$.logger.debug(`用户${authorName}是否在黑名单中:${isBlackUser}`);if($.data.read("zhihu_settings_blocked_users",false)===false||isBlackUser===false){newData.push(element)}});obj.data=newData;response={body:JSON.stringify(obj)}}}catch(err){$.logger.error(`屏蔽回答信息流黑名单用户及广告:${err}`)}return response}function modifyAnswersNextRender(){let response=null;try{if(!!$.response.body){let obj=JSON.parse($.response.body);let user_info=getUserInfo();let customBlockedUsers=$.data.read(blockedUsersKey,{},user_info.id);$.logger.debug(`脚本黑名单用户:\n${JSON.stringify(customBlockedUsers)}`);let newData=[];obj.data.forEach(element=>{const isAd=element["ad_info"]&&element["ad_info"]["data"]!==""||element["biz_type_list"]&&element["biz_type_list"].length!==1||element["biz_type_list"]&&element["biz_type_list"][0]!=="answer"||element["type"]==="ad";if(isAd===true){return}const authorName=element["author"]["fullname"];const isBlackUser=typeof customBlockedUsers[authorName]!="undefined";$.logger.debug(`用户${authorName}是否在黑名单中:${isBlackUser}`);if($.data.read("zhihu_settings_blocked_users",false)===false||isBlackUser===false){newData.push(element)}});obj.data=newData;response={body:JSON.stringify(obj)}}}catch(err){$.logger.error(`屏蔽回答信息流黑名单用户及广告:${err}`)}return response}function changeUserCredit(){$.notification.debug("开始修改用户盐值");let response=null;try{if(!!$.response.body){const score=parseInt($.data.read(userCreditScoreKey,780));$.logger.debug(`准备修改用户盐值为${score}`);let obj=JSON.parse($.response.body);if(obj["credit_basis"].total_score{let response=null;if($.isResponse){switch(true){case/^https:\/\/api\.zhihu\.com\/people\/self$/.test($.request.url):response=processUserInfo();break;case $.data.read("zhihu_settings_app_conf",false)===true&&/^https?:\/\/appcloud2\.zhihu\.com\/v\d+\/config/.test($.request.url):response=modifyAppConfig();break;case $.data.read("zhihu_settings_app_conf",false)===true&&/^https?:\/\/m-cloud\.zhihu\.com\/api\/cloud\/config\/all\?/.test($.request.url):response=modifyMCloudConfig();break;case/^https?:\/\/api\.zhihu\.com\/user-credit\/basis/.test($.request.url):response=changeUserCredit();break;case/^https:\/\/api\.zhihu\.com\/topstory\/recommend/.test($.request.url):response=await removeRecommend();break;case/^https?:\/\/api\.zhihu\.com\/(v4\/)?questions\/\d+/.test($.request.url):response=removeQuestions();break;case/^https?:\/\/api\.zhihu\.com\/next-data\?/.test($.request.url):response=modifyAnswersNextData();break;case/^https?:\/\/api\.zhihu\.com\/next-bff\?/.test($.request.url):response=modifyAnswersNextBff();break;case/^https?:\/\/api\.zhihu\.com\/next-render\?/.test($.request.url):response=modifyAnswersNextRender();break;case $.data.read("zhihu_settings_sys_msg",true)!==false&&/^https?:\/\/api\.zhihu\.com\/notifications\/v3\/message/.test($.request.url):response=removeMarketingMsg();break;case/^https?:\/\/api\.zhihu\.com\/comment_v5\/(answers|pins|comments?|articles)\/\d+\/(root|child)_comment/.test($.request.url):response=removeComment();break;case/^https?:\/\/www\.zhihu\.com\/api\/v\d\/articles\/\d+\/recommendation\?/.test($.request.url):response=removeArticleAd();break;case/^https?:\/\/www\.zhihu\.com\/api\/v4\/comment_v5\/answers\/\d+\/abstract_comment\?/.test($.request.url):response=removeComment();break;case $.data.read("zhihu_settings_answer_tip",true)===true&&/^https?:\/\/www\.zhihu\.com\/appview\/v2\/answer\/.*(entry=(?!(preload-topstory|preload-search|preload-subscription)))?/.test($.request.url):response=modifyAnswer();break;case $.data.read("zhihu_settings_blocked_users",false)!==false&&/^https?:\/\/api\.zhihu\.com\/next\?/.test($.request.url):response=removeNextBlackUserAnswer();break;case $.data.read("zhihu_settings_blocked_users",true)===true&&/^https?:\/\/api\.zhihu\.com\/people\/((?!self).)*$/.test($.request.url):response=autoInsertBlackList();break;case/^https?:\/\/api\.zhihu\.com\/moments_v3\?/.test($.request.url):response=removeMoments();break;case $.data.read("zhihu_settings_hot_list",true)===true&&/^https?:\/\/api\.zhihu\.com\/topstory\/hot-lists(\?|\/)/.test($.request.url):response=removeHotListAds();break;case $.data.read("zhihu_settings_preset_words",true)===true&&/^https?:\/\/api\.zhihu\.com\/search\/preset_words\?/.test($.request.url):response=removeKeywordAds();break;case $.data.read("zhihu_settings_blocked_users",false)!==false&&/^https?:\/\/api\.zhihu\.com\/settings\/blocked_users/.test($.request.url):manageBlackUser();break;default:$.logger.debug("没有匹配到任何请求,请确认配置正确。");break}}else if($.isRequest){if($.data.read("zhihu_settings_blocked_keywords",false)!==false&&/^https?:\/\/api\.zhihu\.com\/feed-root\/block/.test($.request.url)===true){response=unlockBlockedKeywords(response)}}else{$.data.del(currentUserInfoKey);$.data.del(blockedUsersKey);$.data.del(keywordBlockKey);$.notification.post("哲也同学数据清理完毕")}if(response){$.done(response)}else{$.done()}})();function MagicJS(scriptName="MagicJS",logLevel="INFO"){const MagicEnvironment=()=>{const isLoon=typeof $loon!=="undefined";const isQuanX=typeof $task!=="undefined";const isNode=typeof module!=="undefined";const isSurge=typeof $httpClient!=="undefined"&&!isLoon;const isStorm=typeof $storm!=="undefined";const isStash=typeof $environment!=="undefined"&&typeof $environment["stash-build"]!=="undefined";const isSurgeLike=isSurge||isLoon||isStorm||isStash;const isScriptable=typeof importModule!=="undefined";return{isLoon:isLoon,isQuanX:isQuanX,isNode:isNode,isSurge:isSurge,isStorm:isStorm,isStash:isStash,isSurgeLike:isSurgeLike,isScriptable:isScriptable,get name(){if(isLoon){return"Loon"}else if(isQuanX){return"QuantumultX"}else if(isNode){return"NodeJS"}else if(isSurge){return"Surge"}else if(isScriptable){return"Scriptable"}else{return"unknown"}},get build(){if(isSurge){return $environment["surge-build"]}else if(isStash){return $environment["stash-build"]}else if(isStorm){return $storm.buildVersion}},get language(){if(isSurge||isStash){return $environment["language"]}},get version(){if(isSurge){return $environment["surge-version"]}else if(isStash){return $environment["stash-version"]}else if(isStorm){return $storm.appVersion}else if(isNode){return process.version}},get system(){if(isSurge){return $environment["system"]}else if(isNode){return process.platform}},get systemVersion(){if(isStorm){return $storm.systemVersion}},get deviceName(){if(isStorm){return $storm.deviceName}}}};const MagicLogger=(scriptName,logLevel="INFO")=>{let _level=logLevel;const logLevels={SNIFFER:6,DEBUG:5,INFO:4,NOTIFY:3,WARNING:2,ERROR:1,CRITICAL:0,NONE:-1};const logEmoji={SNIFFER:"",DEBUG:"",INFO:"",NOTIFY:"",WARNING:"❗ ",ERROR:"❌ ",CRITICAL:"❌ ",NONE:""};const _log=(msg,level="INFO")=>{if(!(logLevels[_level]{_level=logLevel};return{getLevel:()=>{return _level},setLevel:setLevel,sniffer:msg=>{_log(msg,"SNIFFER")},debug:msg=>{_log(msg,"DEBUG")},info:msg=>{_log(msg,"INFO")},notify:msg=>{_log(msg,"NOTIFY")},warning:msg=>{_log(msg,"WARNING")},error:msg=>{_log(msg,"ERROR")},retry:msg=>{_log(msg,"RETRY")}}};return new class{constructor(scriptName,logLevel){this._startTime=Date.now();this.version="3.0.0";this.scriptName=scriptName;this.env=MagicEnvironment();this.logger=MagicLogger(scriptName,logLevel);this.http=typeof MagicHttp==="function"?MagicHttp(this.env,this.logger):undefined;this.data=typeof MagicData==="function"?MagicData(this.env,this.logger):undefined;this.notification=typeof MagicNotification==="function"?MagicNotification(this.scriptName,this.env,this.logger,this.http):undefined;this.utils=typeof MagicUtils==="function"?MagicUtils(this.env,this.logger):undefined;this.qinglong=typeof MagicQingLong==="function"?MagicQingLong(this.env,this.data,this.logger):undefined;if(typeof this.data!=="undefined"){let magicLoglevel=this.data.read("magic_loglevel");const barkUrl=this.data.read("magic_bark_url");if(magicLoglevel){this.logger.setLevel(magicLoglevel.toUpperCase())}if(barkUrl){this.notification.setBark(barkUrl)}}}get isRequest(){return typeof $request!=="undefined"&&typeof $response==="undefined"}get isResponse(){return typeof $response!=="undefined"}get isDebug(){return this.logger.level==="DEBUG"}get request(){return typeof $request!=="undefined"?$request:undefined}get response(){if(typeof $response!=="undefined"){if($response.hasOwnProperty("status"))$response["statusCode"]=$response["status"];if($response.hasOwnProperty("statusCode"))$response["status"]=$response["statusCode"];return $response}else{return undefined}}done=(value={})=>{this._endTime=Date.now();let span=(this._endTime-this._startTime)/1e3;this.logger.info(`SCRIPT COMPLETED: ${span} S.`);if(typeof $done!=="undefined"){$done(value)}}}(scriptName,logLevel)}function MagicNotification(scriptName,env,logger,http){let _barkUrl=null;let _barkKey=null;const setBark=url=>{try{let _url=url.replace(/\/+$/g,"");_barkUrl=`${/^https?:\/\/([^/]*)/.exec(_url)[0]}/push`;_barkKey=/\/([^\/]+)\/?$/.exec(_url)[1]}catch(ex){logger.error(`Bark url error: ${ex}.`)}};function post(title=scriptName,subTitle="",body="",opts=""){const _adaptOpts=_opts=>{try{let newOpts={};if(typeof _opts==="string"){if(env.isLoon)newOpts={openUrl:_opts};else if(env.isQuanX)newOpts={"open-url":_opts};else if(env.isSurge)newOpts={url:_opts}}else if(typeof _opts==="object"){if(env.isLoon){newOpts["openUrl"]=!!_opts["open-url"]?_opts["open-url"]:"";newOpts["mediaUrl"]=!!_opts["media-url"]?_opts["media-url"]:""}else if(env.isQuanX){newOpts=!!_opts["open-url"]||!!_opts["media-url"]?_opts:{}}else if(env.isSurge){let openUrl=_opts["open-url"]||_opts["openUrl"];newOpts=openUrl?{url:openUrl}:{}}}return newOpts}catch(err){logger.error(`通知选项转换失败${err}`)}return _opts};opts=_adaptOpts(opts);if(arguments.length===1){title=scriptName;subTitle="",body=arguments[0]}logger.notify(`title:${title}\nsubTitle:${subTitle}\nbody:${body}\noptions:${typeof opts==="object"?JSON.stringify(opts):opts}`);if(env.isSurge){$notification.post(title,subTitle,body,opts)}else if(env.isLoon){if(!!opts)$notification.post(title,subTitle,body,opts);else $notification.post(title,subTitle,body)}else if(env.isQuanX){$notify(title,subTitle,body,opts)}if(_barkUrl&&_barkKey){bark(title,subTitle,body)}}function debug(title=scriptName,subTitle="",body="",opts=""){if(logger.getLevel()==="DEBUG"){if(arguments.length===1){title=scriptName;subTitle="";body=arguments[0]}this.post(title,subTitle,body,opts)}}function bark(title=scriptName,subTitle="",body="",opts=""){if(typeof http==="undefined"||typeof http.post==="undefined"){throw"Bark notification needs to import MagicHttp module."}let options={url:_barkUrl,headers:{"content-type":"application/json; charset=utf-8"},body:{title:title,body:subTitle?`${subTitle}\n${body}`:body,device_key:_barkKey}};http.post(options).catch(ex=>{logger.error(`Bark notify error: ${ex}`)})}return{post:post,debug:debug,bark:bark,setBark:setBark}}function MagicData(env,logger){let node={fs:undefined,data:{}};if(env.isNode){node.fs=require("fs");try{node.fs.accessSync("./magic.json",node.fs.constants.R_OK|node.fs.constants.W_OK)}catch(err){node.fs.writeFileSync("./magic.json","{}",{encoding:"utf8"})}node.data=require("./magic.json")}const defaultValueComparator=(oldVal,newVal)=>{if(typeof newVal==="object"){return false}else{return oldVal===newVal}};const _typeConvertor=val=>{if(val==="true"){return true}else if(val==="false"){return false}else if(typeof val==="undefined"){return null}else{return val}};const _valConvertor=(val,default_,session,read_no_session)=>{if(session){try{if(typeof val==="string")val=JSON.parse(val);if(val["magic_session"]===true){val=val[session]}else{val=null}}catch{val=null}}if(typeof val==="string"&&val!=="null"){try{val=JSON.parse(val)}catch{}}if(read_no_session===false&&!!val&&val["magic_session"]===true){val=null}if((val===null||typeof val==="undefined")&&default_!==null&&typeof default_!=="undefined"){val=default_}val=_typeConvertor(val);return val};const convertToObject=obj=>{if(typeof obj==="string"){let data={};try{data=JSON.parse(obj);const type=typeof data;if(type!=="object"||data instanceof Array||type==="bool"||data===null){data={}}}catch{}return data}else if(obj instanceof Array||obj===null||typeof obj==="undefined"||obj!==obj||typeof obj==="boolean"){return{}}else{return obj}};const readForNode=(key,default_=null,session="",read_no_session=false,externalData=null)=>{let data=externalData||node.data;if(!!data&&typeof data[key]!=="undefined"&&data[key]!==null){val=data[key]}else{val=!!session?{}:null}val=_valConvertor(val,default_,session,read_no_session);return val};const read=(key,default_=null,session="",read_no_session=false,externalData=null)=>{let val="";if(externalData||env.isNode){val=readForNode(key,default_,session,read_no_session,externalData)}else{if(env.isSurgeLike){val=$persistentStore.read(key)}else if(env.isQuanX){val=$prefs.valueForKey(key)}val=_valConvertor(val,default_,session,read_no_session)}logger.debug(`READ DATA [${key}]${!!session?`[${session}]`:""} <${typeof val}>\n${JSON.stringify(val)}`);return val};const writeForNode=(key,val,session="",externalData=null)=>{let data=externalData||node.data;data=convertToObject(data);if(!!session){let obj=convertToObject(data[key]);obj["magic_session"]=true;obj[session]=val;data[key]=obj}else{data[key]=val}if(externalData!==null){externalData=data}return data};const write=(key,val,session="",externalData=null)=>{if(typeof val==="undefined"||val!==val){return false}if(!env.isNode&&(typeof val==="boolean"||typeof val==="number")){val=String(val)}let data="";if(externalData||env.isNode){data=writeForNode(key,val,session,externalData)}else{if(!session){data=val}else{if(env.isSurgeLike){data=!!$persistentStore.read(key)?$persistentStore.read(key):data}else if(env.isQuanX){data=!!$prefs.valueForKey(key)?$prefs.valueForKey(key):data}data=convertToObject(data);data["magic_session"]=true;data[session]=val}}if(!!data&&typeof data==="object"){data=JSON.stringify(data,null,4)}logger.debug(`WRITE DATA [${key}]${session?`[${session}]`:""} <${typeof val}>\n${JSON.stringify(val)}`);if(!externalData){if(env.isSurgeLike){return $persistentStore.write(data,key)}else if(env.isQuanX){return $prefs.setValueForKey(data,key)}else if(env.isNode){try{node.fs.writeFileSync("./magic.json",data);return true}catch(err){logger.error(err);return false}}}return true};const update=(key,val,session,comparator=defaultValueComparator,externalData=null)=>{val=_typeConvertor(val);const oldValue=read(key,null,session,false,externalData);if(comparator(oldValue,val)===true){return false}else{const result=write(key,val,session,externalData);let newVal=read(key,null,session,false,externalData);if(comparator===defaultValueComparator&&typeof newVal==="object"){return result}return comparator(val,newVal)}};const delForNode=(key,session,externalData)=>{let data=externalData||node.data;data=convertToObject(data);if(!!session){obj=convertToObject(data[key]);delete obj[session];data[key]=obj}else{delete data[key]}if(!!externalData){externalData=data}return data};const del=(key,session="",externalData=null)=>{let data={};if(externalData||env.isNode){data=delForNode(key,session,externalData);if(!externalData){node.fs.writeFileSync("./magic.json",JSON.stringify(data,null,4))}else{externalData=data}}else{if(!session){if(env.isStorm){return $persistentStore.remove(key)}else if(env.isSurgeLike){return $persistentStore.write(null,key)}else if(env.isQuanX){return $prefs.removeValueForKey(key)}}else{if(env.isSurgeLike){data=$persistentStore.read(key)}else if(env.isQuanX){data=$prefs.valueForKey(key)}data=convertToObject(data);delete data[session];const json=JSON.stringify(data,null,4);write(key,json)}}logger.debug(`DELETE KEY [${key}]${!!session?`[${session}]`:""}`)};const allSessionNames=(key,externalData=null)=>{let _sessions=[];let data=read(key,null,null,true,externalData);data=convertToObject(data);if(data["magic_session"]!==true){_sessions=[]}else{_sessions=Object.keys(data).filter(key=>key!=="magic_session")}logger.debug(`READ ALL SESSIONS [${key}] <${typeof _sessions}>\n${JSON.stringify(_sessions,null,4)}`);return _sessions};const allSessions=(key,externalData=null)=>{let _sessions={};let data=read(key,null,null,true,externalData);data=convertToObject(data);if(data["magic_session"]===true){_sessions={...data};delete _sessions["magic_session"]}logger.debug(`READ ALL SESSIONS [${key}] <${typeof _sessions}>\n${JSON.stringify(_sessions,null,4)}`);return _sessions};return{read:read,write:write,del:del,update:update,allSessions:allSessions,allSessionNames:allSessionNames,defaultValueComparator:defaultValueComparator,convertToObject:convertToObject}}function MagicHttp(env,logger){let axiosInstance;if(env.isNode){const axios=require("axios");axiosInstance=axios.create()}class InterceptorManager{constructor(isRequest=true){this.handlers=[];this.isRequest=isRequest}use(fulfilled,rejected,options){if(typeof fulfilled==="function"){logger.debug(`Register fulfilled ${fulfilled.name}`)}if(typeof rejected==="function"){logger.debug(`Register rejected ${rejected.name}`)}this.handlers.push({fulfilled:fulfilled,rejected:rejected,synchronous:options&&typeof options.synchronous==="boolean"?options.synchronous:false,runWhen:options?options.runWhen:null});return this.handlers.length-1}eject(id){if(this.handlers[id]){this.handlers[id]=null}}forEach(fn){this.handlers.forEach(element=>{if(element!==null){fn(element)}})}}function paramsToQueryString(config){let _config={...config};if(!!_config.params){if(!env.isNode){let qs=Object.keys(_config.params).map(key=>{const encodeKey=encodeURIComponent(key);_config.url=_config.url.replace(new RegExp(`${key}=[^&]*`,"ig"),"");_config.url=_config.url.replace(new RegExp(`${encodeKey}=[^&]*`,"ig"),"");return`${encodeKey}=${encodeURIComponent(_config.params[key])}`}).join("&");if(_config.url.indexOf("?")<0)_config.url+="?";if(!/(&|\?)$/g.test(_config.url)){_config.url+="&"}_config.url+=qs;delete _config.params;logger.debug(`Params to QueryString: ${_config.url}`)}}return _config}const mergeConfig=(method,configOrUrl)=>{let config=typeof configOrUrl==="object"?{headers:{},...configOrUrl}:{url:configOrUrl,headers:{}};if(!config.method){config["method"]=method}config=paramsToQueryString(config);if(config["rewrite"]===true){if(env.isSurge){config.headers["X-Surge-Skip-Scripting"]=false;delete config["rewrite"]}else if(env.isQuanX){config["hints"]=false;delete config["rewrite"]}}if(env.isSurgeLike){const contentType=config.headers["content-type"]||config.headers["Content-Type"];if(config["method"]!=="GET"&&contentType&&contentType.indexOf("application/json")>=0&&config.body instanceof Array){config.body=JSON.stringify(config.body);logger.debug(`Convert Array object to String: ${config.body}`)}}else if(env.isQuanX){if(config.hasOwnProperty("body")&&typeof config["body"]!=="string")config["body"]=JSON.stringify(config["body"]);config["method"]=method}else if(env.isNode){if(method==="POST"||method==="PUT"||method==="PATCH"||method==="DELETE"){config.data=config.data||config.body}else if(method==="GET"){config.params=config.params||config.body}delete config.body}return config};const modifyResponse=(resp,config=null)=>{if(resp){let _resp={...resp,config:resp.config||config,status:resp.statusCode||resp.status,body:resp.body||resp.data,headers:resp.headers||resp.header};if(typeof _resp.body==="string"){try{_resp.body=JSON.parse(_resp.body)}catch{}}delete _resp.data;return _resp}else{return resp}};const convertHeadersToLowerCase=headers=>{return Object.keys(headers).reduce((acc,key)=>{acc[key.toLowerCase()]=headers[key];return acc},{})};const convertHeadersToCamelCase=headers=>{return Object.keys(headers).reduce((acc,key)=>{const newKey=key.split("-").map(word=>word[0].toUpperCase()+word.slice(1)).join("-");acc[newKey]=headers[key];return acc},{})};const raiseExceptionByStatusCode=(resp,config=null)=>{if(!!resp&&resp.status>=400){logger.debug(`Raise exception when status code is ${resp.status}`);return{name:"RequestException",message:`Request failed with status code ${resp.status}`,config:config||resp.config,response:resp}}};const interceptors={request:new InterceptorManager,response:new InterceptorManager(false)};let requestInterceptorChain=[];let responseInterceptorChain=[];let synchronousRequestInterceptors=true;function interceptConfig(config){config=paramsToQueryString(config);logger.debug(`HTTP ${config["method"].toUpperCase()}:\n${JSON.stringify(config)}`);return config}function interceptResponse(resp){try{resp=!!resp?modifyResponse(resp):resp;logger.sniffer(`HTTP ${resp.config["method"].toUpperCase()}:\n${JSON.stringify(resp.config)}\nSTATUS CODE:\n${resp.status}\nRESPONSE:\n${typeof resp.body==="object"?JSON.stringify(resp.body):resp.body}`);const err=raiseExceptionByStatusCode(resp);if(!!err){return Promise.reject(err)}return resp}catch(err){logger.error(err);return resp}}const registerInterceptors=config=>{try{requestInterceptorChain=[];responseInterceptorChain=[];interceptors.request.forEach(interceptor=>{if(typeof interceptor.runWhen==="function"&&interceptor.runWhen(config)===false){return}synchronousRequestInterceptors=synchronousRequestInterceptors&&interceptor.synchronous;requestInterceptorChain.unshift(interceptor.fulfilled,interceptor.rejected)});interceptors.response.forEach(interceptor=>{responseInterceptorChain.push(interceptor.fulfilled,interceptor.rejected)})}catch(err){logger.error(`Failed to register interceptors: ${err}.`)}};const request=(method,config)=>{let dispatchRequest;const _method=method.toUpperCase();config=mergeConfig(_method,config);if(env.isNode){dispatchRequest=axiosInstance}else{if(env.isSurgeLike){dispatchRequest=config=>{return new Promise((resolve,reject)=>{$httpClient[method.toLowerCase()](config,(err,resp,body)=>{if(err){let newErr={name:err.name||err,message:err.message||err,stack:err.stack||err,config:config,response:modifyResponse(resp)};reject(newErr)}else{resp.config=config;resp.body=body;resolve(resp)}})})}}else{dispatchRequest=config=>{return new Promise((resolve,reject)=>{$task.fetch(config).then(resp=>{resp=modifyResponse(resp,config);const err=raiseExceptionByStatusCode(resp,config);if(err){return Promise.reject(err)}resolve(resp)}).catch(err=>{let newErr={name:err.message||err.error,message:err.message||err.error,stack:err.error,config:config,response:!!err.response?modifyResponse(err.response):null};reject(newErr)})})}}}let promise;registerInterceptors(config);const defaultRequestInterceptors=[interceptConfig,undefined];const defaultResponseInterceptors=[interceptResponse,undefined];if(!synchronousRequestInterceptors){logger.debug("Interceptors are executed in asynchronous mode");let chain=[dispatchRequest,undefined];Array.prototype.unshift.apply(chain,defaultRequestInterceptors);Array.prototype.unshift.apply(chain,requestInterceptorChain);chain=chain.concat(defaultResponseInterceptors);chain=chain.concat(responseInterceptorChain);promise=Promise.resolve(config);while(chain.length){try{let onFulfilled=chain.shift();let onRejected=chain.shift();if(!env.isNode&&config["timeout"]&&onFulfilled===dispatchRequest){onFulfilled=requestTimeout}if(typeof onFulfilled==="function"){logger.debug(`Executing request fulfilled ${onFulfilled.name}`)}if(typeof onRejected==="function"){logger.debug(`Executing request rejected ${onRejected.name}`)}promise=promise.then(onFulfilled,onRejected)}catch(err){logger.error(`request exception: ${err}`)}}return promise}else{logger.debug("Interceptors are executed in synchronous mode");Array.prototype.unshift.apply(requestInterceptorChain,defaultRequestInterceptors);requestInterceptorChain=requestInterceptorChain.concat([interceptConfig,undefined]);while(requestInterceptorChain.length){let onFulfilled=requestInterceptorChain.shift();let onRejected=requestInterceptorChain.shift();try{if(typeof onFulfilled==="function"){logger.debug(`Executing request fulfilled ${onFulfilled.name}`)}config=onFulfilled(config)}catch(error){if(typeof onRejected==="function"){logger.debug(`Executing request rejected ${onRejected.name}`)}onRejected(error);break}}try{if(!env.isNode&&config["timeout"]){promise=requestTimeout(config)}else{promise=dispatchRequest(config)}}catch(err){return Promise.reject(err)}Array.prototype.unshift.apply(responseInterceptorChain,defaultResponseInterceptors);while(responseInterceptorChain.length){promise=promise.then(responseInterceptorChain.shift(),responseInterceptorChain.shift())}return promise}function requestTimeout(config){try{const timer=new Promise((_,reject)=>{setTimeout(()=>{let err={message:`timeout of ${config["timeout"]}ms exceeded.`,config:config};reject(err)},config["timeout"])});return Promise.race([dispatchRequest(config),timer])}catch(err){logger.error(`Request Timeout exception: ${err}.`)}}};return{request:request,interceptors:interceptors,convertHeadersToLowerCase:convertHeadersToLowerCase,convertHeadersToCamelCase:convertHeadersToCamelCase,modifyResponse:modifyResponse,get:configOrUrl=>{return request("GET",configOrUrl)},post:configOrUrl=>{return request("POST",configOrUrl)},put:configOrUrl=>{return request("PUT",configOrUrl)},patch:configOrUrl=>{return request("PATCH",configOrUrl)},delete:configOrUrl=>{return request("DELETE",configOrUrl)},head:configOrUrl=>{return request("HEAD",configOrUrl)},options:configOrUrl=>{return request("OPTIONS",configOrUrl)}}} \ No newline at end of file