News for hackers. Stuff that matters.
Re:Is this prime? by nick_name on Wednesday March 09, 2016 @12:23AM (#11251093)
If you don't want the browser to freeze ...

    var target = document.getElementById('n');
    function detect() {
      n = parseInt(target.firstChild.nodeValue);
      if (typeof n === 'number' && is_prime(n) === 'prime') {
        console.log('>> YES,' + n + ' is prime, clicking "yes" ...');
        document.getElementById('yes').click();
      } else {
        console.log('>> NO,' + n + ' is not prime, clicking "no" ...');
        document.getElementById('no').click();
      }
    }
    var observer = new MutationObserver(function (mutations) {
      mutations.forEach(function (mutation) {
        window.setTimeout(detect, 500);
      });
    });
    observer.observe(target, {
      attributes: true,
      childList: true,
      characterData: true
    });

There are no comments on this comment yet.