mirror of
https://github.com/ajayyy/SponsorBlock.git
synced 2024-11-13 10:17:39 +01:00
Merge pull request #235 from OfficialNoob/patch-2
Formatting changes & proxy delete support
This commit is contained in:
commit
5348496768
1 changed files with 57 additions and 52 deletions
13
SB.js
13
SB.js
|
@ -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(prop);
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
@ -128,10 +133,10 @@ function fetchConfig() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function migrateOldFormats() { // Convert sponsorTimes format
|
function migrateOldFormats() { // Convert sponsorTimes format
|
||||||
for (key in SB.localConfig) {
|
for (const 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];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue