No chat to show

This project's files are all here to explore.

Files
content.css
content.js
manifest.json
popup.css
popup.html
popup.js
Code
6 239
content.js
(function () {
  let enabled = true;
  const STYLE_ID = "ysb-style";

  function applyState() {
    const existing = document.getElementById(STYLE_ID);
    if (enabled) {
      if (!existing) {
        const link = document.createElement("link");
        link.id = STYLE_ID;
        link.rel = "stylesheet";
        link.href = chrome.runtime.getURL("content.css");
        document.head.appendChild(link);
      }
    } else {
      if (existing) existing.remove();
    }
  }

  chrome.storage.local.get({ enabled: true }, (result) => {
    enabled = result.enabled;
    applyState();
  });

  chrome.runtime.onMessage.addListener((msg) => {
    if (msg.type === "SET_ENABLED") {
      enabled = msg.enabled;
      applyState();
    }
  });
})();