🧩 Plasmo Developers�PD
🧩 Plasmo Developers17mo ago
4 replies
enzon19

how to use Svelte reactivity on CS?

Maybe I'm too dumb, but what's wrong? Wasn't that supported?
<script context="module" lang="ts">
  import cssText from "data-text:~/style.css";
  import type { PlasmoCSConfig, PlasmoGetInlineAnchor, PlasmoMountShadowHost } from "plasmo";

  export const config: PlasmoCSConfig = {
    matches: ["myurl"]
  }

  export const getInlineAnchor: PlasmoGetInlineAnchor = () => document.querySelector(".olx-focus-header__content")
  export const mountShadowHost: PlasmoMountShadowHost = ({ 
    anchor, shadowHost 
  }) => {
    anchor!.element!.insertBefore(shadowHost!, anchor!.element!.nextSibling)
  }

  export const getStyle = () => {
    const style = document.createElement("style")
    style.textContent = cssText
    return style
  }

  let test: any;
  $: console.log(test)
</script>

<input type="text" bind:value={test}>
{test}
Was this page helpful?