I create a Chrome extension and want add an option page where a radio buttons sets a variable from variable array in background.js
.
I have background.js
with a code like
var xhr = new XMLHttpRequest();
var protocol = "https://";
var country = ["de","ch"];
var middle = ".sistrix.com/toolbox/__loadModule/domain/";
var d = currentDomain();
var end = ".html";
xhr.open("GET", protocol+country+middle+d+end, true);
Further i have a file options.html
, containing this code
<select>
<option value="de">Germany</option>
<option value="ch">Swiss</option>
</select>
Now i want that selecting of an option in options.html
() sets corresponding variable from an array var country = ["de","ch"];
into xhr.open("GET", protocol+country+middle+d+end, true);
as country
.
Scenario:
- user clicks with the right mouse button on the extension icon
- options page is opened,
- user selects an option, i.e.
de - Germany
- after this and until user sets another option,
background.js
uses corresponding variablede
from variable arrayvar country = ["de","ch"];
inxhr.open
ascountry
.
PS: some answers about passing data from popup to background don't match my need. I want to have options explicitely under options - here https://easycaptures.com/fs/uploaded/1232/thumbs/7819701093_b.jpg, not in popup, which opens after clicking with the left mouse button on extension icon.