mirror of
https://github.com/ajayyy/SponsorBlock.git
synced 2025-12-10 21:47:06 +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
|
// Function setup
|
||||||
|
|
||||||
@@ -82,9 +89,13 @@ function decodeStoredItem(data) {
|
|||||||
|
|
||||||
function configProxy() {
|
function configProxy() {
|
||||||
chrome.storage.onChanged.addListener((changes, namespace) => {
|
chrome.storage.onChanged.addListener((changes, namespace) => {
|
||||||
for (key in changes) {
|
for (const key in changes) {
|
||||||
SB.localConfig[key] = decodeStoredItem(changes[key].newValue);
|
SB.localConfig[key] = decodeStoredItem(changes[key].newValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (const callback of SB.configListeners) {
|
||||||
|
callback(changes);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
var handler = {
|
var handler = {
|
||||||
|
|||||||
Reference in New Issue
Block a user