-3

I have a website and I would like every visitor (or at least every session) to help the site survive. By this, I mean integrating a CoinHive based script so when run once, it will mine (with the user's consent and knowledge) and the popup will automatically close with a popup after this.

For the CoinHive based script, I have the following:

<!DOCTYPE HTML>
<html>

<head>
  <title> Sample </title>
</head>

<body>

  <form action="?" method="post">
    <script src="https://authedmine.com/lib/captcha.min.js" async></script>
    <div class="coinhive-captcha" data-hashes="1024" data-key="my_key_here">
      <em>Loading Captcha...<br>
  If it doesn't load, please disable Adblock!</em>
    </div>

    <input type="submit" value="Submit" />
  </form>
</body>

</html>

For the popup displayed, I have:

function myFunction() {
    alert("Thank you for helping. You may now proceed.");
}

Finally, my text on the popup will be:

Dear Visitors. In order to keep this site running, you are required to complete a one-time captcha. This will require you to just click it and wait, however, it will increase CPU and power usage, so using a PC is recommended. This should be the only time you see this. Thank you and sorry for inconvenience.

Could someone help make this into a popup where this is required, users won't be able to scroll or exit and this is one-time?

ankitkanojia
  • 3,072
  • 4
  • 22
  • 35
dado101
  • 7
  • 1

1 Answers1

0

You can use localStorage :

<script type="text/javascript">
    var alerted = localStorage.getItem('alerted') || '';
    if (alerted != 'yes') {
     alert("Thank you for helping. You may now proceed.");
     localStorage.setItem('alerted','yes');
    }
</script>

More complete answer : Here

I hope to help you.

Siros Baghban
  • 406
  • 4
  • 7