mirror of
https://github.com/ajayyy/SponsorBlock.git
synced 2025-12-09 04:57:09 +03:00
Added config callback support.
This commit is contained in:
15
SB.js
15
SB.js
@@ -1,4 +1,11 @@
|
||||
SB = {};
|
||||
SB = {
|
||||
/**
|
||||
* Callback function when an option is updated
|
||||
*
|
||||
* @type {CallableFunction}
|
||||
*/
|
||||
configListeners = []
|
||||
};
|
||||
|
||||
// Function setup
|
||||
|
||||
@@ -82,9 +89,13 @@ function decodeStoredItem(data) {
|
||||
|
||||
function configProxy() {
|
||||
chrome.storage.onChanged.addListener((changes, namespace) => {
|
||||
for (key in changes) {
|
||||
for (const key in changes) {
|
||||
SB.localConfig[key] = decodeStoredItem(changes[key].newValue);
|
||||
}
|
||||
|
||||
for (const callback of SB.configListeners) {
|
||||
callback(changes);
|
||||
}
|
||||
});
|
||||
|
||||
var handler = {
|
||||
|
||||
Reference in New Issue
Block a user