title: Greasemonkey userscript is not loading properly
body: <p>I am currently making a userscript to interpret the APL programming language in a Stack Exchange chat window. This is the code I have come up with:</p>
  <pre class="lang-js prettyprint-override"><code>// ==UserScript==
  // @name     APL chat
  // @version  1
  // @grant    none
  // @match    https://chat.stackexchange.com/*
  // @require  https://cdn.jsdelivr.net/npm/apl@0.1.15/lib/apl.min.js
  // ==/UserScript==
  
  window.onload = function() {
    var prevCode = &quot;&quot;;
    setInterval(function() {
      var codes=document.getElementsByTagName(&quot;code&quot;);
        //console.log(codes);
      var elem = codes[codes.length-1];
      if((elem != prevCode) &amp;&amp; (elem.innerText[0] == '⋄')){
          var result = apl(elem.innerText).toString();
          prevCode = elem;
          var tmp = document.createElement(&quot;div&quot;);
          tmp.innerHTML = &quot;&lt;pre style=\&quot;color:red\&quot;&gt;&quot;+result.replace(&quot;\n&quot;,&quot;&lt;br&gt;&quot;)+&quot;&lt;/pre&gt;&quot;;
          var parent = elem.parentElement;
          parent.appendChild(tmp.firstChild);
              console.log(result);
      }
      },100);
  }
  
  </code></pre>
  <p>When a code block is written to the body with a <code>⋄</code> character in it, it should be executed and displayed in red, underneath the code. However, this doesn't work at all times.</p>
  <p>These are the errors I got while testing in the <a href="https://chat.stackexchange.com/rooms/1/sandbox">Chat Sandbox</a>:</p>
  <p>The script turns on in the correct websites, but in the console in Chrome 87.0.4280.88, I get the following error message:</p>
  <pre><code>Uncaught TypeError: Cannot read property 'innerText' of undefined
      at eval (userscript.html?name=APL%20chat.user.js&amp;id=eb8ebba5-9381-48c2-9f2d-d735cbcb847e:1260)
  </code></pre>
  <p>The <code>apl()</code> function takes a single string and interprets in in the APL language, and it is imported from the <code>@require</code> statement, using <a href="https://gitlab.com/n9n/apl" rel="nofollow noreferrer">ngn's javascript APL interpreter</a>.</p>
  <p>Another problem is that when I try accessing the <code>apl()</code> function from the <code>@require</code>, it says <code>ReferenceError: apl is not defined</code>. This happens on both Chrome and Firefox.</p>
  <p>What is the correct fix for these problems?</p>