检测微信小程序wx.createRewardedVideoAd视频激励广告跳过插件防止白嫖

检测微信小程序wx.createRewardedVideoAd视频激励广告跳过插件防止白嫖-1

前言

晓杰搞了几个小程序靠着广告微薄收入度日,没想到有一天发现了破解的微信居然有这个插件不得不说这个插件确NB,亲测小游戏啥的视频广告瞬秒结束!,晓杰就一直研究如何检测这个插件!
检测微信小程序wx.createRewardedVideoAd视频激励广告跳过插件防止白嫖-2

过程

通过小程序官方接口:https://developers.weixin.qq.com/minigame/dev/guide/open-abil…
检测微信小程序wx.createRewardedVideoAd视频激励广告跳过插件防止白嫖-3
经过调试发现使用了插件跳过广告:res.isEnded 这个是返回true 所以不能根据这个来判断是否使用了插件,那么晓杰就在想能不能根据播放时长判断呢?已知视频广告最小为6秒!
检测微信小程序wx.createRewardedVideoAd视频激励广告跳过插件防止白嫖-4
测试了多个生命周期函数后发现只有onLoad 和onClose符合检测要求,测试后利用插件跳过广告的播放时间只有0点几秒!那么代码就有了!

openVideoAd: function (a, t, o,k) {
    var that = this;
    wx.createRewardedVideoAd ? (wx.showLoading({
      title: "视频加载中"
    }), e && (e.offClose(), e.offError(), e.offLoad()), (e = wx.createRewardedVideoAd({
      adUnitId:that.data.jlgg?that.data.jlgg:"adunit-abe90b069e3ed62d"
    })).load().then((function () {
      wx.hideLoading(), e.onClose((function (e) {
//播放完毕后记录结束时间
        let end = Date.now();
        let time = (end - that.data.start) / 1000;
        console.info(time)
        if(time<4){
          //实现奖励
          return
        }
        e && e.isEnded ? a && a() : (t && t(), console.log("播放中途退出"))
      })), e.show()
    })).catch((function (a) {
      wx.hideLoading()
    })), e.onLoad((function () {
      wx.hideLoading(), console.log("video 视频加载成功")
//加载成功后记录开始时间
      var start = Date.now();
      console.info(start)
      that.setData({
        'start':start
      })
    })), e.onError((function (a) {
      wx.hideLoading(), o && o(), console.log(a)
    }))) : wx.showModal({
      title: "提示",
      content: "您的微信版本过低,不支持此功能,请升级。"
    })
  },

效果图

检测微信小程序wx.createRewardedVideoAd视频激励广告跳过插件防止白嫖-5

不知道为何增加了该检测代码后,微信广告官方审核一直说无法加载视频,不清楚是不是官方也用了跳出广告插件,那么只能做动态判断了,可以搞个参数动态获取 审核通过后再开启检测!

本文作者

Soujer 晓杰

原文

https://segmentfault.com/a/1190000044833365