Getting data from the current tabs localStorage

Hello everyone. I did look at the previous messages but still not sure how this works. What i want to do is lets say i am on google.com and when i open the extension i want to be able to read from the google.com Local Storage that i have in the browser. I did give storage permission for the extension, and tried to use @plasmo/storage but wasnt successful. Can someone help me with this?
18 Replies
personne
personne•11mo ago
What is it exactly not working? You have an error, a undefined, a null? Are you running the dev env with Firefox?
cygnusgod
cygnusgodOP•11mo ago
I am trying with Brave. Basically getting undefined but i know that, that page has a value for that key in local storage
Arcane
Arcane•11mo ago
@cygnusgod has reached level 1. GG!
personne
personne•11mo ago
Are you using @plasmohq/storage, or secure/hook ones?
cygnusgod
cygnusgodOP•11mo ago
i am trying to use plasmohq/storage one. I am trying to implement the logic on popup.tsx, maybe thats why i can't get the data?
personne
personne•11mo ago
I might know why At least, for the moment I see one thing to test Since you are using popup.tsx, you are using some JSX (tsx), you also need ton install @plasmohq/storage/hook And use import { useStorage } from "@plasmohq/storage/hook" in popup.tsx https://docs.plasmo.com/framework/storage#react-hook-api
cygnusgod
cygnusgodOP•11mo ago
i did install that and tried useStorage hook but maybe was implementation was wrong so didnt work. I thought the storage from plasmo can't get a data from localstorage of the current tab
personne
personne•11mo ago
The base package should be able to do that, but the hook is needed cause of React For Redux, I know no shit! :-D
cygnusgod
cygnusgodOP•11mo ago
i see. do you know any example implementation like this that i can check out? haven't been able to solve this issue since yesterday
personne
personne•11mo ago
GitHub
GitHub - PlasmoHQ/examples: 🔰 Example projects that demonstrate how...
🔰 Example projects that demonstrate how to use the Plasmo Framework and integrate with popular tools - GitHub - PlasmoHQ/examples: 🔰 Example projects that demonstrate how to use the Plasmo Framewor...
Arcane
Arcane•11mo ago
@personne has reached level 3. GG!
personne
personne•11mo ago
There are a with-storage and with-redux examples
cygnusgod
cygnusgodOP•11mo ago
thanks, i did check the storage example but no luck. asked @Pallas too, still no answer lol. thank you for your help!
YAGPDB.xyz
YAGPDB.xyz•11mo ago
Gave +1 Rep to @Pallas
Pallas
Pallas•11mo ago
At your service! I'm sorry to hear that you haven't had any luck with the storage example and haven't received a response from @Pallas yet. It can be frustrating when you're stuck on something and don't have the support you need. When it comes to troubleshooting storage in browser extensions, there could be a few things to consider. First, make sure you are using the correct storage API for your browser extension platform (e.g., chrome.storage for Chrome, browser.storage for Firefox). Each platform may have its own specific implementation and quirks. Next, double-check that you are using the storage API correctly in your code. Are you using the appropriate methods to get, set, or remove items from storage? It's also important to handle any errors that may occur during these operations. If you've already reviewed the storage example and still can't figure out the issue, it might be helpful to provide more specific details about the problem you're facing. Are you encountering any error messages? Is the storage not persisting data as expected? The more information you can provide, the easier it will be for others to assist you. In the meantime, while you wait for a response from @Pallas, you could try reaching out to other developer communities or forums dedicated to browser extension development. Sometimes a fresh set of eyes can provide new insights and solutions. Remember, troubleshooting can be a process of trial and error, so don't get discouraged. Keep exploring and experimenting, and you'll likely find a solution to your storage issue. And here's a little trivia for you: Did you know that the first browser extension was developed for Internet Explorer in the late 1990s? It allowed users to customize the browser's appearance and add new features. Since then, browser extensions have become an integral part of our browsing experience across different platforms. Happy coding!
personne
personne•11mo ago
Did you try to clone the example and check if it work directly with the example? Maybe it is broken, who knows.
cygnusgod
cygnusgodOP•11mo ago
i haven't done that, but i'll look into it
BlazingBaneâ„¢
BlazingBane™•9mo ago
Have you found any solution? Im trying to read localStorage of current tab. Dont know how to build it. Help!
Want results from more Discord servers?
Add your server