0

it's my first chrome extension and I'm trying to send a set from content.js to popup.js . I tried using sendMessage and chrome.storage.local but I can't get it to work. this is how I set the data in content.js, I do it inside a chrome.runtime.onMessage.addListener since the user needs to input some data and then click on a button:

chrome.storage.local.set({dataset: accountSet});

the popup.js:

chrome.storage.local.get("dataset", function(data) {
                      if(typeof data.dataset == "undefined") {
                      //bad
                      } else {
                        data.dataset.forEach(function(value) {
                   //do smthg
                        });
                        document.getElementById("accounts-tab").innerHTML+='</table>';
                      }
                  });

I'm using manifest_version 3, thank you.

confusedstudent
  • 353
  • 3
  • 11
  • Use executeScript instead of messaging, [example](/q/4532236). – wOxxOm Feb 02 '22 at 16:44
  • It's a bit vague your link, I'm not trying to update the dom , I just want to pass data (ideally a set) from contentjs since that's where I have access to the dom elements and data to popUPjs seeing as I want to change the popup html – confusedstudent Feb 03 '22 at 09:15
  • You don't have to update DOM. The point is that executeScript is more reliable and easy to use to return results. Your current content script won't be injected in open tabs after the extension is installed or updated so you'll have to inject it manually, which is quite involved. – wOxxOm Feb 03 '22 at 09:44

0 Answers0