mirror of
https://github.com/ajayyy/SponsorBlock.git
synced 2025-12-09 21:17:20 +03:00
Added addDefaults and resetConfig
This commit is contained in:
23
SB.js
23
SB.js
@@ -27,10 +27,31 @@ fetchConfig = _ => new Promise(function(resolve, reject) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
async function config() {
|
async function config() {
|
||||||
SB.localconfig = {};
|
|
||||||
await fetchConfig();
|
await fetchConfig();
|
||||||
|
addDefaults();
|
||||||
SB.config = configProxy();
|
SB.config = configProxy();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SB.defaults = {
|
||||||
|
"startSponsorKeybind": ";",
|
||||||
|
"submitKeybind": "'",
|
||||||
|
"minutesSaved": 0,
|
||||||
|
"skipCount": 0
|
||||||
|
}
|
||||||
|
|
||||||
|
// Reset config
|
||||||
|
function resetConfig() {
|
||||||
|
SB.config = SB.defaults;
|
||||||
|
};
|
||||||
|
|
||||||
|
// Add defaults
|
||||||
|
function addDefaults() {
|
||||||
|
Object.keys(SB.defaults).forEach(key => {
|
||||||
|
if(!SB.localconfig.hasOwnProperty(key)) {
|
||||||
|
SB.localconfig = SB.defaults[key];
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
// Sync config
|
// Sync config
|
||||||
config();
|
config();
|
||||||
|
|||||||
Reference in New Issue
Block a user