title: How to automatically run custom JavaScript code when loading a webpage?
body: <p>Now I have a block of JavaScript code to change the display of a webpage, say to highlight some data so that when I read the webpage I can easily find them. </p>
  
  <p>The code is super simple, you can just imagine it as</p>
  
  <pre><code>document.getElementById(index).classList.add("highlight")
  </code></pre>
  
  <p><code>index</code> is used to find the content needing to be changed. I will append <code>highlight</code> class to the <code>class</code> attribute of found content so that the display would be changed (just for illustration of the purpose) </p>
  
  <p>Now the problem is, whenever I open the webpage, I need to copy and paste this code to console in Chrome and run it, which is troublesome. So I am wondering whether it is possible that the Chrome will run this script automatically when I load the webpage. Say for example, I have a hyperlink directs to the webpage and when I click the hyperlink, the script will be run and the display of the webpage will be changed.</p>
  
  <p><code>Tampermonkey</code> is not really helpful in my case. I have another method to generate the JavaScript for different webpages so the script I want to run will change when I load different webpages.</p>