tatsumaru
PD🧩 Plasmo Developers
•Created by tatsumaru on 11/5/2024 in #👾extension
Nested Background Messages?
I am trying to group background messages in nested folders under
background/messages/{nested}
. I noticed that if I put a regular background script in there, it will work, but if I put a PlasmoMessaging
handler in a nested folder, it won't register. Is there a way to get the Plasmo Messaging API to look into nested folders so I can organize my messengers properly?5 replies
PD🧩 Plasmo Developers
•Created by tatsumaru on 11/4/2024 in #🔰newbie
How to Dynamically Mount/Unmount Plasmo Components without Page Refresh?
Problem:
In a SPA app, components matched to specific URLs don’t consistently mount/unmount on soft navigations (client-side routing). Components either appear only after a page refresh or fail to unmount without one. The goal is to achieve dynamic mounting and unmounting of components in response to soft navigations without loading content scripts on all pages, especially in large extensions with numerous features.
Question:
What’s the best approach to manage component mounting and unmounting within an SPA in Plasmo, considering the need for efficiency, modularity, and scalability?
Potential Solutions (so far):
1. URL-Specific ShadowRoot Mount with Custom Rendering: Configure the shadow root to mount only on matched URLs and manage component rendering within it using a MutationObserver to detect soft navigations in the SPA.
2. All-Pages Shell Component with Internal URL Matching: Load a lightweight shell component on all SPA pages. Inside it, use MutationObserver to detect URL changes and mount/unmount specific components based on the active URL.
3. Shell Component as a Dynamic Router: Implement a minimal shell component that loads on all pages and acts as a router, dynamically importing and mounting components based on URL matches, allowing multiple components to load on the same page if needed.
Which approach aligns best with Plasmo’s architecture for SPAs and offers efficient, scalable management of multiple components? I am also open to other solutions.
Thanks!
2 replies
PD🧩 Plasmo Developers
•Created by tatsumaru on 11/2/2024 in #👟framework
Plasmo with next-js routing?
I noticed that plasmo supports next.js in this example: https://github.com/PlasmoHQ/examples/tree/main/with-nextjs , but I am not sure how mounting works here? Typically with CSUI you indicate when and how to inject elements, but in this case I imagine the file-based routing is somehow leveraged? How does plasmo know what you want?
2 replies
PD🧩 Plasmo Developers
•Created by tatsumaru on 11/2/2024 in #🔰newbie
What is 'plasmo-mount-container'?
In the plasmo with svelte example here https://github.com/PlasmoHQ/examples/blob/main/with-svelte/contents/plasmo-overlay.css there's a
#plasmo-mount-container
target, but it's not clear to me what that is. I am not seeing this id anywhere in the codebase, and I am not seeing it in the rendered component either? I understand that the #plasmo-shadow-container
is basically a secondary wrapper inside the shadowRoot, but I am not sure what the #plasmo-mount-container
is. Maybe it's just some shorthand for targeting the framework's (svelte) own top-level element / mountpoint to plasmo, but I am not sure. You don't see this in the react example here:
https://github.com/PlasmoHQ/examples/blob/main/with-content-scripts-ui/contents/plasmo-overlay.css
Instead here, the .hw-top class is targetted directly.
Any clues?2 replies
PD🧩 Plasmo Developers
•Created by tatsumaru on 10/28/2024 in #👟framework
Svelte 5 support in Plasmo?
Hey just curious if there are any plans to bring Svelte 5 support to Plasmo so we can use svelte.ts and svelte.js files and some of the newer neat syntactic sugar? Thanks.
2 replies
PD🧩 Plasmo Developers
•Created by tatsumaru on 10/22/2024 in #🔰newbie
How to send messages from content to content?
I am building an extension which injects multiple content script UIs in a single page (in order to have different mount points) and I am looking for a way to get them to pass messages efficiently. I managed to do it via the messaging API, but that takes 5ms on average and isn't exactly snappy. Apparently the chrome.tabs API isn't available to content scripts for some reason, and as far as I can tell you can't use the chrome.runtime API to send directly between content scripts because although the extension message infrastructure works as a broadcast, the source that sends the message will not also receive it. I mean all content scripts share the same runtime ID so it'd be crazy if there's no way to get content scripts to talk to each other directly. Any clues will be highly appreciated.
3 replies
PD🧩 Plasmo Developers
•Created by tatsumaru on 10/12/2024 in #👾extension
Maximum size for extension bundle/archive you can upload in Google Chrome Store?
I've looked in the Google docs and in the developer portal, but can't find a single place which states what's the maximum size of an extension bundle/archive. Any clues?
2 replies
PD🧩 Plasmo Developers
•Created by tatsumaru on 10/12/2024 in #👟framework
Dynamically Injecting Content Scripts with Plasmo CSUI
I'm working on a browser extension and wondering about the feasibility of loading external scripts dynamically. I understand that Chrome Web Store policies are generally restrictive when it comes to dynamic script injection, especially for security reasons, but I'm interested in whether anyone has found long-term success with this kind of setup (for example for when different users are paying for different features).
Specifically:
- Has anyone been able to dynamically load external resources or scripts without facing issues during Web Store review or updates?
- Are there alternative approaches for managing modular content (e.g., selectively loading features from a server) that comply with Web Store policies?
- How have solutions like content security policies (CSP) and server-managed entitlement checks been used to navigate this kind of challenge?
I'm trying to understand if it's possible to achieve flexibility in feature loading without violating the security rules or risking removal from the store.
Any insights or experiences would be really helpful!
2 replies
PD🧩 Plasmo Developers
•Created by tatsumaru on 10/11/2024 in #👟framework
Does each CSUI component get a separate React copy?
The Content Script documentation says: "A script that ends with .ts will not have front-end runtime (react/vue/svelte) bundled with it and won't be treated as a ui script, while a script that ends in .tsx, .vue or .svelte, will be."
Just curious if each CSUI component gets its own copy of Reach or if somehow Plasmo manages to share the same React dep with all components.
Thanks.
2 replies
PD🧩 Plasmo Developers
•Created by tatsumaru on 10/10/2024 in #👾extension
Can I use native web components with CSUI?
I tried using Content Scripts UI (CSUI) with a native web component instead of a react component (see below), but I got a bunch of React errors in the browser console referring to a React component. Is there a way to make Plasmo work with native web components or something like Lit? Thanks.
9 replies
PD🧩 Plasmo Developers
•Created by tatsumaru on 10/10/2024 in #👾extension
Error loading {script-name}: ReferenceError: importScripts is not defined
Is this a Plasmo Bug? I am trying to load a module using a dynamic import like this in the content script:
const module = await import('../local/app.js');
So far it hasn't worked and I am seeing this error in the console. I am not using importScripts as far as I can tell but this js-loader.js
might be. Any clues?
Error loading {script-name}: ReferenceError: importScripts is not defined
2 replies