mirror of
https://github.com/ajayyy/SponsorBlock.git
synced 2025-12-16 16:37:18 +03:00
Formatting fixes
This commit is contained in:
42
SB.js
42
SB.js
@@ -4,27 +4,6 @@ Map.prototype.toJSON = function() {
|
|||||||
return Array.from(this.entries());
|
return Array.from(this.entries());
|
||||||
};
|
};
|
||||||
|
|
||||||
function storeEncode(data) {
|
|
||||||
if(!(data instanceof Map)) return data;
|
|
||||||
return JSON.stringify(data);
|
|
||||||
}
|
|
||||||
|
|
||||||
function mapDecode(data, key) {
|
|
||||||
if(typeof data !== "string") return data;
|
|
||||||
try {
|
|
||||||
let str = JSON.parse(data);
|
|
||||||
if(!Array.isArray(str)) return data;
|
|
||||||
return new Map(str);
|
|
||||||
} catch(e) {
|
|
||||||
return data
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function mapProxy(data, key) {
|
|
||||||
if(!(data instanceof Map)) return data;
|
|
||||||
return new mapIO(key);
|
|
||||||
}
|
|
||||||
|
|
||||||
class mapIO extends Map {
|
class mapIO extends Map {
|
||||||
constructor(id) {
|
constructor(id) {
|
||||||
super();
|
super();
|
||||||
@@ -73,6 +52,27 @@ class mapIO extends Map {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function storeEncode(data) {
|
||||||
|
if(!(data instanceof Map)) return data;
|
||||||
|
return JSON.stringify(data);
|
||||||
|
}
|
||||||
|
|
||||||
|
function mapDecode(data, key) {
|
||||||
|
if(typeof data !== "string") return data;
|
||||||
|
try {
|
||||||
|
let str = JSON.parse(data);
|
||||||
|
if(!Array.isArray(str)) return data;
|
||||||
|
return new Map(str);
|
||||||
|
} catch(e) {
|
||||||
|
return data
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function mapProxy(data, key) {
|
||||||
|
if(!(data instanceof Map)) return data;
|
||||||
|
return new mapIO(key);
|
||||||
|
}
|
||||||
|
|
||||||
function configProxy() {
|
function configProxy() {
|
||||||
chrome.storage.onChanged.addListener((changes, namespace) => {
|
chrome.storage.onChanged.addListener((changes, namespace) => {
|
||||||
for (key in changes) {
|
for (key in changes) {
|
||||||
|
|||||||
Reference in New Issue
Block a user