Made the extension successfully build

This commit is contained in:
Ajay Ramachandran
2020-02-01 19:18:53 -05:00
parent 17381e7deb
commit 23141aa624
11 changed files with 117 additions and 132 deletions

View File

@@ -13,13 +13,8 @@
], ],
"all_frames": true, "all_frames": true,
"js": [ "js": [
"config.js", "./js/vendor.js",
"SB.js", "./js/content.js"
"utils/previewBar.js",
"utils/skipNotice.js",
"utils.js",
"content.js",
"popup.js"
], ],
"css": [ "css": [
"content.css", "content.css",
@@ -58,10 +53,8 @@
}, },
"background": { "background": {
"scripts":[ "scripts":[
"config.js", "./js/vendor.js",
"SB.js", "./js/background.js"
"utils.js",
"background.js"
], ],
"persistent": false "persistent": false
}, },

View File

@@ -7,7 +7,7 @@ async function init() {
SB.configListeners.push(optionsConfigUpdateListener); SB.configListeners.push(optionsConfigUpdateListener);
} }
await wait(() => SB.config !== undefined); await wait(() => SB.config !== null);
// Set all of the toggle options to the correct option // Set all of the toggle options to the correct option
let optionsContainer = document.getElementById("options"); let optionsContainer = document.getElementById("options");

View File

@@ -1,7 +1,6 @@
<html> <html>
<head> <head>
<title>__MSG_openPopup__</title> <title>__MSG_openPopup__</title>
<script src="SB.js"></script>
<link id="sponsorBlockPopupFont" rel="stylesheet" type="text/css" href="/libs/Source+Sans+Pro.css"/> <link id="sponsorBlockPopupFont" rel="stylesheet" type="text/css" href="/libs/Source+Sans+Pro.css"/>
<link id="sponsorBlockStyleSheet" rel="stylesheet" type="text/css" href="popup.css"/> <link id="sponsorBlockStyleSheet" rel="stylesheet" type="text/css" href="popup.css"/>
</head> </head>
@@ -210,7 +209,6 @@
</body> </body>
<!-- Scripts that need to load after the html --> <!-- Scripts that need to load after the html -->
<script src="config.js"></script> <script src="./js/vendor.js"></script>
<script src="utils.js"></script> <script src="./js/popup.js"></script>
<script src="popup.js"></script>
</html> </html>

View File

