JSFiddle - React, Tailwind, and code Playground
HTML
<div id="wrapper">
</div>
JavaScript
$(document).ready(function () {
if ($("body").hasClass("on-ads") && $.cookie("locational_cookie") != null) {
debugger;
// Append back link
$("#wrapper").append('<p>Get to your <em><a href="' + $.cookie("locational_cookie") + '" target="_self">original destination</a></em>.</p>');
// Remove locational cookie
$.removeCookie('locational_cookie', {
path: '/'
});
// Set ads_checked cookie
$.cookie('ads_checked', 'true', {
expires: 7, // so the user will be redirected to the landing page after 7 days
path: '/'
});
}
if ($("ins.adsbygoogle").is(':empty') || $("ins.adsbygoogle").height() === 0 || !$("ins.adsbygoogle").is(":visible")) {
// Change the HTML content of the ad
$(".cont-ad").html('<span class="adblock-message">Please. Do not take my ads away! <a href="http://www.yoursite.com/ads" target="_self" title="Ads">Read more.</a></span>');
if ($.cookie('ads_checked') == null) {
// Set cookie with value of current page
$.cookie('locational_cookie', window.location, {
expires: 7, // So a user will be redirected to the landing page very 7 days
path: '/'
});
// Redirect
window.location = "http://www.yoursite.com/ads";
}
}
});