Hidden Text with Passwords


#1

Hi! I was on a really cool server when I saw something that said admin chat and for privacy they had a password on it. Can someone tell me how to do that because my friend’s server is having trouble with admin chat privacy.


#2

Is that even possible?


#5

I don’t know if there’s a way to do it in game but if it’s in the Welcome Message it seems a bit counterintuitive. I’d recommend Discord as a third party messaging system. It’s smooth, works for gamers, and it’s easy to use :slight_smile:


#6

They probably did something like this:

Note: This is not secure. Anyone with a bit of tech knowledge will be able to read the hidden content.


<h1>Hi</h1>

<div data-password="hi">

Super secret.

</div>

<h1>Bye</h1>

<div data-password="bye" data-prompt="See bye content">

Goodbye

</div>

<style>
[data-password]:not(.show) { display: none; }
</style>
<script>

Array.from(document.querySelectorAll('[data-password]')).forEach(function (el) {
    var b = document.createElement('button')
    el.insertAdjacentElement('afterend', b)
    b.textContent = el.dataset.prompt || "Enter password"

    b.addEventListener('click', function () {
      if (prompt("Enter password") === el.dataset.password) {
        el.classList.add('show')
        b.remove()
      } else {
        alert('Wrong password!')
      }
    })
 })

</script>


#8

Thanks!


#9

Can you please explain how this works to me?


#10

What part don’t you understand? It reads fairly straightforwardly to me…