From e5add6c392bb021c3d27d3b8a938d3b25762fb84 Mon Sep 17 00:00:00 2001 From: Official Noob <31563761+OfficialNoob@users.noreply.github.com> Date: Wed, 7 Aug 2019 16:55:47 +0100 Subject: [PATCH 01/36] Create LANG.js --- LANG.js | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 LANG.js diff --git a/LANG.js b/LANG.js new file mode 100644 index 00000000..0a197278 --- /dev/null +++ b/LANG.js @@ -0,0 +1,9 @@ + // File to store strings for diffrent languages + + var EN_US = new Map(); + + EN_US.set(400, 'Server said this request was invalid"') + .set(429, 'You have submitted too many sponsor times for this one video, are you sure there are this many?') + .set(409, 'This has already been submitted before') + .set(502, 'It seems the server is down. Contact the dev to inform them.') + .set('Unknown', 'There was an error submitting your sponsor times, please try again later.'); From 21b5fc9723aec794ee9ea56b91ec66cc4868aa28 Mon Sep 17 00:00:00 2001 From: Official Noob <31563761+OfficialNoob@users.noreply.github.com> Date: Wed, 7 Aug 2019 16:59:57 +0100 Subject: [PATCH 02/36] Added LANG.js --- manifest.json | 2 ++ 1 file changed, 2 insertions(+) diff --git a/manifest.json b/manifest.json index 1fe36a7c..e2fa65a5 100644 --- a/manifest.json +++ b/manifest.json @@ -10,6 +10,7 @@ ], "all_frames": true, "js": [ + "LANG.js", "config.js", "content.js", "popup.js" @@ -48,6 +49,7 @@ }, "background": { "scripts":[ + "LANG.js", "config.js", "background.js" ] From 86fee63a8b73fc351cdb4079f46b5b442976627c Mon Sep 17 00:00:00 2001 From: Official Noob <31563761+OfficialNoob@users.noreply.github.com> Date: Wed, 7 Aug 2019 17:04:50 +0100 Subject: [PATCH 03/36] Moving into LANG --- popup.js | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-) diff --git a/popup.js b/popup.js index 8368f274..a4ef46f6 100644 --- a/popup.js +++ b/popup.js @@ -81,15 +81,6 @@ function runThePopup() { SB.optionsButton.addEventListener("click", openOptions); SB.reportAnIssue.addEventListener("click", reportAnIssue); SB.hideDiscordButton.addEventListener("click", hideDiscordButton); - - //setup error message languages - var EN_US = new Map(); - - EN_US.set(400, 'Server said this request was invalid"') - .set(429, 'You have submitted too many sponsor times for this one video, are you sure there are this many?') - .set(409, 'This has already been submitted before') - .set(502, 'It seems the server is down. Contact the dev to inform them.') - .set('Unknown', 'There was an error submitting your sponsor times, please try again later.'); //if true, the button now selects the end time let startTimeChosen = false; @@ -698,11 +689,6 @@ function runThePopup() { resetStartTimeChosen(); } - function getErrorMessage(lang, statusCode) { - if(lang.has(statusCode)) return lang.get(statusCode); - return lang.get('Unknown').concat(" Error code: ") + statusCode; - } - function submitTimes() { //make info message say loading SB.submitTimesInfoMessage.innerText = "Loading..."; @@ -1143,4 +1129,4 @@ if (chrome.tabs != undefined) { //this means it is actually opened in the popup runThePopup(); -} \ No newline at end of file +} From 37df697b3d1b0d50f50d562fe1329430d331d180 Mon Sep 17 00:00:00 2001 From: Official Noob <31563761+OfficialNoob@users.noreply.github.com> Date: Wed, 7 Aug 2019 17:08:29 +0100 Subject: [PATCH 04/36] Added Utils for lang --- LANG.js | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/LANG.js b/LANG.js index 0a197278..7dc08c3a 100644 --- a/LANG.js +++ b/LANG.js @@ -1,7 +1,22 @@ // File to store strings for diffrent languages + + + // Utils + function getErrorMessage(lang, statusCode) { + if(lang.has(statusCode)) return lang.get(statusCode); + return lang.get('Unknown').concat(" Error code: ") + statusCode; + } + function MSG(lang, message) { + if(lang.has(message)) return lang.get(message); + console.warn("Could not find key " + message + " for lang "+lang); + return ""; + } + + //Declare Maps var EN_US = new Map(); - + + // Main EN_US.set(400, 'Server said this request was invalid"') .set(429, 'You have submitted too many sponsor times for this one video, are you sure there are this many?') .set(409, 'This has already been submitted before') From 24c61bab71942c1383c9856a845681e008c421e0 Mon Sep 17 00:00:00 2001 From: Official Noob <31563761+OfficialNoob@users.noreply.github.com> Date: Wed, 7 Aug 2019 17:15:57 +0100 Subject: [PATCH 05/36] Auto detect lang --- LANG.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/LANG.js b/LANG.js index 7dc08c3a..58b8fd69 100644 --- a/LANG.js +++ b/LANG.js @@ -1,23 +1,23 @@ // File to store strings for diffrent languages - + lang = navigator.language.replace("-", "_"); // Utils - function getErrorMessage(lang, statusCode) { + function getErrorMessage(statusCode) { if(lang.has(statusCode)) return lang.get(statusCode); return lang.get('Unknown').concat(" Error code: ") + statusCode; } - function MSG(lang, message) { + function MSG(message) { if(lang.has(message)) return lang.get(message); console.warn("Could not find key " + message + " for lang "+lang); return ""; } //Declare Maps - var EN_US = new Map(); + var en_US = new Map(); // Main - EN_US.set(400, 'Server said this request was invalid"') + en_US.set(400, 'Server said this request was invalid"') .set(429, 'You have submitted too many sponsor times for this one video, are you sure there are this many?') .set(409, 'This has already been submitted before') .set(502, 'It seems the server is down. Contact the dev to inform them.') From c09cff86b5303d1b1a474b9fad7fb09a12dfbad9 Mon Sep 17 00:00:00 2001 From: Official Noob <31563761+OfficialNoob@users.noreply.github.com> Date: Wed, 7 Aug 2019 17:33:16 +0100 Subject: [PATCH 06/36] Update popup.js --- popup.js | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/popup.js b/popup.js index a4ef46f6..de370426 100644 --- a/popup.js +++ b/popup.js @@ -127,7 +127,7 @@ function runThePopup() { SB.whitelistChannel.style.display = "none"; SB.unwhitelistChannel.style.display = "unset"; - SB.downloadedSponsorMessageTimes.innerText = "Channel Whitelisted!"; + SB.downloadedSponsorMessageTimes.innerText = MSG("CWL"); SB.downloadedSponsorMessageTimes.style.fontWeight = "bold"; } }); @@ -179,9 +179,9 @@ function runThePopup() { chrome.storage.sync.get(["sponsorTimesContributed"], function(result) { if (result.sponsorTimesContributed != undefined) { if (result.sponsorTimesContributed > 1) { - SB.sponsorTimesContributionsDisplayEndWord.innerText = "sponsors." + SB.sponsorTimesContributionsDisplayEndWord.innerText = MSG("SPs"); } else { - SB.sponsorTimesContributionsDisplayEndWord.innerText = "sponsor." + SB.sponsorTimesContributionsDisplayEndWord.innerText = MSG("SP"); } SB.sponsorTimesContributionsDisplay.innerText = result.sponsorTimesContributed; SB.sponsorTimesContributionsContainer.style.display = "unset"; @@ -197,9 +197,9 @@ function runThePopup() { let viewCount = JSON.parse(xmlhttp.responseText).viewCount; if (viewCount != 0) { if (viewCount > 1) { - SB.sponsorTimesViewsDisplayEndWord.innerText = "sponsor segments." + SB.sponsorTimesViewsDisplayEndWord.innerText = MSG("SPSEGs"); } else { - SB.sponsorTimesViewsDisplayEndWord.innerText = "sponsor segment." + SB.sponsorTimesViewsDisplayEndWord.innerText = MSG("SPSEG"); } SB.sponsorTimesViewsDisplay.innerText = viewCount; @@ -276,11 +276,11 @@ function runThePopup() { SB.loadingIndicator.innerHTML = ""; if (request.found) { - SB.videoFound.innerHTML = "This video's sponsors are in the database!" + SB.videoFound.innerHTML = MSG("SP_FOUND"); displayDownloadedSponsorTimes(request); } else { - SB.videoFound.innerHTML = "No sponsors found" + SB.videoFound.innerHTML = MSG("SP_NONE"); } } } @@ -358,7 +358,7 @@ function runThePopup() { function displayDownloadedSponsorTimes(request) { if (request.sponsorTimes != undefined) { //set it to the message - if (SB.downloadedSponsorMessageTimes.innerText != "Channel Whitelisted!") { + if (SB.downloadedSponsorMessageTimes.innerText != MSG("CWL")) { SB.downloadedSponsorMessageTimes.innerText = getSponsorTimesMessage(request.sponsorTimes); } @@ -706,7 +706,7 @@ function runThePopup() { clearTimes(); } else { - let errorMessage = getErrorMessage(EN_US, response.statusCode); + let errorMessage = getErrorMessage(response.statusCode); document.getElementById("submitTimesInfoMessage").innerText = errorMessage; document.getElementById("submitTimesInfoMessageContainer").style.display = "unset"; @@ -873,7 +873,7 @@ function runThePopup() { //update startTimeChosen letiable if (!startTimeChosen) { startTimeChosen = true; - SB.sponsorStart.innerHTML = "Sponsorship Ends Now"; + SB.sponsorStart.innerHTML = MSG("SP_END"); } else { resetStartTimeChosen(); } @@ -882,7 +882,7 @@ function runThePopup() { //set it to false function resetStartTimeChosen() { startTimeChosen = false; - SB.sponsorStart.innerHTML = "Sponsorship Starts Now"; + SB.sponsorStart.innerHTML = "SP_START"; } //hides and shows the submit times button when needed @@ -905,8 +905,7 @@ function runThePopup() { //this is not a YouTube video page function displayNoVideo() { - document.getElementById("loadingIndicator").innerHTML = "This probably isn't a YouTube tab, or you clicked too early. " + - "If you know this is a YouTube tab, close this popup and open it again."; + document.getElementById("loadingIndicator").innerHTML = MSG("NOTYT"); } function reportAnIssue() { @@ -943,7 +942,7 @@ function runThePopup() { //see if it was a success or failure if (response.successType == 1) { //success - addVoteMessage("Thanks for voting!", UUID) + addVoteMessage(MSG("VOTE"), UUID) } else if (response.successType == 0) { //failure: duplicate vote addVoteMessage("You have already voted this way before.", UUID) From c7f8a392828f311afa7dab68473d9d828bd42c4e Mon Sep 17 00:00:00 2001 From: Official Noob <31563761+OfficialNoob@users.noreply.github.com> Date: Wed, 7 Aug 2019 17:45:10 +0100 Subject: [PATCH 07/36] Update LANG.js --- LANG.js | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/LANG.js b/LANG.js index 58b8fd69..007f72a9 100644 --- a/LANG.js +++ b/LANG.js @@ -17,8 +17,23 @@ var en_US = new Map(); // Main - en_US.set(400, 'Server said this request was invalid"') - .set(429, 'You have submitted too many sponsor times for this one video, are you sure there are this many?') - .set(409, 'This has already been submitted before') - .set(502, 'It seems the server is down. Contact the dev to inform them.') - .set('Unknown', 'There was an error submitting your sponsor times, please try again later.'); +en_US.set(400, 'Server said this request was invalid"') +.set(429, 'You have submitted too many sponsor times for this one video, are you sure there are this many?') +.set(409, 'This has already been submitted before') +.set(502, 'It seems the server is down. Contact the dev to inform them.') +.set('Unknown', 'There was an error submitting your sponsor times, please try again later.') +.set("CWL","Channel Whitelisted!") +.set("SPs","sponsors.") +.set("SP","sponsor.") +.set("SPSEGs","sponsor segments.") +.set("SPSEG","sponsor segment.") +.set("SP_FOUND","This video's sponsors are in the database!") +.set("SP_NONE","No sponsors found) +.set("SP_END","Sponsorship Ends Now") +.set("SP_START","Sponsorship Starts Now") +.set("NOTYTT","his probably isn't a YouTube tab, or you clicked too early. \n If you know this is a YouTube tab,\n close this popup and open it again.") +.set("VOTE","Thanks for voting!") +.set("VOTE_FAIL","You have already voted this way before.") +.set("It seems the sever is down. Contact the dev immediately.","SBDOWN") + + From 8e3a46d3933ef2ec9a35a914e6cada06cbdf882d Mon Sep 17 00:00:00 2001 From: Official Noob <31563761+OfficialNoob@users.noreply.github.com> Date: Wed, 7 Aug 2019 17:45:56 +0100 Subject: [PATCH 08/36] Update LANG.js --- LANG.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/LANG.js b/LANG.js index 007f72a9..8f8c61a9 100644 --- a/LANG.js +++ b/LANG.js @@ -28,7 +28,7 @@ en_US.set(400, 'Server said this request was invalid"') .set("SPSEGs","sponsor segments.") .set("SPSEG","sponsor segment.") .set("SP_FOUND","This video's sponsors are in the database!") -.set("SP_NONE","No sponsors found) +.set("SP_NONE","No sponsors found") .set("SP_END","Sponsorship Ends Now") .set("SP_START","Sponsorship Starts Now") .set("NOTYTT","his probably isn't a YouTube tab, or you clicked too early. \n If you know this is a YouTube tab,\n close this popup and open it again.") From 4c37bd24ac9d178657c5716ebc97bb30b2e77502 Mon Sep 17 00:00:00 2001 From: Official Noob <31563761+OfficialNoob@users.noreply.github.com> Date: Wed, 7 Aug 2019 18:12:04 +0100 Subject: [PATCH 09/36] Update LANG.js --- LANG.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/LANG.js b/LANG.js index 8f8c61a9..09264f21 100644 --- a/LANG.js +++ b/LANG.js @@ -31,7 +31,7 @@ en_US.set(400, 'Server said this request was invalid"') .set("SP_NONE","No sponsors found") .set("SP_END","Sponsorship Ends Now") .set("SP_START","Sponsorship Starts Now") -.set("NOTYTT","his probably isn't a YouTube tab, or you clicked too early. \n If you know this is a YouTube tab,\n close this popup and open it again.") +.set("NOTYT","his probably isn't a YouTube tab, or you clicked too early. \n If you know this is a YouTube tab,\n close this popup and open it again.") .set("VOTE","Thanks for voting!") .set("VOTE_FAIL","You have already voted this way before.") .set("It seems the sever is down. Contact the dev immediately.","SBDOWN") From c8341a448de05deca9972e032f0fca49691892c5 Mon Sep 17 00:00:00 2001 From: Official Noob <31563761+OfficialNoob@users.noreply.github.com> Date: Mon, 12 Aug 2019 18:33:36 +0100 Subject: [PATCH 10/36] Switched to native --- LANG.js | 39 ------------------------ _locales/en/messages.json | 63 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 63 insertions(+), 39 deletions(-) delete mode 100644 LANG.js create mode 100644 _locales/en/messages.json diff --git a/LANG.js b/LANG.js deleted file mode 100644 index 09264f21..00000000 --- a/LANG.js +++ /dev/null @@ -1,39 +0,0 @@ - // File to store strings for diffrent languages - lang = navigator.language.replace("-", "_"); - - // Utils - function getErrorMessage(statusCode) { - if(lang.has(statusCode)) return lang.get(statusCode); - return lang.get('Unknown').concat(" Error code: ") + statusCode; - } - - function MSG(message) { - if(lang.has(message)) return lang.get(message); - console.warn("Could not find key " + message + " for lang "+lang); - return ""; - } - - //Declare Maps - var en_US = new Map(); - - // Main -en_US.set(400, 'Server said this request was invalid"') -.set(429, 'You have submitted too many sponsor times for this one video, are you sure there are this many?') -.set(409, 'This has already been submitted before') -.set(502, 'It seems the server is down. Contact the dev to inform them.') -.set('Unknown', 'There was an error submitting your sponsor times, please try again later.') -.set("CWL","Channel Whitelisted!") -.set("SPs","sponsors.") -.set("SP","sponsor.") -.set("SPSEGs","sponsor segments.") -.set("SPSEG","sponsor segment.") -.set("SP_FOUND","This video's sponsors are in the database!") -.set("SP_NONE","No sponsors found") -.set("SP_END","Sponsorship Ends Now") -.set("SP_START","Sponsorship Starts Now") -.set("NOTYT","his probably isn't a YouTube tab, or you clicked too early. \n If you know this is a YouTube tab,\n close this popup and open it again.") -.set("VOTE","Thanks for voting!") -.set("VOTE_FAIL","You have already voted this way before.") -.set("It seems the sever is down. Contact the dev immediately.","SBDOWN") - - diff --git a/_locales/en/messages.json b/_locales/en/messages.json new file mode 100644 index 00000000..1136bd62 --- /dev/null +++ b/_locales/en/messages.json @@ -0,0 +1,63 @@ +{ + "Name": { + "message": "SponsorBlock", + "description": "Name of the extension." + }, + + "Description": { + "message": "Skip over sponsorship on YouTube videos. Report sponsors on videos you watch to save the time of others.", + "description": "Description of the extension." + }, + + "400": { + "message": "Server said this request was invalid" + }, + "429": { + "message": "You have submitted too many sponsor times for this one video, are you sure there are this many?" + }, + "409": { + "message": "This has already been submitted before" + }, + "502": { + "message": "It seems the server is down. Contact the dev to inform them." + }, + "ChannelWhitelisted": { + "message": "Channel Whitelisted!" + }, + "Sponsor": { + "message": "Sponsor" + }, + "Sponsors": { + "message": "Sponsors" + }, + "Segments": { + "message": "sponsor segments" + }, + "Unknown": { + "message": "There was an error submitting your sponsor times, please try again later." + }, + "SponsorFound": { + "message": "This video's sponsors are in the database!" + }, + "Sponsor404": { + "message": "No sponsors found" + }, + "SponsorStart": { + "message": "Sponsorship Starts Now" + }, + "SponsorEND": { + "message": "Sponsorship Ends Now" + }, + "noVIDEOID": { + "message": "this probably isn't a YouTube tab, or you clicked too early. \n If you know this is a YouTube tab,\n close this popup and open it again." + }, + "VOTED": { + "message": "Thanks for voting!" + }, + "VOTE_FAIL": { + "message": "You have already voted this way before." + }, + "ServerDown": { + "message": "It seems the sever is down. Contact the dev immediately." + }, +} From a2750ad70985e9ba3ec2cbabb679fa95c5bdcee9 Mon Sep 17 00:00:00 2001 From: Official Noob <31563761+OfficialNoob@users.noreply.github.com> Date: Mon, 12 Aug 2019 18:34:17 +0100 Subject: [PATCH 11/36] Fixed JSON --- _locales/en/messages.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/_locales/en/messages.json b/_locales/en/messages.json index 1136bd62..2c9c0e41 100644 --- a/_locales/en/messages.json +++ b/_locales/en/messages.json @@ -59,5 +59,5 @@ }, "ServerDown": { "message": "It seems the sever is down. Contact the dev immediately." - }, + } } From 189a28f027e4e548a0a8e880789dff227b7aeb41 Mon Sep 17 00:00:00 2001 From: Official Noob <31563761+OfficialNoob@users.noreply.github.com> Date: Mon, 12 Aug 2019 18:36:02 +0100 Subject: [PATCH 12/36] added fullName --- _locales/en/messages.json | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/_locales/en/messages.json b/_locales/en/messages.json index 2c9c0e41..82fd5008 100644 --- a/_locales/en/messages.json +++ b/_locales/en/messages.json @@ -3,6 +3,10 @@ "message": "SponsorBlock", "description": "Name of the extension." }, + "fullName": { + "message": "SponsorBlock for YouTube - Skip Sponsorships", + "description": "Name of the extension." + }, "Description": { "message": "Skip over sponsorship on YouTube videos. Report sponsors on videos you watch to save the time of others.", From cc3f970aef85e91693bf9026c7bdb4e44be6c0d4 Mon Sep 17 00:00:00 2001 From: Official Noob <31563761+OfficialNoob@users.noreply.github.com> Date: Mon, 12 Aug 2019 18:40:16 +0100 Subject: [PATCH 13/36] Internationalization --- manifest.json | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/manifest.json b/manifest.json index 5360b2e2..215ea951 100644 --- a/manifest.json +++ b/manifest.json @@ -1,8 +1,9 @@ { - "name": "SponsorBlock for YouTube - Skip Sponsorships", - "short_name": "SponsorBlock", + "name": "__MSG_fullName__", + "short_name": "__MSG_Name__", "version": "1.0.31", - "description": "Skip over sponsorship on YouTube videos. Report sponsors on videos you watch to save the time of others.", + "default_locale": "en", + "description": "__MSG_Description__", "content_scripts": [ { "matches": [ @@ -10,7 +11,6 @@ ], "all_frames": true, "js": [ - "LANG.js", "config.js", "utils.js", "content.js", From 71d2231fb51055ed8df4f58e5981ccac652b0912 Mon Sep 17 00:00:00 2001 From: Official Noob <31563761+OfficialNoob@users.noreply.github.com> Date: Mon, 12 Aug 2019 18:41:45 +0100 Subject: [PATCH 14/36] Update messages.json --- _locales/en/messages.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/_locales/en/messages.json b/_locales/en/messages.json index 82fd5008..ca8a455d 100644 --- a/_locales/en/messages.json +++ b/_locales/en/messages.json @@ -53,7 +53,7 @@ "message": "Sponsorship Ends Now" }, "noVIDEOID": { - "message": "this probably isn't a YouTube tab, or you clicked too early. \n If you know this is a YouTube tab,\n close this popup and open it again." + "message": "This probably isn't a YouTube tab, or you clicked too early. \n If you know this is a YouTube tab,\n close this popup and open it again." }, "VOTED": { "message": "Thanks for voting!" From 9a2bce4ba68f1dd33a84d21147c2114cf67698cf Mon Sep 17 00:00:00 2001 From: Official Noob <31563761+OfficialNoob@users.noreply.github.com> Date: Mon, 12 Aug 2019 19:35:08 +0100 Subject: [PATCH 15/36] Added Segment --- _locales/en/messages.json | 3 +++ 1 file changed, 3 insertions(+) diff --git a/_locales/en/messages.json b/_locales/en/messages.json index ca8a455d..232fd85b 100644 --- a/_locales/en/messages.json +++ b/_locales/en/messages.json @@ -33,6 +33,9 @@ }, "Sponsors": { "message": "Sponsors" + }, + "Segment": { + "message": "sponsor segment" }, "Segments": { "message": "sponsor segments" From 7a362776955dc0d24433418b863196f23df614ab Mon Sep 17 00:00:00 2001 From: Official Noob <31563761+OfficialNoob@users.noreply.github.com> Date: Mon, 12 Aug 2019 19:46:25 +0100 Subject: [PATCH 16/36] added connectionError --- _locales/en/messages.json | 3 +++ 1 file changed, 3 insertions(+) diff --git a/_locales/en/messages.json b/_locales/en/messages.json index 232fd85b..d2ad7169 100644 --- a/_locales/en/messages.json +++ b/_locales/en/messages.json @@ -66,5 +66,8 @@ }, "ServerDown": { "message": "It seems the sever is down. Contact the dev immediately." + }, + "connectionError": { + "message": "A connection error has occured. Error code: " } } From 334e32fb6bdf671b78756eee1a96d962639f54f8 Mon Sep 17 00:00:00 2001 From: Official Noob <31563761+OfficialNoob@users.noreply.github.com> Date: Mon, 12 Aug 2019 19:47:11 +0100 Subject: [PATCH 17/36] i18n --- popup.js | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/popup.js b/popup.js index ec6e1f3c..ded54fef 100644 --- a/popup.js +++ b/popup.js @@ -159,9 +159,9 @@ function runThePopup() { chrome.storage.sync.get(["sponsorTimesContributed"], function(result) { if (result.sponsorTimesContributed != undefined) { if (result.sponsorTimesContributed > 1) { - SB.sponsorTimesContributionsDisplayEndWord.innerText = MSG("SPs"); + SB.sponsorTimesContributionsDisplayEndWord.innerText = browser.i18n.getMessage("Sponsors"); } else { - SB.sponsorTimesContributionsDisplayEndWord.innerText = MSG("SP"); + SB.sponsorTimesContributionsDisplayEndWord.innerText = browser.i18n.getMessage("Sponsor"); } SB.sponsorTimesContributionsDisplay.innerText = result.sponsorTimesContributed; SB.sponsorTimesContributionsContainer.style.display = "unset"; @@ -177,9 +177,9 @@ function runThePopup() { let viewCount = JSON.parse(xmlhttp.responseText).viewCount; if (viewCount != 0) { if (viewCount > 1) { - SB.sponsorTimesViewsDisplayEndWord.innerText = MSG("SPSEGs"); + SB.sponsorTimesViewsDisplayEndWord.innerText = browser.i18n.getMessage("Segments"); } else { - SB.sponsorTimesViewsDisplayEndWord.innerText = MSG("SPSEG"); + SB.sponsorTimesViewsDisplayEndWord.innerText = browser.i18n.getMessage("Segment"); } SB.sponsorTimesViewsDisplay.innerText = viewCount; @@ -256,11 +256,11 @@ function runThePopup() { SB.loadingIndicator.innerHTML = ""; if (request.found) { - SB.videoFound.innerHTML = MSG("SP_FOUND"); + SB.videoFound.innerHTML = browser.i18n.getMessage("SponsorFound"); displayDownloadedSponsorTimes(request); } else { - SB.videoFound.innerHTML = MSG("SP_NONE"); + SB.videoFound.innerHTML = browser.i18n.getMessage("Sponsor404"); } } @@ -358,7 +358,7 @@ function runThePopup() { function displayDownloadedSponsorTimes(request) { if (request.sponsorTimes != undefined) { //set it to the message - if (SB.downloadedSponsorMessageTimes.innerText != MSG("CWL")) { + if (SB.downloadedSponsorMessageTimes.innerText != browser.i18n.getMessage("ChannelWhitelisted")) { SB.downloadedSponsorMessageTimes.innerText = getSponsorTimesMessage(request.sponsorTimes); } @@ -873,7 +873,7 @@ function runThePopup() { //update startTimeChosen letiable if (!startTimeChosen) { startTimeChosen = true; - SB.sponsorStart.innerHTML = MSG("SP_END"); + SB.sponsorStart.innerHTML = browser.i18n.getMessage("SponsorEND"); } else { resetStartTimeChosen(); } @@ -905,7 +905,7 @@ function runThePopup() { //this is not a YouTube video page function displayNoVideo() { - document.getElementById("loadingIndicator").innerHTML = MSG("NOTYT"); + document.getElementById("loadingIndicator").innerHTML = browser.i18n.getMessage("Sponsor404"); } function reportAnIssue() { @@ -942,16 +942,16 @@ function runThePopup() { //see if it was a success or failure if (response.successType == 1) { //success - addVoteMessage(MSG("VOTE"), UUID) + addVoteMessage(browser.i18n.getMessage("VOTED"), UUID) } else if (response.successType == 0) { //failure: duplicate vote - addVoteMessage("You have already voted this way before.", UUID) + addVoteMessage(browser.i18n.getMessage("VOTE_FAIL"), UUID) } else if (response.successType == -1) { if (response.statusCode == 502) { - addVoteMessage("It seems the sever is down. Contact the dev immediately.", UUID) + addVoteMessage(browser.i18n.getMessage("ServerDown"), UUID) } else { //failure: unknown error - addVoteMessage("A connection error has occured. Error code: " + response.statusCode, UUID) + addVoteMessage(browser.i18n.getMessage("connectionError") + response.statusCode, UUID) } } } From a30c7cf383d7688eb3a445476d52a476b1888281 Mon Sep 17 00:00:00 2001 From: Official Noob <31563761+OfficialNoob@users.noreply.github.com> Date: Mon, 12 Aug 2019 20:08:26 +0100 Subject: [PATCH 18/36] Update messages.json --- _locales/en/messages.json | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/_locales/en/messages.json b/_locales/en/messages.json index d2ad7169..1028a7fc 100644 --- a/_locales/en/messages.json +++ b/_locales/en/messages.json @@ -40,9 +40,28 @@ "Segments": { "message": "sponsor segments" }, + "Dismiss": { + "message": "Dismiss" + }, + "Hide": { + "message": "Don't Show This Again" + }, + "HitGoBack": { + "message": "Hit go back to get to where you came from." + }, + "GoBack": { + "message": "Go back" + }, + "ConfirmMSG": { + "message": "\n\nTo edit or delete individual values, click the info button or open the extension popup by clicking the extension icon in the top right corner." + }, + "ClearThis": { + "message": "Are you sure you want to clear this?\n\n" + }, "Unknown": { "message": "There was an error submitting your sponsor times, please try again later." }, + "SponsorFound": { "message": "This video's sponsors are in the database!" }, From 59c2e5cae7a9b0e4d9f0b28acbe2146bc05521a4 Mon Sep 17 00:00:00 2001 From: Official Noob <31563761+OfficialNoob@users.noreply.github.com> Date: Mon, 12 Aug 2019 20:10:13 +0100 Subject: [PATCH 19/36] i18n --- content.js | 38 ++++++++++++++++---------------------- 1 file changed, 16 insertions(+), 22 deletions(-) diff --git a/content.js b/content.js index c1060415..d4269fea 100644 --- a/content.js +++ b/content.js @@ -454,7 +454,7 @@ function addPlayerControlsButton() { let startSponsorButton = document.createElement("button"); startSponsorButton.id = "startSponsorButton"; startSponsorButton.className = "ytp-button playerButton"; - startSponsorButton.setAttribute("title", "Sponsor Starts Now"); + startSponsorButton.setAttribute("title", browser.i18n.getMessage("SponsorStart")); startSponsorButton.addEventListener("click", startSponsorClicked); let startSponsorImage = document.createElement("img"); @@ -546,7 +546,7 @@ function changeStartSponsorButton(showStartSponsor, uploadButtonVisible) { if (showStartSponsor) { showingStartSponsor = true; document.getElementById("startSponsorImage").src = chrome.extension.getURL("icons/PlayerStartIconSponsorBlocker256px.png"); - document.getElementById("startSponsorButton").setAttribute("title", "Sponsor Starts Now"); + document.getElementById("startSponsorButton").setAttribute("title", browser.i18n.getMessage("SponsorStart")); if (document.getElementById("startSponsorImage").style.display != "none" && uploadButtonVisible && !hideInfoButtonPlayerControls) { document.getElementById("submitButton").style.display = "unset"; @@ -557,7 +557,7 @@ function changeStartSponsorButton(showStartSponsor, uploadButtonVisible) { } else { showingStartSponsor = false; document.getElementById("startSponsorImage").src = chrome.extension.getURL("icons/PlayerStopIconSponsorBlocker256px.png"); - document.getElementById("startSponsorButton").setAttribute("title", "Sponsor Ends Now"); + document.getElementById("startSponsorButton").setAttribute("title", browser.i18n.getMessage("SponsorEND")); //disable submit button document.getElementById("submitButton").style.display = "none"; @@ -745,8 +745,8 @@ function clearSponsorTimes() { let sponsorTimes = result[sponsorTimeKey]; if (sponsorTimes != undefined && sponsorTimes.length > 0) { - let confirmMessage = "Are you sure you want to clear this?\n\n" + getSponsorTimesMessage(sponsorTimes); - confirmMessage += "\n\nTo edit or delete individual values, click the info button or open the extension popup by clicking the extension icon in the top right corner." + let confirmMessage = browser.i18n.getMessage("ClearThis") + getSponsorTimesMessage(sponsorTimes); + confirmMessage += browser.i18n.getMessage("ConfirmMSG") if(!confirm(confirmMessage)) return; //clear the sponsor times @@ -827,17 +827,17 @@ function openSkipNotice(UUID){ buttonContainer.setAttribute("align", "center"); let goBackButton = document.createElement("button"); - goBackButton.innerText = "Go back"; + goBackButton.innerText = browser.i18n.getMessage("GoBack"); goBackButton.className = "sponsorSkipButton"; goBackButton.addEventListener("click", () => goBackToPreviousTime(UUID)); let hideButton = document.createElement("button"); - hideButton.innerText = "Dismiss"; + hideButton.innerText = browser.i18n.getMessage("Dismiss"); hideButton.className = "sponsorSkipButton"; hideButton.addEventListener("click", () => closeSkipNotice(UUID)); let dontShowAgainButton = document.createElement("button"); - dontShowAgainButton.innerText = "Don't Show This Again"; + dontShowAgainButton.innerText = browser.i18n.getMessage("Hide"); dontShowAgainButton.className = "sponsorSkipDontShowButton"; dontShowAgainButton.addEventListener("click", dontShowNoticeAgain); @@ -892,12 +892,12 @@ function afterDownvote(UUID) { //add thanks for voting text let thanksForVotingText = document.createElement("p"); thanksForVotingText.id = "sponsorTimesThanksForVotingText"; - thanksForVotingText.innerText = "Thanks for voting!" + thanksForVotingText.innerText = browser.i18n.getMessage("VOTED"); //add extra info for voting let thanksForVotingInfoText = document.createElement("p"); thanksForVotingInfoText.id = "sponsorTimesThanksForVotingInfoText"; - thanksForVotingInfoText.innerText = "Hit go back to get to where you came from." + thanksForVotingInfoText.innerText = browser.i18n.getMessage("HitGoBack"); //add element to div document.getElementById("sponsorTimesVoteButtonsContainer" + UUID).appendChild(thanksForVotingText); @@ -952,13 +952,13 @@ function vote(type, UUID) { } } else if (response.successType == 0) { //failure: duplicate vote - addLoadingInfo("It seems you've already voted before", UUID) + addLoadingInfo(browser.i18n.getMessage("VOTE_FAIL"), UUID) } else if (response.successType == -1) { if (response.statusCode == 502) { - addLoadingInfo("It seems the sever is down. Contact the dev immediately.", UUID) + addLoadingInfo(browser.i18n.getMessage("ServerDown"), UUID) } else { //failure: unknown error - addLoadingInfo("A connection error has occured. Error code: " + response.statusCode, UUID) + addLoadingInfo((browser.i18n.getMessage("connectionError") + response.statusCode, UUID) } } @@ -1070,16 +1070,10 @@ function sendSubmitMessage(){ document.getElementById("submitButton").style.animation = "unset"; document.getElementById("submitButtonImage").src = chrome.extension.getURL("icons/PlayerUploadFailedIconSponsorBlocker256px.png"); - if(response.statusCode == 400) { - alert("Server said this request was invalid"); - } else if(response.statusCode == 429) { - alert("You have submitted too many sponsor times for this one video, are you sure there are this many?"); - } else if(response.statusCode == 409) { - alert("This has already been submitted before"); - } else if(response.statusCode == 502) { - alert("It seems the server is down. Contact the dev to inform them. Error code " + response.statusCode); + if([400,429,409,502].includes(response.statusCode)) { + alert(browser.i18n.getMessage(response.statusCode)); } else { - alert("There was an error submitting your sponsor times, please try again later. Error code " + response.statusCode); + alert(browser.i18n.getMessage("connectionError") + response.statusCode); } } } From 0b801ae986f915155f9412e736fb137ac3a08ed0 Mon Sep 17 00:00:00 2001 From: Official Noob <31563761+OfficialNoob@users.noreply.github.com> Date: Mon, 12 Aug 2019 21:23:11 +0100 Subject: [PATCH 20/36] browser.i18n -> chrome.i18n --- content.js | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/content.js b/content.js index 6c5227d2..efd64a04 100644 --- a/content.js +++ b/content.js @@ -486,7 +486,7 @@ function addPlayerControlsButton() { let startSponsorButton = document.createElement("button"); startSponsorButton.id = "startSponsorButton"; startSponsorButton.className = "ytp-button playerButton"; - startSponsorButton.setAttribute("title", browser.i18n.getMessage("SponsorStart")); + startSponsorButton.setAttribute("title", chrome.i18n.getMessage("SponsorStart")); startSponsorButton.addEventListener("click", startSponsorClicked); let startSponsorImage = document.createElement("img"); @@ -578,7 +578,7 @@ function changeStartSponsorButton(showStartSponsor, uploadButtonVisible) { if (showStartSponsor) { showingStartSponsor = true; document.getElementById("startSponsorImage").src = chrome.extension.getURL("icons/PlayerStartIconSponsorBlocker256px.png"); - document.getElementById("startSponsorButton").setAttribute("title", browser.i18n.getMessage("SponsorStart")); + document.getElementById("startSponsorButton").setAttribute("title", chrome.i18n.getMessage("SponsorStart")); if (document.getElementById("startSponsorImage").style.display != "none" && uploadButtonVisible && !hideInfoButtonPlayerControls) { document.getElementById("submitButton").style.display = "unset"; @@ -589,7 +589,7 @@ function changeStartSponsorButton(showStartSponsor, uploadButtonVisible) { } else { showingStartSponsor = false; document.getElementById("startSponsorImage").src = chrome.extension.getURL("icons/PlayerStopIconSponsorBlocker256px.png"); - document.getElementById("startSponsorButton").setAttribute("title", browser.i18n.getMessage("SponsorEND")); + document.getElementById("startSponsorButton").setAttribute("title", chrome.i18n.getMessage("SponsorEND")); //disable submit button document.getElementById("submitButton").style.display = "none"; @@ -777,8 +777,8 @@ function clearSponsorTimes() { let sponsorTimes = result[sponsorTimeKey]; if (sponsorTimes != undefined && sponsorTimes.length > 0) { - let confirmMessage = browser.i18n.getMessage("ClearThis") + getSponsorTimesMessage(sponsorTimes); - confirmMessage += browser.i18n.getMessage("ConfirmMSG") + let confirmMessage = chrome.i18n.getMessage("ClearThis") + getSponsorTimesMessage(sponsorTimes); + confirmMessage += chrome.i18n.getMessage("ConfirmMSG") if(!confirm(confirmMessage)) return; //clear the sponsor times @@ -859,17 +859,17 @@ function openSkipNotice(UUID){ buttonContainer.setAttribute("align", "center"); let goBackButton = document.createElement("button"); - goBackButton.innerText = browser.i18n.getMessage("GoBack"); + goBackButton.innerText = chrome.i18n.getMessage("GoBack"); goBackButton.className = "sponsorSkipButton"; goBackButton.addEventListener("click", () => goBackToPreviousTime(UUID)); let hideButton = document.createElement("button"); - hideButton.innerText = browser.i18n.getMessage("Dismiss"); + hideButton.innerText = chrome.i18n.getMessage("Dismiss"); hideButton.className = "sponsorSkipButton"; hideButton.addEventListener("click", () => closeSkipNotice(UUID)); let dontShowAgainButton = document.createElement("button"); - dontShowAgainButton.innerText = browser.i18n.getMessage("Hide"); + dontShowAgainButton.innerText = chrome.i18n.getMessage("Hide"); dontShowAgainButton.className = "sponsorSkipDontShowButton"; dontShowAgainButton.addEventListener("click", dontShowNoticeAgain); @@ -924,12 +924,12 @@ function afterDownvote(UUID) { //add thanks for voting text let thanksForVotingText = document.createElement("p"); thanksForVotingText.id = "sponsorTimesThanksForVotingText"; - thanksForVotingText.innerText = browser.i18n.getMessage("VOTED"); + thanksForVotingText.innerText = chrome.i18n.getMessage("VOTED"); //add extra info for voting let thanksForVotingInfoText = document.createElement("p"); thanksForVotingInfoText.id = "sponsorTimesThanksForVotingInfoText"; - thanksForVotingInfoText.innerText = browser.i18n.getMessage("HitGoBack"); + thanksForVotingInfoText.innerText = chrome.i18n.getMessage("HitGoBack"); //add element to div document.getElementById("sponsorTimesVoteButtonsContainer" + UUID).appendChild(thanksForVotingText); @@ -984,13 +984,13 @@ function vote(type, UUID) { } } else if (response.successType == 0) { //failure: duplicate vote - addLoadingInfo(browser.i18n.getMessage("VOTE_FAIL"), UUID) + addLoadingInfo(chrome.i18n.getMessage("VOTE_FAIL"), UUID) } else if (response.successType == -1) { if (response.statusCode == 502) { - addLoadingInfo(browser.i18n.getMessage("ServerDown"), UUID) + addLoadingInfo(chrome.i18n.getMessage("ServerDown"), UUID) } else { //failure: unknown error - addLoadingInfo((browser.i18n.getMessage("connectionError") + response.statusCode, UUID) + addLoadingInfo((chrome.i18n.getMessage("connectionError") + response.statusCode, UUID) } } @@ -1103,9 +1103,9 @@ function sendSubmitMessage(){ document.getElementById("submitButtonImage").src = chrome.extension.getURL("icons/PlayerUploadFailedIconSponsorBlocker256px.png"); if([400,429,409,502].includes(response.statusCode)) { - alert(browser.i18n.getMessage(response.statusCode)); + alert(chrome.i18n.getMessage(response.statusCode)); } else { - alert(browser.i18n.getMessage("connectionError") + response.statusCode); + alert(chrome.i18n.getMessage("connectionError") + response.statusCode); } } } From ed9a445b4cb6a0bca26a6355bc7aa87e8974a62d Mon Sep 17 00:00:00 2001 From: Official Noob <31563761+OfficialNoob@users.noreply.github.com> Date: Mon, 12 Aug 2019 21:25:03 +0100 Subject: [PATCH 21/36] browser.i18n -> chrome.i18n --- popup.js | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/popup.js b/popup.js index 149c546b..0265d2a6 100644 --- a/popup.js +++ b/popup.js @@ -159,9 +159,9 @@ function runThePopup() { chrome.storage.sync.get(["sponsorTimesContributed"], function(result) { if (result.sponsorTimesContributed != undefined) { if (result.sponsorTimesContributed > 1) { - SB.sponsorTimesContributionsDisplayEndWord.innerText = browser.i18n.getMessage("Sponsors"); + SB.sponsorTimesContributionsDisplayEndWord.innerText = chrome.i18n.getMessage("Sponsors"); } else { - SB.sponsorTimesContributionsDisplayEndWord.innerText = browser.i18n.getMessage("Sponsor"); + SB.sponsorTimesContributionsDisplayEndWord.innerText = chrome.i18n.getMessage("Sponsor"); } SB.sponsorTimesContributionsDisplay.innerText = result.sponsorTimesContributed; SB.sponsorTimesContributionsContainer.style.display = "unset"; @@ -177,9 +177,9 @@ function runThePopup() { let viewCount = JSON.parse(xmlhttp.responseText).viewCount; if (viewCount != 0) { if (viewCount > 1) { - SB.sponsorTimesViewsDisplayEndWord.innerText = browser.i18n.getMessage("Segments"); + SB.sponsorTimesViewsDisplayEndWord.innerText = chrome.i18n.getMessage("Segments"); } else { - SB.sponsorTimesViewsDisplayEndWord.innerText = browser.i18n.getMessage("Segment"); + SB.sponsorTimesViewsDisplayEndWord.innerText = chrome.i18n.getMessage("Segment"); } SB.sponsorTimesViewsDisplay.innerText = viewCount; @@ -264,11 +264,11 @@ function runThePopup() { SB.loadingIndicator.innerHTML = ""; if (request.found) { - SB.videoFound.innerHTML = browser.i18n.getMessage("SponsorFound"); + SB.videoFound.innerHTML = chrome.i18n.getMessage("SponsorFound"); displayDownloadedSponsorTimes(request); } else { - SB.videoFound.innerHTML = browser.i18n.getMessage("Sponsor404"); + SB.videoFound.innerHTML = chrome.i18n.getMessage("Sponsor404"); } } @@ -366,7 +366,7 @@ function runThePopup() { function displayDownloadedSponsorTimes(request) { if (request.sponsorTimes != undefined) { //set it to the message - if (SB.downloadedSponsorMessageTimes.innerText != browser.i18n.getMessage("ChannelWhitelisted")) { + if (SB.downloadedSponsorMessageTimes.innerText != chrome.i18n.getMessage("ChannelWhitelisted")) { SB.downloadedSponsorMessageTimes.innerText = getSponsorTimesMessage(request.sponsorTimes); } @@ -950,7 +950,7 @@ function runThePopup() { //update startTimeChosen letiable if (!startTimeChosen) { startTimeChosen = true; - SB.sponsorStart.innerHTML = browser.i18n.getMessage("SponsorEND"); + SB.sponsorStart.innerHTML = chrome.i18n.getMessage("SponsorEND"); } else { resetStartTimeChosen(); } @@ -982,7 +982,7 @@ function runThePopup() { //this is not a YouTube video page function displayNoVideo() { - document.getElementById("loadingIndicator").innerHTML = browser.i18n.getMessage("Sponsor404"); + document.getElementById("loadingIndicator").innerHTML = chrome.i18n.getMessage("Sponsor404"); } function reportAnIssue() { @@ -1019,16 +1019,16 @@ function runThePopup() { //see if it was a success or failure if (response.successType == 1) { //success - addVoteMessage(browser.i18n.getMessage("VOTED"), UUID) + addVoteMessage(chrome.i18n.getMessage("VOTED"), UUID) } else if (response.successType == 0) { //failure: duplicate vote - addVoteMessage(browser.i18n.getMessage("VOTE_FAIL"), UUID) + addVoteMessage(chrome.i18n.getMessage("VOTE_FAIL"), UUID) } else if (response.successType == -1) { if (response.statusCode == 502) { - addVoteMessage(browser.i18n.getMessage("ServerDown"), UUID) + addVoteMessage(chrome.i18n.getMessage("ServerDown"), UUID) } else { //failure: unknown error - addVoteMessage(browser.i18n.getMessage("connectionError") + response.statusCode, UUID) + addVoteMessage(chrome.i18n.getMessage("connectionError") + response.statusCode, UUID) } } } From 37816ba7625830f44e65e98d501f093f966872a5 Mon Sep 17 00:00:00 2001 From: Official Noob <31563761+OfficialNoob@users.noreply.github.com> Date: Mon, 12 Aug 2019 21:30:02 +0100 Subject: [PATCH 22/36] Rename index.html to index_en.html --- help/{index.html => index_en.html} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename help/{index.html => index_en.html} (99%) diff --git a/help/index.html b/help/index_en.html similarity index 99% rename from help/index.html rename to help/index_en.html index 61e4e6ad..52f24c27 100644 --- a/help/index.html +++ b/help/index_en.html @@ -119,4 +119,4 @@ - \ No newline at end of file + From a5e3dcaf4d9b2eb878a57154ace9bbd1d8fe5242 Mon Sep 17 00:00:00 2001 From: Official Noob <31563761+OfficialNoob@users.noreply.github.com> Date: Mon, 12 Aug 2019 21:34:03 +0100 Subject: [PATCH 23/36] Update background.js --- background.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/background.js b/background.js index c8d7d593..5f8573e9 100644 --- a/background.js +++ b/background.js @@ -55,7 +55,8 @@ chrome.runtime.onInstalled.addListener(function (object) { // TODO (shownInstallPage): remove this if statement, but leave contents if (!shownInstallPage){ //open up the install page - chrome.tabs.create({url: chrome.extension.getURL("/help/index.html")}); + + chrome.tabs.create({url: chrome.extension.getURL("/help/"+navigator.language.split("-")[0]"-index.html")}); } // TODO (shownInstallPage): delete if statement and contents From 5031a85a5c76e76b3224cc7871f17156ed3226dd Mon Sep 17 00:00:00 2001 From: Official Noob <31563761+OfficialNoob@users.noreply.github.com> Date: Mon, 12 Aug 2019 21:38:44 +0100 Subject: [PATCH 24/36] Update background.js --- background.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/background.js b/background.js index 5f8573e9..55826752 100644 --- a/background.js +++ b/background.js @@ -32,8 +32,8 @@ chrome.runtime.onMessage.addListener(function (request, sender, callback) { } else if (request.message == "alertPrevious") { chrome.notifications.create("stillThere" + Math.random(), { type: "basic", - title: "Do you want to submit the sponsor times for video id " + request.previousVideoID + "?", - message: "You seem to have left some sponsor times unsubmitted. Go back to that page to submit them (they are not deleted).", + title: chrome.i18n.getMessage("Wanttosubmit") + request.previousVideoID + "?", + message: chrome.i18n.getMessage("leftTimes"), iconUrl: "./icons/LogoSponsorBlocker256px.png" }); } From 948293db049b692ccffd8e655374992ab56ab322 Mon Sep 17 00:00:00 2001 From: Official Noob <31563761+OfficialNoob@users.noreply.github.com> Date: Mon, 12 Aug 2019 21:40:23 +0100 Subject: [PATCH 25/36] added popup --- _locales/en/messages.json | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/_locales/en/messages.json b/_locales/en/messages.json index 1028a7fc..d9726162 100644 --- a/_locales/en/messages.json +++ b/_locales/en/messages.json @@ -88,5 +88,14 @@ }, "connectionError": { "message": "A connection error has occured. Error code: " + }, + "Wanttosubmit": { + "message": "Do you want to submit the sponsor times for video id" + }, + "leftTimes": { + "message": "You seem to have left some sponsor times unsubmitted. Go back to that page to submit them (they are not deleted)." + }, + "popup": { + "message": "popup_en.html" } } From f2036885aad4e9632d392b6c164ff10e7bd53d9c Mon Sep 17 00:00:00 2001 From: Official Noob <31563761+OfficialNoob@users.noreply.github.com> Date: Mon, 12 Aug 2019 21:41:16 +0100 Subject: [PATCH 26/36] Update manifest.json --- manifest.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/manifest.json b/manifest.json index a7450545..21c293ec 100644 --- a/manifest.json +++ b/manifest.json @@ -42,8 +42,8 @@ "https://sponsor.ajay.app/*" ], "browser_action": { - "default_title": "SponsorBlock", - "default_popup": "popup.html" + "default_title": "__MSG_Name__", + "default_popup": "__MSG_popup__" }, "background": { "scripts":[ From fb1836cd0789dc5596d9f4d330fd8686d50bf2f9 Mon Sep 17 00:00:00 2001 From: Official Noob <31563761+OfficialNoob@users.noreply.github.com> Date: Mon, 12 Aug 2019 21:41:40 +0100 Subject: [PATCH 27/36] Rename popup.html to popup_en.html --- popup.html => popup_en.html | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename popup.html => popup_en.html (100%) diff --git a/popup.html b/popup_en.html similarity index 100% rename from popup.html rename to popup_en.html From 2deb2ff4b5cdf3b59115672ced08f517123e6cd0 Mon Sep 17 00:00:00 2001 From: Official Noob <31563761+OfficialNoob@users.noreply.github.com> Date: Mon, 12 Aug 2019 21:43:34 +0100 Subject: [PATCH 28/36] added helpPage --- background.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/background.js b/background.js index 55826752..ac3630ee 100644 --- a/background.js +++ b/background.js @@ -56,7 +56,7 @@ chrome.runtime.onInstalled.addListener(function (object) { if (!shownInstallPage){ //open up the install page - chrome.tabs.create({url: chrome.extension.getURL("/help/"+navigator.language.split("-")[0]"-index.html")}); + chrome.tabs.create({url: chrome.extension.getURL("/help/"+chrome.i18n.getMessage("helpPage")}); } // TODO (shownInstallPage): delete if statement and contents From 806456d287b8ac2bff698173f872ba196d825841 Mon Sep 17 00:00:00 2001 From: Official Noob <31563761+OfficialNoob@users.noreply.github.com> Date: Mon, 12 Aug 2019 21:45:14 +0100 Subject: [PATCH 29/36] added helpPage --- _locales/en/messages.json | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/_locales/en/messages.json b/_locales/en/messages.json index d9726162..36f3ef0d 100644 --- a/_locales/en/messages.json +++ b/_locales/en/messages.json @@ -12,7 +12,9 @@ "message": "Skip over sponsorship on YouTube videos. Report sponsors on videos you watch to save the time of others.", "description": "Description of the extension." }, - + "helpPage": { + "message": "index_en.html" + }, "400": { "message": "Server said this request was invalid" }, From b13837ce4479348e1409ca153750bb0f084b14f8 Mon Sep 17 00:00:00 2001 From: Official Noob <31563761+OfficialNoob@users.noreply.github.com> Date: Mon, 12 Aug 2019 22:07:24 +0100 Subject: [PATCH 30/36] CC --- _locales/en/messages.json | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/_locales/en/messages.json b/_locales/en/messages.json index 36f3ef0d..be5d528e 100644 --- a/_locales/en/messages.json +++ b/_locales/en/messages.json @@ -27,7 +27,7 @@ "502": { "message": "It seems the server is down. Contact the dev to inform them." }, - "ChannelWhitelisted": { + "channelWhitelisted": { "message": "Channel Whitelisted!" }, "Sponsor": { @@ -48,56 +48,56 @@ "Hide": { "message": "Don't Show This Again" }, - "HitGoBack": { + "hitGoBack": { "message": "Hit go back to get to where you came from." }, - "GoBack": { + "goBack": { "message": "Go back" }, - "ConfirmMSG": { + "confirmMSG": { "message": "\n\nTo edit or delete individual values, click the info button or open the extension popup by clicking the extension icon in the top right corner." }, - "ClearThis": { + "clearThis": { "message": "Are you sure you want to clear this?\n\n" }, "Unknown": { "message": "There was an error submitting your sponsor times, please try again later." }, - "SponsorFound": { + "sponsorFound": { "message": "This video's sponsors are in the database!" }, - "Sponsor404": { + "sponsor404": { "message": "No sponsors found" }, - "SponsorStart": { + "sponsorStart": { "message": "Sponsorship Starts Now" }, - "SponsorEND": { + "sponsorEND": { "message": "Sponsorship Ends Now" }, "noVIDEOID": { "message": "This probably isn't a YouTube tab, or you clicked too early. \n If you know this is a YouTube tab,\n close this popup and open it again." }, - "VOTED": { + "Voted": { "message": "Thanks for voting!" }, - "VOTE_FAIL": { + "voteFAIL": { "message": "You have already voted this way before." }, - "ServerDown": { + "serverDown": { "message": "It seems the sever is down. Contact the dev immediately." }, "connectionError": { "message": "A connection error has occured. Error code: " }, - "Wanttosubmit": { + "wantToSubmit": { "message": "Do you want to submit the sponsor times for video id" }, "leftTimes": { "message": "You seem to have left some sponsor times unsubmitted. Go back to that page to submit them (they are not deleted)." }, - "popup": { + "Popup": { "message": "popup_en.html" } } From bcc927f21a921b1076ea6a73396ee3becbb48693 Mon Sep 17 00:00:00 2001 From: Official Noob <31563761+OfficialNoob@users.noreply.github.com> Date: Mon, 12 Aug 2019 22:10:33 +0100 Subject: [PATCH 31/36] CC --- background.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/background.js b/background.js index ac3630ee..2f6e304d 100644 --- a/background.js +++ b/background.js @@ -32,7 +32,7 @@ chrome.runtime.onMessage.addListener(function (request, sender, callback) { } else if (request.message == "alertPrevious") { chrome.notifications.create("stillThere" + Math.random(), { type: "basic", - title: chrome.i18n.getMessage("Wanttosubmit") + request.previousVideoID + "?", + title: chrome.i18n.getMessage("wantToSubmit") + request.previousVideoID + "?", message: chrome.i18n.getMessage("leftTimes"), iconUrl: "./icons/LogoSponsorBlocker256px.png" }); From 8c7d749f1179ea7c047686224c01cbf9b976c220 Mon Sep 17 00:00:00 2001 From: Official Noob <31563761+OfficialNoob@users.noreply.github.com> Date: Mon, 12 Aug 2019 22:15:25 +0100 Subject: [PATCH 32/36] CC --- content.js | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/content.js b/content.js index efd64a04..265e1a41 100644 --- a/content.js +++ b/content.js @@ -486,7 +486,7 @@ function addPlayerControlsButton() { let startSponsorButton = document.createElement("button"); startSponsorButton.id = "startSponsorButton"; startSponsorButton.className = "ytp-button playerButton"; - startSponsorButton.setAttribute("title", chrome.i18n.getMessage("SponsorStart")); + startSponsorButton.setAttribute("title", chrome.i18n.getMessage("sponsorStart")); startSponsorButton.addEventListener("click", startSponsorClicked); let startSponsorImage = document.createElement("img"); @@ -578,7 +578,7 @@ function changeStartSponsorButton(showStartSponsor, uploadButtonVisible) { if (showStartSponsor) { showingStartSponsor = true; document.getElementById("startSponsorImage").src = chrome.extension.getURL("icons/PlayerStartIconSponsorBlocker256px.png"); - document.getElementById("startSponsorButton").setAttribute("title", chrome.i18n.getMessage("SponsorStart")); + document.getElementById("startSponsorButton").setAttribute("title", chrome.i18n.getMessage("sponsorStart")); if (document.getElementById("startSponsorImage").style.display != "none" && uploadButtonVisible && !hideInfoButtonPlayerControls) { document.getElementById("submitButton").style.display = "unset"; @@ -589,7 +589,7 @@ function changeStartSponsorButton(showStartSponsor, uploadButtonVisible) { } else { showingStartSponsor = false; document.getElementById("startSponsorImage").src = chrome.extension.getURL("icons/PlayerStopIconSponsorBlocker256px.png"); - document.getElementById("startSponsorButton").setAttribute("title", chrome.i18n.getMessage("SponsorEND")); + document.getElementById("startSponsorButton").setAttribute("title", chrome.i18n.getMessage("sponsorEND")); //disable submit button document.getElementById("submitButton").style.display = "none"; @@ -777,8 +777,8 @@ function clearSponsorTimes() { let sponsorTimes = result[sponsorTimeKey]; if (sponsorTimes != undefined && sponsorTimes.length > 0) { - let confirmMessage = chrome.i18n.getMessage("ClearThis") + getSponsorTimesMessage(sponsorTimes); - confirmMessage += chrome.i18n.getMessage("ConfirmMSG") + let confirmMessage = chrome.i18n.getMessage("clearThis") + getSponsorTimesMessage(sponsorTimes); + confirmMessage += chrome.i18n.getMessage("confirmMSG") if(!confirm(confirmMessage)) return; //clear the sponsor times @@ -859,7 +859,7 @@ function openSkipNotice(UUID){ buttonContainer.setAttribute("align", "center"); let goBackButton = document.createElement("button"); - goBackButton.innerText = chrome.i18n.getMessage("GoBack"); + goBackButton.innerText = chrome.i18n.getMessage("goBack"); goBackButton.className = "sponsorSkipButton"; goBackButton.addEventListener("click", () => goBackToPreviousTime(UUID)); @@ -924,12 +924,12 @@ function afterDownvote(UUID) { //add thanks for voting text let thanksForVotingText = document.createElement("p"); thanksForVotingText.id = "sponsorTimesThanksForVotingText"; - thanksForVotingText.innerText = chrome.i18n.getMessage("VOTED"); + thanksForVotingText.innerText = chrome.i18n.getMessage("Voted"); //add extra info for voting let thanksForVotingInfoText = document.createElement("p"); thanksForVotingInfoText.id = "sponsorTimesThanksForVotingInfoText"; - thanksForVotingInfoText.innerText = chrome.i18n.getMessage("HitGoBack"); + thanksForVotingInfoText.innerText = chrome.i18n.getMessage("hitGoBack"); //add element to div document.getElementById("sponsorTimesVoteButtonsContainer" + UUID).appendChild(thanksForVotingText); @@ -984,10 +984,10 @@ function vote(type, UUID) { } } else if (response.successType == 0) { //failure: duplicate vote - addLoadingInfo(chrome.i18n.getMessage("VOTE_FAIL"), UUID) + addLoadingInfo(chrome.i18n.getMessage("voteFAIL"), UUID) } else if (response.successType == -1) { if (response.statusCode == 502) { - addLoadingInfo(chrome.i18n.getMessage("ServerDown"), UUID) + addLoadingInfo(chrome.i18n.getMessage("serverDown"), UUID) } else { //failure: unknown error addLoadingInfo((chrome.i18n.getMessage("connectionError") + response.statusCode, UUID) From f9fcd8055262d95d16a7e69dfd1440980b306934 Mon Sep 17 00:00:00 2001 From: Official Noob <31563761+OfficialNoob@users.noreply.github.com> Date: Mon, 12 Aug 2019 22:28:07 +0100 Subject: [PATCH 33/36] CC --- popup.js | 39 +++++++++++++++++++-------------------- 1 file changed, 19 insertions(+), 20 deletions(-) diff --git a/popup.js b/popup.js index 0265d2a6..209763e1 100644 --- a/popup.js +++ b/popup.js @@ -200,13 +200,12 @@ function runThePopup() { function onTabs(tabs) { chrome.tabs.sendMessage(tabs[0].id, {message: 'getVideoID'}, function(result) { if (result != undefined && result.videoID) { - currentVideoID = result.videoID; - - loadTabData(tabs); + currentVideoID = result.videoID; + loadTabData(tabs); } else if (result == undefined && chrome.runtime.lastError) { - //this isn't a YouTube video then, or at least the content script is not loaded - displayNoVideo(); - } + //this isn't a YouTube video then, or at least the content script is not loaded + displayNoVideo(); + } }); } @@ -224,7 +223,7 @@ function runThePopup() { if (sponsorTimesStorage != undefined && sponsorTimesStorage.length > 0) { if (sponsorTimesStorage[sponsorTimesStorage.length - 1] != undefined && sponsorTimesStorage[sponsorTimesStorage.length - 1].length < 2) { startTimeChosen = true; - SB.sponsorStart.innerHTML = "Sponsorship Ends Now"; + SB.sponsorStart.innerHTML = chrome.i18n.getMessage("sponsorEND"); } sponsorTimes = sponsorTimesStorage; @@ -264,11 +263,11 @@ function runThePopup() { SB.loadingIndicator.innerHTML = ""; if (request.found) { - SB.videoFound.innerHTML = chrome.i18n.getMessage("SponsorFound"); + SB.videoFound.innerHTML = chrome.i18n.getMessage("sponsorFound"); displayDownloadedSponsorTimes(request); } else { - SB.videoFound.innerHTML = chrome.i18n.getMessage("Sponsor404"); + SB.videoFound.innerHTML = chrome.i18n.getMessage("sponsor404"); } } @@ -366,7 +365,7 @@ function runThePopup() { function displayDownloadedSponsorTimes(request) { if (request.sponsorTimes != undefined) { //set it to the message - if (SB.downloadedSponsorMessageTimes.innerText != chrome.i18n.getMessage("ChannelWhitelisted")) { + if (SB.downloadedSponsorMessageTimes.innerText != chrome.i18n.getMessage("channelWhitelisted")) { SB.downloadedSponsorMessageTimes.innerText = getSponsorTimesMessage(request.sponsorTimes); } @@ -628,8 +627,8 @@ function runThePopup() { tabs[0].id, {message: "getCurrentTime"}, function (response) { - let minutes = document.getElementById(idStartName + "Minutes" + index); - let seconds = document.getElementById(idStartName + "Seconds" + index); + let minutes = document.getElementById(idStartName + chrome.i18n.getMessage("Mins") + index); + let seconds = document.getElementById(idStartName + chrome.i18n.getMessage("Secs") + index); minutes.value = getTimeInMinutes(response.currentTime); seconds.value = getTimeInFormattedSeconds(response.currentTime); @@ -640,8 +639,8 @@ function runThePopup() { //id start name is whether it is the startTime or endTime //gives back the time in seconds function getSponsorTimeEditTimes(idStartName, index) { - let minutes = document.getElementById(idStartName + "Minutes" + index); - let seconds = document.getElementById(idStartName + "Seconds" + index); + let minutes = document.getElementById(idStartName + chrome.i18n.getMessage("Mins") + index); + let seconds = document.getElementById(idStartName + chrome.i18n.getMessage("Secs") + index); return parseInt(minutes.value) * 60 + parseFloat(seconds.value); } @@ -768,7 +767,7 @@ function runThePopup() { function submitTimes() { //make info message say loading - SB.submitTimesInfoMessage.innerText = "Loading..."; + SB.submitTimesInfoMessage.innerText = chrome.i18n.getMessage("Loading"); SB.submitTimesInfoMessageContainer.style.display = "unset"; if (sponsorTimes.length > 0) { @@ -950,7 +949,7 @@ function runThePopup() { //update startTimeChosen letiable if (!startTimeChosen) { startTimeChosen = true; - SB.sponsorStart.innerHTML = chrome.i18n.getMessage("SponsorEND"); + SB.sponsorStart.innerHTML = chrome.i18n.getMessage("sponsorEND"); } else { resetStartTimeChosen(); } @@ -982,7 +981,7 @@ function runThePopup() { //this is not a YouTube video page function displayNoVideo() { - document.getElementById("loadingIndicator").innerHTML = chrome.i18n.getMessage("Sponsor404"); + document.getElementById("loadingIndicator").innerHTML = chrome.i18n.getMessage("sponsor404"); } function reportAnIssue() { @@ -1019,13 +1018,13 @@ function runThePopup() { //see if it was a success or failure if (response.successType == 1) { //success - addVoteMessage(chrome.i18n.getMessage("VOTED"), UUID) + addVoteMessage(chrome.i18n.getMessage("Voted"), UUID) } else if (response.successType == 0) { //failure: duplicate vote - addVoteMessage(chrome.i18n.getMessage("VOTE_FAIL"), UUID) + addVoteMessage(chrome.i18n.getMessage("voteFAIL"), UUID) } else if (response.successType == -1) { if (response.statusCode == 502) { - addVoteMessage(chrome.i18n.getMessage("ServerDown"), UUID) + addVoteMessage(chrome.i18n.getMessage("serverDown"), UUID) } else { //failure: unknown error addVoteMessage(chrome.i18n.getMessage("connectionError") + response.statusCode, UUID) From e141b1f4e8458fe0fd64930f593e4747e793c0a9 Mon Sep 17 00:00:00 2001 From: Official Noob <31563761+OfficialNoob@users.noreply.github.com> Date: Mon, 12 Aug 2019 22:28:41 +0100 Subject: [PATCH 34/36] Update manifest.json --- manifest.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifest.json b/manifest.json index 21c293ec..c121f6ef 100644 --- a/manifest.json +++ b/manifest.json @@ -43,7 +43,7 @@ ], "browser_action": { "default_title": "__MSG_Name__", - "default_popup": "__MSG_popup__" + "default_popup": "__MSG_Popup__" }, "background": { "scripts":[ From e8246a9a8aa561fc525a68a328a72e06cc279aa2 Mon Sep 17 00:00:00 2001 From: Official Noob <31563761+OfficialNoob@users.noreply.github.com> Date: Mon, 12 Aug 2019 22:29:15 +0100 Subject: [PATCH 35/36] Added new stuff --- _locales/en/messages.json | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/_locales/en/messages.json b/_locales/en/messages.json index be5d528e..78b12c19 100644 --- a/_locales/en/messages.json +++ b/_locales/en/messages.json @@ -45,6 +45,15 @@ "Dismiss": { "message": "Dismiss" }, + "Loading": { + "message": "Loading..." + }, + "Mins": { + "message": "Minutes" + }, + "Secs": { + "message": "Seconds" + }, "Hide": { "message": "Don't Show This Again" }, From f350f181909f00255c147b192421284bfb0c56a7 Mon Sep 17 00:00:00 2001 From: OfficialNoob Date: Tue, 13 Aug 2019 22:05:39 +0100 Subject: [PATCH 36/36] Fixed code problems --- background.js | 2 +- content.js | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/background.js b/background.js index 2f6e304d..c5927143 100644 --- a/background.js +++ b/background.js @@ -56,7 +56,7 @@ chrome.runtime.onInstalled.addListener(function (object) { if (!shownInstallPage){ //open up the install page - chrome.tabs.create({url: chrome.extension.getURL("/help/"+chrome.i18n.getMessage("helpPage")}); + chrome.tabs.create({url: chrome.extension.getURL("/help/"+chrome.i18n.getMessage("helpPage"))}); } // TODO (shownInstallPage): delete if statement and contents diff --git a/content.js b/content.js index 265e1a41..5d433620 100644 --- a/content.js +++ b/content.js @@ -990,9 +990,8 @@ function vote(type, UUID) { addLoadingInfo(chrome.i18n.getMessage("serverDown"), UUID) } else { //failure: unknown error - addLoadingInfo((chrome.i18n.getMessage("connectionError") + response.statusCode, UUID) + addLoadingInfo(chrome.i18n.getMessage("connectionError") + response.statusCode, UUID); } - } } });