Home

Issue: 1401

Why FuckAdBlock not working on client?

[issue link]

Hello. I am trying to use this plugin https://github.com/sitexw/FuckAdBlock

Without SSR/Nuxt it’s working, but I can’t set it with Nuxt. Can anybody help me? Here’s my final code:

<script>
if (process.browser) {
  require('fuckadblock')
}
// require('fuckadblock')
// import fuckAdBlock from 'fuckadblock'
// import 'fuckadblock'

export default {
  data () {
    return {
      status: ''
    }
  },
  mounted () {
    let fuckAdBlock
    var _this = this

    function adBlockNotDetected () {
      console.log('AdBlock is not enabled')
      _this.status = 'AdBlock is not enabled'
    }

    function adBlockDetected () {
      console.log('AdBlock is enabled')
      _this.status = 'AdBlock is enabled'
    }

    if (typeof fuckAdBlock === 'undefined') {
      adBlockDetected()
    } else {
      fuckAdBlock.onDetected(adBlockDetected)
      fuckAdBlock.onNotDetected(adBlockNotDetected)
    }

    fuckAdBlock.setOption({
      // debug: true,
      checkOnLoad: true,
      resetOnEnd: true
    })
  }
}
</script>
This question is available on Nuxt.js community (#c1245)