mirror of
https://github.com/ajayyy/SponsorBlock.git
synced 2025-12-06 19:47:04 +03:00
Reverted back <Not working>
This commit is contained in:
44
SB.js
44
SB.js
@@ -17,6 +17,46 @@ function strParser(data) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class ListenerMap extends Map {
|
||||||
|
constructor(name) {
|
||||||
|
super();
|
||||||
|
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
set(key, value) {
|
||||||
|
super.set(key, value);
|
||||||
|
|
||||||
|
this.updateListener(this.name, this);
|
||||||
|
}
|
||||||
|
|
||||||
|
delete(key) {
|
||||||
|
this.updateListener(this.name, this);
|
||||||
|
|
||||||
|
return super.set(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
clear() {
|
||||||
|
return super.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
forEach(callbackfn) {
|
||||||
|
return super.forEach(callbackfn);
|
||||||
|
}
|
||||||
|
|
||||||
|
get(key) {
|
||||||
|
return super.get(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
has(key) {
|
||||||
|
return super.has(key);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function mapHandler(name, object) {
|
||||||
|
SB.config[name] = storeEncode(object);
|
||||||
|
}
|
||||||
|
|
||||||
function configProxy() {
|
function configProxy() {
|
||||||
chrome.storage.onChanged.addListener((changes, namespace) => {
|
chrome.storage.onChanged.addListener((changes, namespace) => {
|
||||||
for (key in changes) {
|
for (key in changes) {
|
||||||
@@ -57,12 +97,14 @@ function migrate() { // Convert sponsorTimes format
|
|||||||
async function config() {
|
async function config() {
|
||||||
await fetchConfig();
|
await fetchConfig();
|
||||||
addDefaults();
|
addDefaults();
|
||||||
|
// Setup sponsorTime listener
|
||||||
|
SB.localconfig.sponsorTimes.updateListener = mapHandler;
|
||||||
SB.config = configProxy();
|
SB.config = configProxy();
|
||||||
migrate();
|
migrate();
|
||||||
}
|
}
|
||||||
|
|
||||||
SB.defaults = {
|
SB.defaults = {
|
||||||
"sponsorTimes": new Map(),
|
"sponsorTimes": new ListenerMap("sponsorTimes"),
|
||||||
"startSponsorKeybind": ";",
|
"startSponsorKeybind": ";",
|
||||||
"submitKeybind": "'",
|
"submitKeybind": "'",
|
||||||
"minutesSaved": 0,
|
"minutesSaved": 0,
|
||||||
|
|||||||
Reference in New Issue
Block a user