title: fetch javascript input/output from google sheet
body: <p>I have the code below on Apps script but keep getting 'ReferenceError: setInterval is not defined on line 17'. Not sure how to fix this but it does load when i use the scipt below in a cell in google sheets and set it up to output to another - it runs apart from that error. not sure if it's because i have it set up wrong or because google apps script doesn't like the code</p>
  <pre><code>function scart() {// ==UserScript==
  
  
  setInterval(function() {
      var possibleClasses = [&quot;.listenArtworkWrapper&quot;, &quot;.listenInfo&quot;],
          sizes = { 't500x500': '500x500', 'original': 'original size' },
          regexp = /t\d{3}x\d{3}/gi;
  
  $('.modal__content:not(.appeared)')
      .addClass('appeared')
      .each(handleModal);
  
  function handleModal() {
      var imageURL;
  
      for (var i = 0; i &lt; possibleClasses.length; i++) {
          if ($(possibleClasses[i] + &quot; .image__full&quot;).length &gt; 0) {
              imageURL = $(possibleClasses[i] + &quot; .image__full&quot;).css('background-image');
          }
      }
  
      if (!imageURL) {
          logError('No suitable selector found!');
      } else {
          imageURL = /url\(&quot;(.+)&quot;\)/.exec(imageURL)[1];
      }
  
      $(&quot;.modal__content .image__full&quot;).parent().remove();
      $(&quot;.modal__content .imageContent&quot;).append(&quot;&lt;img style='width: 500px; height: 500px; margin-bottom: 15px;' src='&quot; + imageURL.replace(regexp, 't500x500') + &quot;'&gt;&quot;);
  
      Object.keys(sizes).forEach(function (size) {
          var url = imageURL.replace(regexp, size);
          $.ajax({
              type: 'HEAD',
              url: url,
              complete: function(xhr) {
                  if (xhr.status !== 200) {
                      return;
                  }
  
                  $(&quot;.modal__content .imageContent&quot;).append(
                      makeButton(url, sizes[size])
                  );
              }
          });
      });
  }
  
  function makeButton(url, sizeLabel) {
      var $btn = $('&lt;button /&gt;')
          .css({ margin: '10px auto 0 auto', display: 'block', width: '100%'})
          .attr('class', 'sc-button sc-button-medium sc-button-responsive')
          .text('Download ' + sizeLabel);
  
      $btn.on('click', function(e) {
          e.preventDefault();
          download(url);
      });
  
      return $btn;
  }
  
  function download(url) {
      url = url.split('?')[0];
      if (!url.startsWith('http')) {
          url = window.location.protocol + (url.startsWith('//') ? '' : '//') + url;
      }
  
      var fileNameParts = url.split('/');
      var fileName = fileNameParts[fileNameParts.length - 1];
  
      var options = {
          url: url,
          name: fileName,
          onerror: function (e) {
              logError('Download failed. Reason: ' + e.error);
          }
      };
  
      GM_download(options);
  }
  
  function logError(message) {
      var details = {
          title: GM_info.script.name,
          text: message,
      };
  
      GM_notification(details);
      console.error('%c' + GM_info.script.name + '%c: ' + message, 'font-weight: bold', 'font-weight: normal');
  }
  </code></pre>
  <p>}, 250);</p>
  <p>}</p>