title: Chrome Extension: Check if background script is running
body: <p>I have a background script that uses the setInterval command to do a network request on a routine basis. </p>
  
  <p>I was wondering if the background script can detect if the os goes on sleep or standby so that I can adjust the timer displayed upon resuming the background script. I understand that the setInterval timer is suspended during sleep based on this Answer: <a href="https://stackoverflow.com/questions/6346849/what-happens-to-settimeout-when-the-computer-goes-to-sleep">What happens to setTimeout when the computer goes to sleep?</a> </p>
  
  <p>Code sample is background.js</p>
  
  <pre><code>    set_start_time();
      search_set_int = setInterval(function() {
  
      foo();
  
      // Set the Auto Search Start time for the next run 
      set_start_time();
  }, frequency); // Set interval function
  
  
   var total_time_left_sec = (frequency/1000) - (current_time_unix - start_time_unix)
  </code></pre>
  
  <p>Thanks</p>