Tell me how to pass a variable to background? In the manifest, you have the necessary permissions.

I am writing in background.js:

 function randomInteger (min, max) {
     var rand = min - 0.5 + Math.random () * (max - min + 1)
     rand = Math.round (rand);
     return rand;
   }

 if (localStorage ["extension_id"])
   localStorage ["extension_id"] = randomInteger (1, 1,000,000);

How can I finally transfer localStorage ["extension_id"] to content.js for future use?

  • var extension_id = localStorage["extension_id"]; in content.js not working? What does it mean to pass on to background ? - MasterAlex
  • undefined comes, must come a number. - Timur Musharapov
  • ru.stackoverflow.com/questions/531749 see the answer here, in your case can help - MasterAlex
  • 2
    if any temporary value, then read about message passing . If the value of the value is to be stored, then use chrome.storage . It is common to content_scripts and background. - UserName
  • UserName, you really helped! - Timur Musharapov

0