I have a short options page that's running and the value ('Yes' or 'No') gets passed to storage. Getting it out of storage and using it in a switch statement seems to be something of a production. I'd like to pass the value from storage to the variable filterSetting
and use this string value to in my switch statement. I used an alert();
to test whether or not anything was being passed into storage, so I know it's there.
Here's what I have in my content.js file. All permissions appear to be in place. Thoughts on where I've gone wrong would be appreciated.
var words = /minecraft|played/gi;
// obtain web page url for eventual identification
var url = window.location.href;
var filterSetting;
chrome.storage.sync.get('filter', function(data) {
filterSetting = data.filter;});
switch (filterSetting) {
case "Yes":
// generic filter
alert("It worked!");
break;
case "No":
// specific filter