title: How would I go about using window.find() activate on that text only once
body: <p>I use <a href="http://hack.chat/" rel="nofollow noreferrer">hack.chat</a> a bit, and I saw that they have a bot, but the bot program wasn't working for me so I decided to make my own.</p>
  <pre><code>var finderBinder;
  var searchFor = function(command){
      finderBinder = window.find(command, true, true);
      if(finderBinder){
          if(command === &quot;/hello&quot;){
              ws.send(JSON.stringify({cmd: &quot;chat&quot;, text: &quot;hello!&quot;}));
          }
          else if(command === &quot;/cry&quot;){
              ws.send(JSON.stringify({cmd: &quot;chat&quot;, text: &quot;wah waha wahhh&quot;}));
          }
          else
          {
              console.log(&quot;it was found but it was not a command.&quot;)
          }
      }
      else
      {
          console.log(&quot;Did not find the command&quot;);
      }
  }
  
  var loopdeloop = 0;
  
  while(loopdeloop === 0){
      searchFor(&quot;/hello&quot;);
      searchFor(&quot;/cry&quot;);
  }
  </code></pre>
  <p>Now, the first part works if I just run that by itself on the page, and enter searchFor(&quot;/hello&quot;); that would work, but if I wanted it to just automatically do that whenever a message popped up, I attempted the loop,(In a empty chatroom so it wouldn't spam a used room if it did) and it crashed my browser. I know why it did that. because it just checked forever, and it saw it forever so it kept on trying to do the code forever..</p>
  <p>But how would I make it only run the searchFor when a new text showed up so it would run the text in it and if it was a command it would do the command? Or is there a better way to do this?</p>