From 4907be7738102f30f1c893c5784c31231f83fc9b Mon Sep 17 00:00:00 2001 From: Ajay Ramachandran Date: Sat, 1 Feb 2020 19:25:40 -0500 Subject: [PATCH] Fixed maps not being handled properly --- src/SB.ts | 6 +++--- src/popup.ts | 53 ++++++++++++++++++++++++++-------------------------- 2 files changed, 30 insertions(+), 29 deletions(-) diff --git a/src/SB.ts b/src/SB.ts index 2cbb9266..019ef8e1 100644 --- a/src/SB.ts +++ b/src/SB.ts @@ -14,7 +14,7 @@ class SBMap extends Map { // Import all entries if they were given if (entries !== undefined) { 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) => { for (const key in changes) { 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() { diff --git a/src/popup.ts b/src/popup.ts index f477c15d..e07650a8 100644 --- a/src/popup.ts +++ b/src/popup.ts @@ -323,17 +323,17 @@ async function runThePopup(messageListener?: MessageListener) { } function sendSponsorStartMessage() { - //the content script will get the message if a YouTube page is open - messageHandler.query({ - active: true, - currentWindow: true - }, tabs => { - messageHandler.sendMessage( - tabs[0].id, - {from: 'popup', message: 'sponsorStart'}, - startSponsorCallback - ); - }); + //the content script will get the message if a YouTube page is open + messageHandler.query({ + active: true, + currentWindow: true + }, tabs => { + messageHandler.sendMessage( + tabs[0].id, + {from: 'popup', message: 'sponsorStart'}, + startSponsorCallback + ); + }); } function startSponsorCallback(response) { @@ -347,18 +347,19 @@ async function runThePopup(messageListener?: MessageListener) { let localStartTimeChosen = startTimeChosen; SB.config.sponsorTimes.set(currentVideoID, sponsorTimes); - //send a message to the client script - if (localStartTimeChosen) { - messageHandler.query({ - active: true, - currentWindow: true - }, tabs => { - messageHandler.sendMessage( - tabs[0].id, - {message: "sponsorDataChanged"} - ); - }); - } + + //send a message to the client script + if (localStartTimeChosen) { + messageHandler.query({ + active: true, + currentWindow: true + }, tabs => { + messageHandler.sendMessage( + tabs[0].id, + {message: "sponsorDataChanged"} + ); + }); + } updateStartTimeChosen(); @@ -999,7 +1000,7 @@ async function runThePopup(messageListener?: MessageListener) { PageElements.downloadedSponsorMessageTimes.style.fontWeight = "bold"; //save this - PageElements.config.whitelistedChannels = whitelistedChannels; + SB.config.whitelistedChannels = whitelistedChannels; //send a message to the client messageHandler.query({ @@ -1046,7 +1047,7 @@ async function runThePopup(messageListener?: MessageListener) { PageElements.downloadedSponsorMessageTimes.style.fontWeight = "unset"; //save this - PageElements.config.whitelistedChannels = whitelistedChannels; + SB.config.whitelistedChannels = whitelistedChannels; //send a message to the client messageHandler.query({ @@ -1069,7 +1070,7 @@ async function runThePopup(messageListener?: MessageListener) { * Should skipping be disabled (visuals stay) */ function toggleSkipping(disabled) { - PageElements.config.disableSkipping = disabled; + SB.config.disableSkipping = disabled; let hiddenButton = PageElements.disableSkipping; let shownButton = PageElements.enableSkipping;