Formatting changes & proxy delete support

This commit is contained in:
Official Noob
2020-01-11 19:42:35 +00:00
committed by GitHub
parent f5a4ffabde
commit 4de0ae51e8

11
SB.js
View File

@@ -99,18 +99,23 @@ function configProxy() {
}); });
var handler = { var handler = {
set: function(obj, prop, value) { set(obj, prop, value) {
SB.localConfig[prop] = value; SB.localConfig[prop] = value;
chrome.storage.sync.set({ chrome.storage.sync.set({
[prop]: encodeStoredItem(value) [prop]: encodeStoredItem(value)
}); });
}, },
get: function(obj, prop) {
get(obj, prop) {
let data = SB.localConfig[prop]; let data = SB.localConfig[prop];
if(data instanceof Map) data = new MapIO(prop); if(data instanceof Map) data = new MapIO(prop);
return obj[prop] || data; return obj[prop] || data;
},
deleteProperty(obj, prop) {
chrome.storage.sync.remove(key);
} }
}; };
@@ -131,7 +136,7 @@ function migrateOldFormats() { // Convert sponsorTimes format
for (key in SB.localConfig) { for (key in SB.localConfig) {
if (key.startsWith("sponsorTimes") && key !== "sponsorTimes" && key !== "sponsorTimesContributed") { if (key.startsWith("sponsorTimes") && key !== "sponsorTimes" && key !== "sponsorTimesContributed") {
SB.config.sponsorTimes.set(key.substr(12), SB.config[key]); SB.config.sponsorTimes.set(key.substr(12), SB.config[key]);
chrome.storage.sync.remove(key); delete SB.config[key];
} }
} }
} }