@@ -51,8 +51,8 @@ var SB: SBObject = {
"invidiousUpdateInfoShowCount": 0, "invidiousUpdateInfoShowCount": 0,
"autoUpvote": true "autoUpvote": true
}, },
localConfig: {}, localConfig: null,
config: {} config: null
}; };
// Function setup // Function setup
@@ -113,7 +113,7 @@ class MapIO {
* A SBMap cannot be stored in the chrome storage. * A SBMap cannot be stored in the chrome storage.
* This data will be encoded into an array instead as specified by the toJSON function. * This data will be encoded into an array instead as specified by the toJSON function.
* *
* @param {*} data * @param data
*/ */
function encodeStoredItem(data) { function encodeStoredItem(data) {
// if data is SBMap convert to json for storing // if data is SBMap convert to json for storing

View File

@@ -12,7 +12,7 @@ var contentScriptRegistrations = {};
// Register content script if needed // Register content script if needed
if (utils.isFirefox()) { if (utils.isFirefox()) {
utils.wait(() => SB.config !== undefined).then(function() { utils.wait(() => SB.config !== null).then(function() {
if (SB.config.supportInvidious) utils.setupExtraSiteContentScripts(); if (SB.config.supportInvidious) utils.setupExtraSiteContentScripts();
}); });
} }

View File

@@ -427,13 +427,13 @@ function getYouTubeVideoID(url: string) {
return false; return false;
} }
//Check if valid hostname // Check if valid hostname
if (SB.config && SB.config.invidiousInstances.includes(urlObject.host)) { if (SB.config && SB.config.invidiousInstances.includes(urlObject.host)) {
onInvidious = true; onInvidious = true;
} else if (!["www.youtube.com", "www.youtube-nocookie.com"].includes(urlObject.host)) { } else if (!["www.youtube.com", "www.youtube-nocookie.com"].includes(urlObject.host)) {
if (!SB.config) { if (!SB.config) {
// Call this later, in case this is an Invidious tab // Call this later, in case this is an Invidious tab
this.wait(() => SB.config !== undefined).then(() => this.videoIDChange(this.getYouTubeVideoID(url))); this.wait(() => SB.config !== null).then(() => this.videoIDChange(this.getYouTubeVideoID(url)));
} }
return false return false

View File

@@ -42,9 +42,9 @@ async function runThePopup(messageListener?: MessageListener) {
utils.localizeHtmlPage(); utils.localizeHtmlPage();
await utils.wait(() => SB.config !== undefined); await utils.wait(() => SB.config !== null);
var OptionsElements: any = {}; var PageElements: any = {};
["sponsorStart", ["sponsorStart",
// Top toggles // Top toggles
@@ -100,22 +100,22 @@ async function runThePopup(messageListener?: MessageListener) {
"videoFound", "videoFound",
"sponsorMessageTimes", "sponsorMessageTimes",
"downloadedSponsorMessageTimes", "downloadedSponsorMessageTimes",
].forEach(id => OptionsElements[id] = document.getElementById(id)); ].forEach(id => PageElements[id] = document.getElementById(id));
//setup click listeners //setup click listeners
OptionsElements.sponsorStart.addEventListener("click", sendSponsorStartMessage); PageElements.sponsorStart.addEventListener("click", sendSponsorStartMessage);
OptionsElements.whitelistChannel.addEventListener("click", whitelistChannel); PageElements.whitelistChannel.addEventListener("click", whitelistChannel);
OptionsElements.unwhitelistChannel.addEventListener("click", unwhitelistChannel); PageElements.unwhitelistChannel.addEventListener("click", unwhitelistChannel);
OptionsElements.disableSkipping.addEventListener("click", () => toggleSkipping(true)); PageElements.disableSkipping.addEventListener("click", () => toggleSkipping(true));
OptionsElements.enableSkipping.addEventListener("click", () => toggleSkipping(false)); PageElements.enableSkipping.addEventListener("click", () => toggleSkipping(false));
OptionsElements.clearTimes.addEventListener("click", clearTimes); PageElements.clearTimes.addEventListener("click", clearTimes);
OptionsElements.submitTimes.addEventListener("click", submitTimes); PageElements.submitTimes.addEventListener("click", submitTimes);
OptionsElements.showNoticeAgain.addEventListener("click", showNoticeAgain); PageElements.showNoticeAgain.addEventListener("click", showNoticeAgain);
OptionsElements.setUsernameButton.addEventListener("click", setUsernameButton); PageElements.setUsernameButton.addEventListener("click", setUsernameButton);
OptionsElements.submitUsername.addEventListener("click", submitUsername); PageElements.submitUsername.addEventListener("click", submitUsername);
OptionsElements.optionsButton.addEventListener("click", openOptions); PageElements.optionsButton.addEventListener("click", openOptions);
OptionsElements.reportAnIssue.addEventListener("click", reportAnIssue); PageElements.reportAnIssue.addEventListener("click", reportAnIssue);
OptionsElements.hideDiscordButton.addEventListener("click", hideDiscordButton); PageElements.hideDiscordButton.addEventListener("click", hideDiscordButton);
//if true, the button now selects the end time //if true, the button now selects the end time
let startTimeChosen = false; let startTimeChosen = false;
@@ -132,7 +132,7 @@ async function runThePopup(messageListener?: MessageListener) {
let hideDiscordLaunches = SB.config.hideDiscordLaunches; let hideDiscordLaunches = SB.config.hideDiscordLaunches;
//only if less than 10 launches //only if less than 10 launches
if (hideDiscordLaunches == undefined || hideDiscordLaunches < 10) { if (hideDiscordLaunches == undefined || hideDiscordLaunches < 10) {
OptionsElements.discordButtonContainer.style.display = null; PageElements.discordButtonContainer.style.display = null;
if (hideDiscordLaunches == undefined) { if (hideDiscordLaunches == undefined) {
hideDiscordLaunches = 1; hideDiscordLaunches = 1;
@@ -144,26 +144,26 @@ async function runThePopup(messageListener?: MessageListener) {
//show proper disable skipping button //show proper disable skipping button
let disableSkipping = SB.config.disableSkipping; let disableSkipping = SB.config.disableSkipping;
if (disableSkipping != undefined && disableSkipping) { if (disableSkipping != undefined && disableSkipping) {
OptionsElements.disableSkipping.style.display = "none"; PageElements.disableSkipping.style.display = "none";
OptionsElements.enableSkipping.style.display = "unset"; PageElements.enableSkipping.style.display = "unset";
} }
//if the don't show notice again variable is true, an option to //if the don't show notice again variable is true, an option to
// disable should be available // disable should be available
let dontShowNotice = SB.config.dontShowNotice; let dontShowNotice = SB.config.dontShowNotice;
if (dontShowNotice != undefined && dontShowNotice) { if (dontShowNotice != undefined && dontShowNotice) {
OptionsElements.showNoticeAgain.style.display = "unset"; PageElements.showNoticeAgain.style.display = "unset";
} }
//get the amount of times this user has contributed and display it to thank them //get the amount of times this user has contributed and display it to thank them
if (SB.config.sponsorTimesContributed != undefined) { if (SB.config.sponsorTimesContributed != undefined) {
if (SB.config.sponsorTimesContributed > 1) { if (SB.config.sponsorTimesContributed > 1) {
OptionsElements.sponsorTimesContributionsDisplayEndWord.innerText = chrome.i18n.getMessage("Sponsors"); PageElements.sponsorTimesContributionsDisplayEndWord.innerText = chrome.i18n.getMessage("Sponsors");
} else { } else {
OptionsElements.sponsorTimesContributionsDisplayEndWord.innerText = chrome.i18n.getMessage("Sponsor"); PageElements.sponsorTimesContributionsDisplayEndWord.innerText = chrome.i18n.getMessage("Sponsor");
} }
OptionsElements.sponsorTimesContributionsDisplay.innerText = SB.config.sponsorTimesContributed; PageElements.sponsorTimesContributionsDisplay.innerText = SB.config.sponsorTimesContributed;
OptionsElements.sponsorTimesContributionsContainer.style.display = "unset"; PageElements.sponsorTimesContributionsContainer.style.display = "unset";
//get the userID //get the userID
let userID = SB.config.userID; let userID = SB.config.userID;
@@ -175,13 +175,13 @@ async function runThePopup(messageListener?: MessageListener) {
let viewCount = JSON.parse(xmlhttp.responseText).viewCount; let viewCount = JSON.parse(xmlhttp.responseText).viewCount;
if (viewCount != 0) { if (viewCount != 0) {
if (viewCount > 1) { if (viewCount > 1) {
OptionsElements.sponsorTimesViewsDisplayEndWord.innerText = chrome.i18n.getMessage("Segments"); PageElements.sponsorTimesViewsDisplayEndWord.innerText = chrome.i18n.getMessage("Segments");
} else { } else {
OptionsElements.sponsorTimesViewsDisplayEndWord.innerText = chrome.i18n.getMessage("Segment"); PageElements.sponsorTimesViewsDisplayEndWord.innerText = chrome.i18n.getMessage("Segment");
} }
OptionsElements.sponsorTimesViewsDisplay.innerText = viewCount; PageElements.sponsorTimesViewsDisplay.innerText = viewCount;
OptionsElements.sponsorTimesViewsContainer.style.display = "unset"; PageElements.sponsorTimesViewsContainer.style.display = "unset";
} }
} }
}); });
@@ -192,13 +192,13 @@ async function runThePopup(messageListener?: MessageListener) {
let minutesSaved = JSON.parse(xmlhttp.responseText).timeSaved; let minutesSaved = JSON.parse(xmlhttp.responseText).timeSaved;
if (minutesSaved != 0) { if (minutesSaved != 0) {
if (minutesSaved != 1) { if (minutesSaved != 1) {
OptionsElements.sponsorTimesOthersTimeSavedEndWord.innerText = chrome.i18n.getMessage("minsLower"); PageElements.sponsorTimesOthersTimeSavedEndWord.innerText = chrome.i18n.getMessage("minsLower");
} else { } else {
OptionsElements.sponsorTimesOthersTimeSavedEndWord.innerText = chrome.i18n.getMessage("minLower"); PageElements.sponsorTimesOthersTimeSavedEndWord.innerText = chrome.i18n.getMessage("minLower");
} }
OptionsElements.sponsorTimesOthersTimeSavedDisplay.innerText = getFormattedHours(minutesSaved); PageElements.sponsorTimesOthersTimeSavedDisplay.innerText = getFormattedHours(minutesSaved);
OptionsElements.sponsorTimesOthersTimeSavedContainer.style.display = "unset"; PageElements.sponsorTimesOthersTimeSavedContainer.style.display = "unset";
} }
} }
}); });
@@ -208,25 +208,25 @@ async function runThePopup(messageListener?: MessageListener) {
//get the amount of times this user has skipped a sponsor //get the amount of times this user has skipped a sponsor
if (SB.config.skipCount != undefined) { if (SB.config.skipCount != undefined) {
if (SB.config.skipCount != 1) { if (SB.config.skipCount != 1) {
OptionsElements.sponsorTimesSkipsDoneEndWord.innerText = chrome.i18n.getMessage("Sponsors"); PageElements.sponsorTimesSkipsDoneEndWord.innerText = chrome.i18n.getMessage("Sponsors");
} else { } else {
OptionsElements.sponsorTimesSkipsDoneEndWord.innerText = chrome.i18n.getMessage("Sponsor"); PageElements.sponsorTimesSkipsDoneEndWord.innerText = chrome.i18n.getMessage("Sponsor");
} }
OptionsElements.sponsorTimesSkipsDoneDisplay.innerText = SB.config.skipCount; PageElements.sponsorTimesSkipsDoneDisplay.innerText = SB.config.skipCount;
OptionsElements.sponsorTimesSkipsDoneContainer.style.display = "unset"; PageElements.sponsorTimesSkipsDoneContainer.style.display = "unset";
} }
//get the amount of time this user has saved. //get the amount of time this user has saved.
if (SB.config.minutesSaved != undefined) { if (SB.config.minutesSaved != undefined) {
if (SB.config.minutesSaved != 1) { if (SB.config.minutesSaved != 1) {
OptionsElements.sponsorTimeSavedEndWord.innerText = chrome.i18n.getMessage("minsLower"); PageElements.sponsorTimeSavedEndWord.innerText = chrome.i18n.getMessage("minsLower");
} else { } else {
OptionsElements.sponsorTimeSavedEndWord.innerText = chrome.i18n.getMessage("minLower"); PageElements.sponsorTimeSavedEndWord.innerText = chrome.i18n.getMessage("minLower");
} }
OptionsElements.sponsorTimeSavedDisplay.innerText = getFormattedHours(SB.config.minutesSaved); PageElements.sponsorTimeSavedDisplay.innerText = getFormattedHours(SB.config.minutesSaved);
OptionsElements.sponsorTimeSavedContainer.style.display = "unset"; PageElements.sponsorTimeSavedContainer.style.display = "unset";
} }
messageHandler.query({ messageHandler.query({
@@ -258,7 +258,7 @@ async function runThePopup(messageListener?: MessageListener) {
if (sponsorTimesStorage != undefined && sponsorTimesStorage.length > 0) { if (sponsorTimesStorage != undefined && sponsorTimesStorage.length > 0) {
if (sponsorTimesStorage[sponsorTimesStorage.length - 1] != undefined && sponsorTimesStorage[sponsorTimesStorage.length - 1].length < 2) { if (sponsorTimesStorage[sponsorTimesStorage.length - 1] != undefined && sponsorTimesStorage[sponsorTimesStorage.length - 1].length < 2) {
startTimeChosen = true; startTimeChosen = true;
OptionsElements.sponsorStart.innerHTML = chrome.i18n.getMessage("sponsorEnd"); PageElements.sponsorStart.innerHTML = chrome.i18n.getMessage("sponsorEnd");
} }
sponsorTimes = sponsorTimesStorage; sponsorTimes = sponsorTimesStorage;
@@ -266,7 +266,7 @@ async function runThePopup(messageListener?: MessageListener) {
displaySponsorTimes(); displaySponsorTimes();
//show submission section //show submission section
OptionsElements.submissionSection.style.display = "unset"; PageElements.submissionSection.style.display = "unset";
showSubmitTimesIfNecessary(); showSubmitTimesIfNecessary();
} }
@@ -289,15 +289,15 @@ async function runThePopup(messageListener?: MessageListener) {
//if request is undefined, then the page currently being browsed is not YouTube //if request is undefined, then the page currently being browsed is not YouTube
if (request != undefined) { if (request != undefined) {
//remove loading text //remove loading text
OptionsElements.mainControls.style.display = "unset" PageElements.mainControls.style.display = "unset"
OptionsElements.loadingIndicator.style.display = "none"; PageElements.loadingIndicator.style.display = "none";
if (request.found) { if (request.found) {
OptionsElements.videoFound.innerHTML = chrome.i18n.getMessage("sponsorFound"); PageElements.videoFound.innerHTML = chrome.i18n.getMessage("sponsorFound");
displayDownloadedSponsorTimes(request); displayDownloadedSponsorTimes(request);
} else { } else {
OptionsElements.videoFound.innerHTML = chrome.i18n.getMessage("sponsor404"); PageElements.videoFound.innerHTML = chrome.i18n.getMessage("sponsor404");
} }
} }
@@ -311,11 +311,11 @@ async function runThePopup(messageListener?: MessageListener) {
{message: 'isChannelWhitelisted'}, {message: 'isChannelWhitelisted'},
function(response) { function(response) {
if (response.value) { if (response.value) {
OptionsElements.whitelistChannel.style.display = "none"; PageElements.whitelistChannel.style.display = "none";
OptionsElements.unwhitelistChannel.style.display = "unset"; PageElements.unwhitelistChannel.style.display = "unset";
OptionsElements.downloadedSponsorMessageTimes.innerText = chrome.i18n.getMessage("channelWhitelisted"); PageElements.downloadedSponsorMessageTimes.innerText = chrome.i18n.getMessage("channelWhitelisted");
OptionsElements.downloadedSponsorMessageTimes.style.fontWeight = "bold"; PageElements.downloadedSponsorMessageTimes.style.fontWeight = "bold";
} }
}); });
} }
@@ -366,7 +366,7 @@ async function runThePopup(messageListener?: MessageListener) {
displaySponsorTimes(); displaySponsorTimes();
//show submission section //show submission section
OptionsElements.submissionSection.style.display = "unset"; PageElements.submissionSection.style.display = "unset";
showSubmitTimesIfNecessary(); showSubmitTimesIfNecessary();
} }
@@ -374,20 +374,20 @@ async function runThePopup(messageListener?: MessageListener) {
//display the video times from the array //display the video times from the array
function displaySponsorTimes() { function displaySponsorTimes() {
//remove all children //remove all children
while (OptionsElements.sponsorMessageTimes.firstChild) { while (PageElements.sponsorMessageTimes.firstChild) {
OptionsElements.sponsorMessageTimes.removeChild(OptionsElements.sponsorMessageTimes.firstChild); PageElements.sponsorMessageTimes.removeChild(PageElements.sponsorMessageTimes.firstChild);
} }
//add sponsor times //add sponsor times
OptionsElements.sponsorMessageTimes.appendChild(getSponsorTimesMessageDiv(sponsorTimes)); PageElements.sponsorMessageTimes.appendChild(getSponsorTimesMessageDiv(sponsorTimes));
} }
//display the video times from the array at the top, in a different section //display the video times from the array at the top, in a different section
function displayDownloadedSponsorTimes(request) { function displayDownloadedSponsorTimes(request) {
if (request.sponsorTimes != undefined) { if (request.sponsorTimes != undefined) {
//set it to the message //set it to the message
if (OptionsElements.downloadedSponsorMessageTimes.innerText != chrome.i18n.getMessage("channelWhitelisted")) { if (PageElements.downloadedSponsorMessageTimes.innerText != chrome.i18n.getMessage("channelWhitelisted")) {
OptionsElements.downloadedSponsorMessageTimes.innerText = getSponsorTimesMessage(request.sponsorTimes); PageElements.downloadedSponsorMessageTimes.innerText = getSponsorTimesMessage(request.sponsorTimes);
} }
//add them as buttons to the issue reporting container //add them as buttons to the issue reporting container
@@ -789,8 +789,8 @@ async function runThePopup(messageListener?: MessageListener) {
function submitTimes() { function submitTimes() {
//make info message say loading //make info message say loading
OptionsElements.submitTimesInfoMessage.innerText = chrome.i18n.getMessage("Loading"); PageElements.submitTimesInfoMessage.innerText = chrome.i18n.getMessage("Loading");
OptionsElements.submitTimesInfoMessageContainer.style.display = "unset"; PageElements.submitTimesInfoMessageContainer.style.display = "unset";
if (sponsorTimes.length > 0) { if (sponsorTimes.length > 0) {
chrome.runtime.sendMessage({ chrome.runtime.sendMessage({
@@ -800,14 +800,14 @@ async function runThePopup(messageListener?: MessageListener) {
if (response != undefined) { if (response != undefined) {
if (response.statusCode == 200) { if (response.statusCode == 200) {
//hide loading message //hide loading message
OptionsElements.submitTimesInfoMessageContainer.style.display = "none"; PageElements.submitTimesInfoMessageContainer.style.display = "none";
clearTimes(); clearTimes();
} else { } else {
document.getElementById("submitTimesInfoMessage").innerText = utils.getErrorMessage(response.statusCode); document.getElementById("submitTimesInfoMessage").innerText = utils.getErrorMessage(response.statusCode);
document.getElementById("submitTimesInfoMessageContainer").style.display = "unset"; document.getElementById("submitTimesInfoMessageContainer").style.display = "unset";
OptionsElements.submitTimesInfoMessageContainer.style.display = "unset"; PageElements.submitTimesInfoMessageContainer.style.display = "unset";
} }
} }
}); });
@@ -817,14 +817,14 @@ async function runThePopup(messageListener?: MessageListener) {
function showNoticeAgain() { function showNoticeAgain() {
SB.config.dontShowNotice = false; SB.config.dontShowNotice = false;
OptionsElements.showNoticeAgain.style.display = "none"; PageElements.showNoticeAgain.style.display = "none";
} }
function updateStartTimeChosen() { function updateStartTimeChosen() {
//update startTimeChosen letiable //update startTimeChosen letiable
if (!startTimeChosen) { if (!startTimeChosen) {
startTimeChosen = true; startTimeChosen = true;
OptionsElements.sponsorStart.innerHTML = chrome.i18n.getMessage("sponsorEnd"); PageElements.sponsorStart.innerHTML = chrome.i18n.getMessage("sponsorEnd");
} else { } else {
resetStartTimeChosen(); resetStartTimeChosen();
} }
@@ -833,7 +833,7 @@ async function runThePopup(messageListener?: MessageListener) {
//set it to false //set it to false
function resetStartTimeChosen() { function resetStartTimeChosen() {
startTimeChosen = false; startTimeChosen = false;
OptionsElements.sponsorStart.innerHTML = chrome.i18n.getMessage("sponsorStart"); PageElements.sponsorStart.innerHTML = chrome.i18n.getMessage("sponsorStart");
} }
//hides and shows the submit times button when needed //hides and shows the submit times button when needed
@@ -858,22 +858,22 @@ async function runThePopup(messageListener?: MessageListener) {
//get username from the server //get username from the server
utils.sendRequestToServer("GET", "/api/getUsername?userID=" + SB.config.userID, function (xmlhttp, error) { utils.sendRequestToServer("GET", "/api/getUsername?userID=" + SB.config.userID, function (xmlhttp, error) {
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) { if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
OptionsElements.usernameInput.value = JSON.parse(xmlhttp.responseText).userName; PageElements.usernameInput.value = JSON.parse(xmlhttp.responseText).userName;
OptionsElements.submitUsername.style.display = "unset"; PageElements.submitUsername.style.display = "unset";
OptionsElements.usernameInput.style.display = "unset"; PageElements.usernameInput.style.display = "unset";
OptionsElements.setUsernameContainer.style.display = "none"; PageElements.setUsernameContainer.style.display = "none";
OptionsElements.setUsername.style.display = "unset"; PageElements.setUsername.style.display = "unset";
OptionsElements PageElements
OptionsElements.setUsernameStatusContainer.style.display = "none"; PageElements.setUsernameStatusContainer.style.display = "none";
} else if (xmlhttp.readyState == 4) { } else if (xmlhttp.readyState == 4) {
OptionsElements.setUsername.style.display = "unset"; PageElements.setUsername.style.display = "unset";
OptionsElements.submitUsername.style.display = "none"; PageElements.submitUsername.style.display = "none";
OptionsElements.usernameInput.style.display = "none"; PageElements.usernameInput.style.display = "none";
OptionsElements.setUsernameStatusContainer.style.display = "unset"; PageElements.setUsernameStatusContainer.style.display = "unset";
OptionsElements.setUsernameStatus.innerText = utils.getErrorMessage(xmlhttp.status); PageElements.setUsernameStatus.innerText = utils.getErrorMessage(xmlhttp.status);
} }
}); });
} }
@@ -881,25 +881,25 @@ async function runThePopup(messageListener?: MessageListener) {
//submit the new username //submit the new username
function submitUsername() { function submitUsername() {
//add loading indicator //add loading indicator
OptionsElements.setUsernameStatusContainer.style.display = "unset"; PageElements.setUsernameStatusContainer.style.display = "unset";
OptionsElements.setUsernameStatus.innerText = "Loading..."; PageElements.setUsernameStatus.innerText = "Loading...";
//get the userID //get the userID
utils.sendRequestToServer("POST", "/api/setUsername?userID=" + SB.config.userID + "&username=" + OptionsElements.usernameInput.value, function (xmlhttp, error) { utils.sendRequestToServer("POST", "/api/setUsername?userID=" + SB.config.userID + "&username=" + PageElements.usernameInput.value, function (xmlhttp, error) {
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) { if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
//submitted //submitted
OptionsElements.submitUsername.style.display = "none"; PageElements.submitUsername.style.display = "none";
OptionsElements.usernameInput.style.display = "none"; PageElements.usernameInput.style.display = "none";
OptionsElements.setUsernameStatus.innerText = chrome.i18n.getMessage("success"); PageElements.setUsernameStatus.innerText = chrome.i18n.getMessage("success");
} else if (xmlhttp.readyState == 4) { } else if (xmlhttp.readyState == 4) {
OptionsElements.setUsernameStatus.innerText = utils.getErrorMessage(xmlhttp.status); PageElements.setUsernameStatus.innerText = utils.getErrorMessage(xmlhttp.status);
} }
}); });
OptionsElements.setUsernameContainer.style.display = "none"; PageElements.setUsernameContainer.style.display = "none";
OptionsElements.setUsername.style.display = "unset"; PageElements.setUsername.style.display = "unset";
} }
//this is not a YouTube video page //this is not a YouTube video page
@@ -909,7 +909,7 @@ async function runThePopup(messageListener?: MessageListener) {
function reportAnIssue() { function reportAnIssue() {
document.getElementById("issueReporterContainer").style.display = "unset"; document.getElementById("issueReporterContainer").style.display = "unset";
OptionsElements.reportAnIssue.style.display = "none"; PageElements.reportAnIssue.style.display = "none";
} }
function addVoteMessage(message, UUID) { function addVoteMessage(message, UUID) {
@@ -954,7 +954,7 @@ async function runThePopup(messageListener?: MessageListener) {
function hideDiscordButton() { function hideDiscordButton() {
SB.config.hideDiscordLink = true; SB.config.hideDiscordLink = true;
OptionsElements.discordButtonContainer.style.display = "none"; PageElements.discordButtonContainer.style.display = "none";
} }
//converts time in seconds to minutes:seconds //converts time in seconds to minutes:seconds
@@ -992,14 +992,14 @@ async function runThePopup(messageListener?: MessageListener) {
whitelistedChannels.push(response.channelURL); whitelistedChannels.push(response.channelURL);
//change button //change button
OptionsElements.whitelistChannel.style.display = "none"; PageElements.whitelistChannel.style.display = "none";
OptionsElements.unwhitelistChannel.style.display = "unset"; PageElements.unwhitelistChannel.style.display = "unset";
OptionsElements.downloadedSponsorMessageTimes.innerText = chrome.i18n.getMessage("channelWhitelisted"); PageElements.downloadedSponsorMessageTimes.innerText = chrome.i18n.getMessage("channelWhitelisted");
OptionsElements.downloadedSponsorMessageTimes.style.fontWeight = "bold"; PageElements.downloadedSponsorMessageTimes.style.fontWeight = "bold";
//save this //save this
OptionsElements.config.whitelistedChannels = whitelistedChannels; PageElements.config.whitelistedChannels = whitelistedChannels;
//send a message to the client //send a message to the client
messageHandler.query({ messageHandler.query({
@@ -1039,14 +1039,14 @@ async function runThePopup(messageListener?: MessageListener) {
whitelistedChannels.splice(index, 1); whitelistedChannels.splice(index, 1);
//change button //change button
OptionsElements.whitelistChannel.style.display = "unset"; PageElements.whitelistChannel.style.display = "unset";
OptionsElements.unwhitelistChannel.style.display = "none"; PageElements.unwhitelistChannel.style.display = "none";
OptionsElements.downloadedSponsorMessageTimes.innerText = ""; PageElements.downloadedSponsorMessageTimes.innerText = "";
OptionsElements.downloadedSponsorMessageTimes.style.fontWeight = "unset"; PageElements.downloadedSponsorMessageTimes.style.fontWeight = "unset";
//save this //save this
OptionsElements.config.whitelistedChannels = whitelistedChannels; PageElements.config.whitelistedChannels = whitelistedChannels;
//send a message to the client //send a message to the client
messageHandler.query({ messageHandler.query({
@@ -1069,14 +1069,14 @@ async function runThePopup(messageListener?: MessageListener) {
* Should skipping be disabled (visuals stay) * Should skipping be disabled (visuals stay)
*/ */
function toggleSkipping(disabled) { function toggleSkipping(disabled) {
OptionsElements.config.disableSkipping = disabled; PageElements.config.disableSkipping = disabled;
let hiddenButton = OptionsElements.disableSkipping; let hiddenButton = PageElements.disableSkipping;
let shownButton = OptionsElements.enableSkipping; let shownButton = PageElements.enableSkipping;
if (!disabled) { if (!disabled) {
hiddenButton = OptionsElements.enableSkipping; hiddenButton = PageElements.enableSkipping;
shownButton = OptionsElements.disableSkipping; shownButton = PageElements.disableSkipping;
} }
shownButton.style.display = "unset"; shownButton.style.display = "unset";

View File

@@ -66,13 +66,7 @@ class Utils {
*/ */
setupExtraSiteContentScripts() { setupExtraSiteContentScripts() {
let js = [ let js = [
"config.js", "content.js"
"SB.js",
"utils/previewBar.js",
"utils/skipNotice.js",
"utils.js",
"content.js",
"popup.js"
]; ];
let css = [ let css = [
"content.css", "content.css",

View File

@@ -7,7 +7,7 @@ module.exports = {
entry: { entry: {
popup: path.join(__dirname, srcDir + 'popup.ts'), popup: path.join(__dirname, srcDir + 'popup.ts'),
background: path.join(__dirname, srcDir + 'background.ts'), background: path.join(__dirname, srcDir + 'background.ts'),
content_script: path.join(__dirname, srcDir + 'content.ts') content: path.join(__dirname, srcDir + 'content.ts')
}, },
output: { output: {
path: path.join(__dirname, '../dist/js'), path: path.join(__dirname, '../dist/js'),