1

I am trying to get the current tab url from background.js and render it onto the popup.html. How can I do the same? I am using the Vuejs framework to create a plugin.

I tried sending the data as a message from background.js to popup. But the onClicked event does not allow it to be run on the popup.

I expect to have the url of the current open tab in the popup plugin, with which I intend to do other things.

1 Answers1

0

I think you can save the data to chrome.storage.local right in the backgroundt and detect this fact in your popup using chrome.storage.onChanged event.

Umbro
  • 1,984
  • 12
  • 40
  • 99
  • @MohitKamal Did you try it? – Umbro Jun 24 '19 at 07:40
  • Is there a way I can incorporate the vue store into the chrome extension, or do I explicitly need to user chrome.storage api only? My basic Vuejs app uses a basic store which I want to use in the chrome extension – Mohit Kamal Jun 24 '19 at 10:25
  • Do you want to create 'chrome extension'? – Umbro Jun 24 '19 at 10:27
  • Yes. I am creating a chrome plugin using Vuejs where I want to get the url of the current tab, and in the popup.html, there is a button which does an api call using that url. – Mohit Kamal Jun 24 '19 at 10:54
  • Did you get the current tab and save in state in vue? – Umbro Jun 24 '19 at 11:03
  • Where do you want to save date about current tab page? – Umbro Jun 24 '19 at 11:05
  • I am sorry for my novice understanding, as I am fairly new to chrome extension development. I am getting the current tab url from chrome.tabs.query from background.js. Now I want to save this url in my vuejs popup. I hope you are getting me – Mohit Kamal Jun 24 '19 at 11:09
  • I would do as I did in response. This is my idea – Umbro Jun 24 '19 at 11:14
  • One more question. Can I get the chrome.storage data from background.js directly into my vuejs store via actions or mutations? – Mohit Kamal Jun 24 '19 at 11:31
  • You can use `chrome.storage.local.get` and assign to variable. `const d = chrome.storage.local.get`. variable `d` save to state – Umbro Jun 24 '19 at 11:54