Apart from using localStorage( through background page), you can directly save those variables in the background page by messaging from content script to the background page. If those variables are in the extension page(other that content or injected scripts) you can easily save them by chrome.extension.getBackgroundPage().window.variableYouWant
method and access those variables in the content script itself by messaging.
If those variables are in the content script use messaging to send those variables to background page like this:
chrome.runtime.sendMessage(object);
object
could be any Object you might want to send.
on background page have a lisner like this:
chrome.runtime.onMessage.addListener(function(message, sender, sendResponse) {
myVariabeInBackground = message.yourObjectProperties;
});
when you require those variables you can use chrome.extension.getBackgroundPage().window.myVariabeInBackground
in your extension page(other than content script) or you can send message from background page to content script by calling chrome.tabs.sendMessage(tabId, messageObject)
in the background page itself and receive at the content script by having a listner like this:
chrome.runtime.onMessage.addListener(
function(request, sender) {}); //request is your sent object.
For localStorage also you can do the same thing to get that stored variable into your content script.
And No, you cant directly access the background page from content script.
PS: variables in background page will reset if extension is reloaded. If you want to use those variables even after reloading the extension use local storage. Extension does not reload on browser actions.
For more details read https://developer.chrome.com/extensions/messaging