title: Callback with window.setInterval
body: <p>I am trying to return a some metadata found on a page in a google-chrome extension. The background.js makes a request to the website.js page for the metedata. The request is made right when the page is updating content, so I have to check to make sure that data has been modified before I return. Here is my code:</p>
  
  <pre><code>var checkMeta = function(){
      var title = $(".playerBarSong").text();
      var artist = $(".playerBarArtist").text();
      var album = $(".playerBarAlbum").text();
      var art = $(".playerBarArt").attr("src");
      if (previousTitle != title || previousArtist != artist || previousAlbum != album || previousArt != art){
          previousTitle = title;
          previousArtist = artist;
          previousAlbum = album;
          previousArt = art;
  
          currentMeta.title = title;
          currentMeta.artist = artist;
          currentMeta.album = album;
          currentMeta.art = art;
  
          window.clearInterval(intervalId);
          sendResponse(currentMeta); //Does not return value to the extension
      }
  
  };
  
  chrome.extension.onMessage.addListener(
      function(request, sender, sendResponse){
          if (request.request == "meta"){
              currentMeta = request.meta;
  
              intervalId = window.setInterval(checkMeta,250)
              //Some sort of callback?
          }
      }
  );
  </code></pre>
  
  <p>Any solution in vanilla JavaScript or jquery would be appreciated. </p>