<?xml version="1.0" encoding="utf-8"?><feed xmlns="http://www.w3.org/2005/Atom" ><generator uri="https://jekyllrb.com/" version="3.10.0">Jekyll</generator><link href="https://xziyu6.github.io/feed.xml" rel="self" type="application/atom+xml" /><link href="https://xziyu6.github.io/" rel="alternate" type="text/html" /><updated>2026-02-04T00:24:25+00:00</updated><id>https://xziyu6.github.io/feed.xml</id><title type="html">Chazz’s Blog</title><subtitle>Updates, tutorials, random thoughts, and more.</subtitle><author><name>Chazz Yu</name></author><entry><title type="html">Dev Log: GOLD Additions</title><link href="https://xziyu6.github.io/2026/02/02/dev-log-gold-additions.html" rel="alternate" type="text/html" title="Dev Log: GOLD Additions" /><published>2026-02-02T00:00:00+00:00</published><updated>2026-02-02T00:00:00+00:00</updated><id>https://xziyu6.github.io/2026/02/02/dev-log-gold-additions</id><content type="html" xml:base="https://xziyu6.github.io/2026/02/02/dev-log-gold-additions.html"><![CDATA[<p>This is the original author’s <a href="https://github.com/unsurprisable/gold-additions">repo</a></p>

<p>It is a Chrome extension that downloads the course schedule as an ICS file from the school portal (it’s called GOLD, hence the name), and some other features too.</p>

<p>I make some contributions during winter break and some more recently, figured I’ll write a dev log as my first blog.</p>

<hr />

<h2 id="changes-i-made">Changes I Made</h2>

<ul>
  <li>Added final exams, pass times, and other dates to export file</li>
  <li>Used <a href="https://github.com/xziyu6/export-ucsb-gold">my code</a> to semi-automate quarter start and end date retrieval (previously needed to manually Ctrl+C Ctrl+V)</li>
  <li>Tweaked the settings popup</li>
  <li>Lots of refractoring</li>
</ul>

<p>Lesson: refractoring is so fun :D</p>

<h2 id="problems-i-encountered">Problems I Encountered</h2>

<h3 id="1">1</h3>

<p><strong>Problem</strong>: If you put the HTML you want to inject in a separate file, you need to get it with</p>

<pre><code class="language-JavaScript">const response = fetch(chrome.runtime.getURL('xxx.html'));
const modalHtml = response.text();
backdrop.insertAdjacentHTML('beforeend', modalHtml);
</code></pre>

<p>What you see is even though the HTML is injected, the buttons don’t work.</p>

<p><strong>Solution</strong>: Use <code>async</code> and <code>await</code>, put all code related to the injection a huge <code>async</code> block. No idea why <code>fetch</code> is designed like this but whatever.</p>

<pre><code class="language-JavaScript">(async () =&gt; {
    const response = await fetch(chrome.runtime.getURL('xxx.html'));
    const modalHtml = await response.text();
    backdrop.insertAdjacentHTML('beforeend', modalHtml);

    // remaining code
})();
</code></pre>

<p><strong>Rationale</strong>: <code>fetch</code> is asynchronous, so upcoming code runs before the HTML is injected, <code>async</code> fixes this because all the remaining code waits for the await lines to finish.</p>

<p>Note: <code>await</code> only happens in the <code>async</code> block, code outside the block still runs asynchronously, so EVERYTHING depending on the HTML should be in the async block.</p>

<h3 id="2">2</h3>

<p><strong>Problem</strong>: Injected HTML can’t use <code>&lt;link rel="stylesheet" href="xxx.css"&gt;</code>, you’ll get <code>Failed to load resource</code> (I think, I just tried replicating the error)</p>

<p><strong>Solution</strong>:</p>

<pre><code class="language-JavaScript">const cssLink = document.getElementById('ics-settings-css');
cssLink.href = chrome.runtime.getURL('css/ics-settings.css');
</code></pre>

<p><strong>Rationale</strong>: When the extension is running, since the script is injecting the text of the HTML into the page. Its context is of the schedule webpage, and can’t access the CSS file by relative path.</p>

<h2 id="blah-blah-blah">Blah Blah Blah</h2>

<p>Really proud of the refractoring I did. Not much technical stuff to it, but it feels good to see my code becoming more and more readable. I pretty much rewrote the entire repo. Also did some documentation (the scraping looks all over the place, I blame whoever designed GOLD)</p>

<p>This is also my first time using AI to code. Github Copilot saved me so much time, mostly with researching implementation methods and mass refractoring. But it’s also really dumb, so I’m still working on finding a middle-ground.</p>

<p>I’ll try to make dev logs a habit and write them during development in the future (took some time trying to remember the problems I encountered)</p>]]></content><author><name>Chazz Yu</name></author><category term="Other" /><summary type="html"><![CDATA[This is the original author’s repo]]></summary></entry></feed>