/*
Log the storage area that changed,
then for each item changed,
log its old value and its new value.
*/
function logStorageChange(changes, area) {
console.log(`Change in storage area: ${area}`);
const changedItems = Object.keys(changes);
for (const item of changedItems) {
console.log(`${item} has changed:`);
console.log("Old value: ", changes[item].oldValue);
console.log("New value: ", changes[item].newValue);
}
}
browser.storage.onChanged.addListener(logStorageChange);storage.onChanged / notebook
storage.onChanged
Runnable notebook: every JavaScript, HTML and CSS example on this page executes in a sandboxed local frame. Nothing leaves the browser.