From 94b01ea25bca59d6004f52779705ae2a288a6078 Mon Sep 17 00:00:00 2001 From: buzz-lightsnack-2007 <73412182+buzz-lightsnack-2007@users.noreply.github.com> Date: Fri, 29 Mar 2024 20:25:42 +0800 Subject: [PATCH] add storage events change handling --- scripts/secretariat.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/scripts/secretariat.js b/scripts/secretariat.js index 5a3ca7e..4138774 100644 --- a/scripts/secretariat.js +++ b/scripts/secretariat.js @@ -382,3 +382,14 @@ export function init(data) { }); } } + +/* +Run a script when the browser storage has been changed. + +@param {object} reaction the function to run +*/ +export async function observe(reaction) { + chrome.storage.onChanged.addListener((changes, namespace) => { + reaction(changes, namespace); + }); +}