mirror of
https://github.com/ajayyy/SponsorBlock.git
synced 2025-12-11 22:17:21 +03:00
Fixed maps not being handled properly
This commit is contained in:
@@ -14,7 +14,7 @@ class SBMap<T, U> extends Map {
|
|||||||
// Import all entries if they were given
|
// Import all entries if they were given
|
||||||
if (entries !== undefined) {
|
if (entries !== undefined) {
|
||||||
for (const item of entries) {
|
for (const item of entries) {
|
||||||
this.set(entries[0], entries[1])
|
this.set(item[0], item[1])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -142,7 +142,7 @@ function decodeStoredItem(data) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function configProxy(): void {
|
function configProxy(): any {
|
||||||
chrome.storage.onChanged.addListener((changes, namespace) => {
|
chrome.storage.onChanged.addListener((changes, namespace) => {
|
||||||
for (const key in changes) {
|
for (const key in changes) {
|
||||||
SB.localConfig[key] = decodeStoredItem(changes[key].newValue);
|
SB.localConfig[key] = decodeStoredItem(changes[key].newValue);
|
||||||
@@ -179,7 +179,7 @@ function configProxy(): void {
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return new Proxy({handler}, handler);
|
return new Proxy({}, handler);
|
||||||
}
|
}
|
||||||
|
|
||||||
function fetchConfig() {
|
function fetchConfig() {
|
||||||
|
|||||||
53
src/popup.ts
53
src/popup.ts
@@ -323,17 +323,17 @@ async function runThePopup(messageListener?: MessageListener) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function sendSponsorStartMessage() {
|
function sendSponsorStartMessage() {
|
||||||
//the content script will get the message if a YouTube page is open
|
//the content script will get the message if a YouTube page is open
|
||||||
messageHandler.query({
|
messageHandler.query({
|
||||||
active: true,
|
active: true,
|
||||||
currentWindow: true
|
currentWindow: true
|
||||||
}, tabs => {
|
}, tabs => {
|
||||||
messageHandler.sendMessage(
|
messageHandler.sendMessage(
|
||||||
tabs[0].id,
|
tabs[0].id,
|
||||||
{from: 'popup', message: 'sponsorStart'},
|
{from: 'popup', message: 'sponsorStart'},
|
||||||
startSponsorCallback
|
startSponsorCallback
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function startSponsorCallback(response) {
|
function startSponsorCallback(response) {
|
||||||
@@ -347,18 +347,19 @@ async function runThePopup(messageListener?: MessageListener) {
|
|||||||
|
|
||||||
let localStartTimeChosen = startTimeChosen;
|
let localStartTimeChosen = startTimeChosen;
|
||||||
SB.config.sponsorTimes.set(currentVideoID, sponsorTimes);
|
SB.config.sponsorTimes.set(currentVideoID, sponsorTimes);
|
||||||
//send a message to the client script
|
|
||||||
if (localStartTimeChosen) {
|
//send a message to the client script
|
||||||
messageHandler.query({
|
if (localStartTimeChosen) {
|
||||||
active: true,
|
messageHandler.query({
|
||||||
currentWindow: true
|
active: true,
|
||||||
}, tabs => {
|
currentWindow: true
|
||||||
messageHandler.sendMessage(
|
}, tabs => {
|
||||||
tabs[0].id,
|
messageHandler.sendMessage(
|
||||||
{message: "sponsorDataChanged"}
|
tabs[0].id,
|
||||||
);
|
{message: "sponsorDataChanged"}
|
||||||
});
|
);
|
||||||
}
|
});
|
||||||
|
}
|
||||||
|
|
||||||
updateStartTimeChosen();
|
updateStartTimeChosen();
|
||||||
|
|
||||||
@@ -999,7 +1000,7 @@ async function runThePopup(messageListener?: MessageListener) {
|
|||||||
PageElements.downloadedSponsorMessageTimes.style.fontWeight = "bold";
|
PageElements.downloadedSponsorMessageTimes.style.fontWeight = "bold";
|
||||||
|
|
||||||
//save this
|
//save this
|
||||||
PageElements.config.whitelistedChannels = whitelistedChannels;
|
SB.config.whitelistedChannels = whitelistedChannels;
|
||||||
|
|
||||||
//send a message to the client
|
//send a message to the client
|
||||||
messageHandler.query({
|
messageHandler.query({
|
||||||
@@ -1046,7 +1047,7 @@ async function runThePopup(messageListener?: MessageListener) {
|
|||||||
PageElements.downloadedSponsorMessageTimes.style.fontWeight = "unset";
|
PageElements.downloadedSponsorMessageTimes.style.fontWeight = "unset";
|
||||||
|
|
||||||
//save this
|
//save this
|
||||||
PageElements.config.whitelistedChannels = whitelistedChannels;
|
SB.config.whitelistedChannels = whitelistedChannels;
|
||||||
|
|
||||||
//send a message to the client
|
//send a message to the client
|
||||||
messageHandler.query({
|
messageHandler.query({
|
||||||
@@ -1069,7 +1070,7 @@ async function runThePopup(messageListener?: MessageListener) {
|
|||||||
* Should skipping be disabled (visuals stay)
|
* Should skipping be disabled (visuals stay)
|
||||||
*/
|
*/
|
||||||
function toggleSkipping(disabled) {
|
function toggleSkipping(disabled) {
|
||||||
PageElements.config.disableSkipping = disabled;
|
SB.config.disableSkipping = disabled;
|
||||||
|
|
||||||
let hiddenButton = PageElements.disableSkipping;
|
let hiddenButton = PageElements.disableSkipping;
|
||||||
let shownButton = PageElements.enableSkipping;
|
let shownButton = PageElements.enableSkipping;
|
||||||
|
|||||||
Reference in New Issue
Block a user