title: Replace text before other scripts load
body: <p>I have piece of code:</p>
  
  <pre><code>&lt;!doctype html&gt;
  &lt;html lang="en"&gt;
  &lt;head&gt;
      &lt;script src="main.js"&gt;&lt;/script&gt;
  &lt;/head&gt;
  &lt;body&gt;
  &lt;script src="custom.js?token={{token}}"&gt;&lt;/script&gt;
  
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p><code>main.js</code> is my script which replace in <code>body</code> tag <code>{{token}}</code> for value provided from Query. </p>
  
  <pre><code>window.onload = function() {
      var link_sid = query.get('link_sid');
      document.body.innerHTML = document.body.innerHTML.replace(/{{token}}/g, util.protocol() + '://c.' + util.env() + util.domain() + '/' + link_sid);
  }
  </code></pre>
  
  <p><code>custom.js?token={{token}}</code> is user content which I can't change. </p>
  
  <p>The problem is that user JS put some HTML code based on my <code>{{token}}</code> value.
  So after open page all <code>{{token}}</code> are changed but not inside custom JS cos token was changed after JS was loaded.</p>
  
  <p>How can I replace <code>{{token}}</code> in custom.js query before it loads? It needs to be done in pure JS.</p>
  
  <p><strong>[Updated 1]</strong></p>
  
  <p>I can't move anything from <code>body</code> also can't change. Body is user-provided content.</p>