Chrome extensions: storage listener for only one stored variable
问题 popup.js: ... chrome.storage.sync.set({'source': source, 'active': active, 'secs': secs, 'domain': domain}, function() { console.log('Settings saved'); }); ... background.js: chrome.storage.onChanged.addListener(function(tab) { //something }); So, can I add a listener for changes of (for example) 'active'? 回答1: You'd have to add an if or switch statement in the listener for specific keys, like so; chrome.storage.onChanged.addListener(function(changes, namespace) { for(key in changes) { if(key