How to keep the content.tsx open (or open again) when navigating to a new page?

I am trying to redirect the user from the content to a new page (for web scraping uses) and I need to open the extension again once the new page is opened.
3 Replies
lab
lab•2y ago
If you need persistent, use the CS for scraping, and a separate tab page for notification. if it's a SPA page, you can listen to one of their anchor and remount as needed - I added a global watch method that will let you rerender your entire dom tree as welll
GabrielDSFS
GabrielDSFSOP•2y ago
I found a solution using the storage API @plasmohq/storage One question I have now, is how to use this way with default data const [data, setData] = useStorage({ key: "data", instance: localStorage }) I need it to be local, but I can't set the default value like I would useStorage("data", [])
lab
lab•2y ago
the 2nd argument is how you set default value:
useStorage({
key: "data",
instance: localStorage
}, "defval")
useStorage({
key: "data",
instance: localStorage
}, "defval")
Note that the above form works in most case but not entirely when it comes to hydrating in multiple place. You might want to use the function form instead;
useStorage({
key: "data",
instance: localStorage
}, (v, isHydrated)=> { // if v is undefined and isHydrated, it's not set previously })
useStorage({
key: "data",
instance: localStorage
}, (v, isHydrated)=> { // if v is undefined and isHydrated, it's not set previously })
Want results from more Discord servers?
Add your server