mirror of
https://github.com/ajayyy/SponsorBlock.git
synced 2025-12-17 03:44:25 +03:00
Comments and added delete
This commit is contained in:
25
SB.js
25
SB.js
@@ -15,12 +15,14 @@ Map.prototype.toJSON = function() {
|
|||||||
|
|
||||||
class MapIO {
|
class MapIO {
|
||||||
constructor(id) {
|
constructor(id) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
this.map = SB.localConfig[this.id];
|
this.map = SB.localConfig[this.id];
|
||||||
}
|
}
|
||||||
|
|
||||||
set(key, value) {
|
set(key, value) {
|
||||||
|
// Proxy to map
|
||||||
this.map.set(key, value);
|
this.map.set(key, value);
|
||||||
|
// Store updated map locally
|
||||||
chrome.storage.sync.set({
|
chrome.storage.sync.set({
|
||||||
[this.id]: encodeStoredItem(this.map)
|
[this.id]: encodeStoredItem(this.map)
|
||||||
});
|
});
|
||||||
@@ -28,19 +30,21 @@ class MapIO {
|
|||||||
}
|
}
|
||||||
|
|
||||||
get(key) {
|
get(key) {
|
||||||
return this.map.get(key);
|
return this.map.get(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
has(key) {
|
has(key) {
|
||||||
return this.map.has(key);
|
return this.map.has(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
deleteProperty(key) {
|
deleteProperty(key) {
|
||||||
if (this.map.has(key)) {
|
if (this.map.has(key)) {
|
||||||
|
// Proxy to map
|
||||||
this.map.delete(key);
|
this.map.delete(key);
|
||||||
chrome.storage.sync.set({
|
// Store updated map locally
|
||||||
[this.id]: encodeStoredItem(this.map)
|
chrome.storage.sync.set({
|
||||||
});
|
[this.id]: encodeStoredItem(this.map)
|
||||||
|
});
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
@@ -52,7 +56,12 @@ class MapIO {
|
|||||||
}
|
}
|
||||||
|
|
||||||
delete(key) {
|
delete(key) {
|
||||||
|
// Proxy to map
|
||||||
this.map.delete(key);
|
this.map.delete(key);
|
||||||
|
// Store updated map locally
|
||||||
|
chrome.storage.sync.set({
|
||||||
|
[this.id]: encodeStoredItem(this.map)
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user