async function checkState() {
  const threshold = parseInt(document.querySelector('#idle-threshold').value);
  const dom_threshold = document.querySelector('#idle-set-threshold');
  dom_threshold.innerText = threshold;

  // Request the state based off of the user-supplied threshold.
  chrome.idle.queryState(threshold, function (state) {
    const time = new Date();
    if (laststate != state) {
      laststate = state;
      laststatetime = time;
    }

    // Keep rendering results so we get a nice "seconds elapsed" view.
    const dom_result = document.querySelector('#idle-state');
    dom_result.innerHTML = renderState(state, time);
    const dom_laststate = document.querySelector('#idle-laststate');
    dom_laststate.innerHTML = renderState(laststate, laststatetime);
  });
}
Checks the current state of the browser.