S
S
s_katala2019-01-22 13:04:56
React
s_katala, 2019-01-22 13:04:56

How to rewrite the react method?

There is a script that detects an ad blocker, how to rewrite it with the react method?

<script>
  $(function(){
  setTimeout(function() {
  var abcount = 0;
  var adblockActive = $.cookie('adblockActive');
  if (typeof $.ab == 'undefined' || $.ab === undefined) { $.ab = true; }
  if ($.ab == true) { abcount = abcount + 1; console.log("method 1"); }
  if( !$(".adblockDetect").is(":visible") ){ abcount = abcount + 1; console.log("method 2"); }
  if( window.gabchecker == "bingo" ){ abcount = abcount + 1; console.log("method 3"); }
  if( abcount == 3 ){
  if (adblockActive == undefined) {
  $.cookie('adblockActive', 1, { expires: 1, path: '/' });
  } else {
  $.cookie('adblockActive', parseInt(adblockActive) + 1, { expires: 1, path: '/' });
  }
  if (adblockActive > 1) {
  $("html").addClass("m-blurry");
  $(".b-feed-adblock").removeAttr("style");
  ga('send', 'event', 'adblock-blur', 'hit', 'adblock-warning');
  }
  console.log("adblock enabled");
  } else {
  if ($.cookie('adblockActive') != undefined) {
  $.removeCookie('adblockActive', { path: '/' });
  ga('send', 'event', 'adblock-blur', 'hit', 'adblock-turn-off');
  }
  console.log("adblock disabled");
  }
  console.log("abcount: " + abcount)
  }, 500);
  $("body").on("click", ".b-feed-adblock__buy", function(){
  ga('send', 'event', 'adblock-blur', 'click', 'button-buy');
  });
  $("body").on("click", ".b-feed-adblock__help", function(){
  ga('send', 'event', 'adblock-blur', 'click', 'button-help');
  });
  });
</script>

Answer the question

In order to leave comments, you need to log in

1 answer(s)
W
webe, 2019-01-22
@webe

https://medium.com/@hotdang_ca/how-i-wrote-a-react...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question