雪村葵 发表于 2024-4-25 23:57

能请教一下为什么这个去广告脚本没生效吗?

本帖最后由 雪村葵 于 2024-4-26 00:06 编辑

const targetUserAgent = 'Tachimanga';

if ($request?.headers?.['User-Agent']?.includes(targetUserAgent)) {
    console.log("Blocking request with User-Agent containing 'Tachimanga");
    $done({ response: { status: 403, body: 'Access denied' } });
} else {
    $done({});
}


IOS的Tachimanga总是会弹出广告,一开始我屏蔽掉了googleads.g.doubleclick.net,但是似乎没有完全解决问题。偶尔还是会有视频广告弹出来。所以想写个脚本去掉广告。

当HTTP请求里匹配上^https?:\/\/[\w-]+\.googlevideo\.com\/.+$ 就会执行上面的脚本。但是我的编码水平很菜,不懂js,虽然日志里打印了Blocking request with User-Agent containing 'Tachimanga,但是广告还是会正常播放,想知道怎么改这个脚本才能让去广告生效呢


页: [1]
查看完整版本: 能请教一下为什么这个去广告脚本没生效吗?