From c1170855f8e5d0a48804517e615a89ba53e0f2d9 Mon Sep 17 00:00:00 2001 From: RyanBurgert219 Date: Sun, 20 Mar 2022 18:36:21 -0400 Subject: [PATCH 01/26] Added YouTube tutorial to contribution guide --- CONTRIBUTING.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index e9248df..d05c308 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -34,6 +34,8 @@ npm run build // to create the build file(s) once Congratulations, You are now ready to develop! +If you are new to developing Chrome extensions, or need extra help, please see [this YouTube tutorial](https://www.youtube.com/watch?v=mdOj6HYE3_0) + ### Issues #### Opening a new issue From 1d2f89a38c6743489e399fd9d5021df52d3f6150 Mon Sep 17 00:00:00 2001 From: Cyril Strahm Date: Wed, 6 Apr 2022 21:50:39 +0200 Subject: [PATCH 02/26] Display 'temporarily unavailable' when the API can't be reached --- Extensions/combined/_locales/en/messages.json | 3 +++ Extensions/combined/_locales/fr/messages.json | 3 +++ Extensions/combined/src/state.js | 14 +++++++++++++- Extensions/combined/src/utils.js | 5 +++++ 4 files changed, 24 insertions(+), 1 deletion(-) diff --git a/Extensions/combined/_locales/en/messages.json b/Extensions/combined/_locales/en/messages.json index 8493b52..c53f45a 100644 --- a/Extensions/combined/_locales/en/messages.json +++ b/Extensions/combined/_locales/en/messages.json @@ -29,6 +29,9 @@ "textSettingsHover": { "message": "Stops counting your likes and dislikes." }, + "textTempUnavailable": { + "message": "temporarily unavailable" + }, "textUpdate": { "message": "update to" }, diff --git a/Extensions/combined/_locales/fr/messages.json b/Extensions/combined/_locales/fr/messages.json index 78878f0..7556201 100644 --- a/Extensions/combined/_locales/fr/messages.json +++ b/Extensions/combined/_locales/fr/messages.json @@ -29,6 +29,9 @@ "textSettingsHover": { "message": "Arrête de compter les likes et les dislikes mis sur les vidéos." }, + "textTempUnavailable": { + "message": "temporairement indisponible" + }, "textUpdate": { "message": "mettre à jour vers" } diff --git a/Extensions/combined/src/state.js b/Extensions/combined/src/state.js index 6a85e8c..c4abdfa 100644 --- a/Extensions/combined/src/state.js +++ b/Extensions/combined/src/state.js @@ -8,6 +8,7 @@ import { getColorFromTheme, } from "./utils"; import { sendVideoIds } from "./events"; +import { localize } from "./utils"; //TODO: Do not duplicate here and in ryd.background.js const apiUrl = "https://returnyoutubedislikeapi.com"; @@ -124,6 +125,13 @@ function processResponse(response, storedData) { } } +// Tells the user if the API is down +function displayError(error) { + getButtons().children[1].querySelector("#text").innerText = localize( + "textTempUnavailable" + ); +} + async function setState(storedData) { storedData.previousState = isVideoDisliked() ? DISLIKED_STATE @@ -144,8 +152,12 @@ async function setState(storedData) { }, } ) + .then((response) => { + if (!response.ok) displayError(response.error); + return response; + }) .then((response) => response.json()) - .catch(); + .catch(displayError); cLog("response from api:"); cLog(JSON.stringify(response)); likesDisabledState = diff --git a/Extensions/combined/src/utils.js b/Extensions/combined/src/utils.js index 7cedc21..b1acc54 100644 --- a/Extensions/combined/src/utils.js +++ b/Extensions/combined/src/utils.js @@ -29,6 +29,10 @@ function numberFormat(numberState) { ); } +function localize(localeString) { + return chrome.i18n.getMessage(localeString); +} + function getNumberFormatter(optionSelect) { let formatterNotation; let formatterCompactDisplay; @@ -151,4 +155,5 @@ export { isVideoLoaded, cLog, getColorFromTheme, + localize, }; From 43a7167e2b02a5476a98ee87cffa1f9778ae9824 Mon Sep 17 00:00:00 2001 From: CreaZyp154 Date: Tue, 12 Apr 2022 13:43:50 +0200 Subject: [PATCH 03/26] Closes #472 --- Extensions/combined/_locales/en/messages.json | 3 ++ Extensions/combined/_locales/fr/messages.json | 3 ++ Extensions/combined/src/bar.js | 9 ++++-- Extensions/combined/src/state.js | 29 ++++++++++--------- 4 files changed, 28 insertions(+), 16 deletions(-) diff --git a/Extensions/combined/_locales/en/messages.json b/Extensions/combined/_locales/en/messages.json index c53f45a..f937645 100644 --- a/Extensions/combined/_locales/en/messages.json +++ b/Extensions/combined/_locales/en/messages.json @@ -26,6 +26,9 @@ "textSettings": { "message": "Disable like/dislike submission" }, + "textLikesDisabled": { + "message": "disabled by owner" + }, "textSettingsHover": { "message": "Stops counting your likes and dislikes." }, diff --git a/Extensions/combined/_locales/fr/messages.json b/Extensions/combined/_locales/fr/messages.json index 7556201..1fc16cb 100644 --- a/Extensions/combined/_locales/fr/messages.json +++ b/Extensions/combined/_locales/fr/messages.json @@ -23,6 +23,9 @@ "legendSettings": { "message": "Paramètres" }, + "textLikesDisabled": { + "message": "Désactivé par le créateur" + }, "textSettings": { "message": "Désactiver l'envoi des likes/dislikes" }, diff --git a/Extensions/combined/src/bar.js b/Extensions/combined/src/bar.js index dbd4c68..c56ab57 100644 --- a/Extensions/combined/src/bar.js +++ b/Extensions/combined/src/bar.js @@ -1,8 +1,9 @@ import { getButtons } from "./buttons"; -import { likesDisabledState, extConfig, isMobile } from "./state"; +import { extConfig, isMobile, isLikesDisabled } from "./state"; import { cLog, getColorFromTheme } from "./utils"; + function createRateBar(likes, dislikes) { - if (!likesDisabledState) { + if (!isLikesDisabled()) { let rateBar = document.getElementById("ryd-bar-container"); const widthPx = @@ -61,7 +62,9 @@ function createRateBar(likes, dislikes) { } else { cLog("removing bar"); let ratebar = document.getElementById("ryd-bar-container"); - ratebar.parentNode.removeChild(ratebar); + if(ratebar) { + ratebar.parentNode.removeChild(ratebar); + } } } diff --git a/Extensions/combined/src/state.js b/Extensions/combined/src/state.js index c4abdfa..4ca7d35 100644 --- a/Extensions/combined/src/state.js +++ b/Extensions/combined/src/state.js @@ -16,8 +16,6 @@ const LIKED_STATE = "LIKED_STATE"; const DISLIKED_STATE = "DISLIKED_STATE"; const NEUTRAL_STATE = "NEUTRAL_STATE"; -const DISLIKES_DISABLED_TEXT = "DISLIKES DISABLED"; - let extConfig = { disableVoteSubmission: false, coloredThumbs: false, @@ -33,8 +31,6 @@ let storedData = { previousState: NEUTRAL_STATE, }; -let likesDisabledState = true; - function isMobile() { return location.hostname == "m.youtube.com"; } @@ -43,6 +39,16 @@ function isShorts() { return location.pathname.startsWith("/shorts"); } +function isLikesDisabled() { + // return true if the like button's text doesn't contain any number + if (isMobile()) { + return /^\D*$/.test( + getButtons().children[0].querySelector(".button-renderer-text").innerText + ); + } + return /^\D*$/.test(getButtons().children[0].querySelector("#text").innerText); +} + function isVideoLiked() { if (isMobile()) { return ( @@ -79,7 +85,7 @@ function setLikes(likesCount) { } function setDislikes(dislikesCount) { - if (!likesDisabledState) { + if (!isLikesDisabled()) { if (isMobile()) { getButtons().children[1].querySelector( ".button-renderer-text" @@ -92,11 +98,12 @@ function setDislikes(dislikesCount) { if (isMobile()) { getButtons().children[1].querySelector( ".button-renderer-text" - ).innerText = DISLIKES_DISABLED_TEXT; + ).innerText = localize("TextLikesDisabled"); return; } - getButtons().children[1].querySelector("#text").innerText = - DISLIKES_DISABLED_TEXT; + getButtons().children[1].querySelector("#text").innerText = localize( + "TextLikesDisabled" + ); } } @@ -160,10 +167,6 @@ async function setState(storedData) { .catch(displayError); cLog("response from api:"); cLog(JSON.stringify(response)); - likesDisabledState = - numberFormat(response.dislikes) == 0 && - numberFormat(response.likes) == 0 && - numberFormat(response.viewCount) == 0; if (response !== undefined && !("traceId" in response) && !statsSet) { processResponse(response, storedData); } @@ -262,5 +265,5 @@ export { extConfig, initExtConfig, storedData, - likesDisabledState, + isLikesDisabled }; From 237997c565f0d284ae4d6b30033fcd29865c7386 Mon Sep 17 00:00:00 2001 From: sy-b <94835959+sy-b@users.noreply.github.com> Date: Sat, 16 Apr 2022 07:16:27 +0530 Subject: [PATCH 04/26] FAQ - improve accuracy of count && minor typo fix --- Website/pages/faq.vue | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Website/pages/faq.vue b/Website/pages/faq.vue index 1df8900..5fbecd5 100644 --- a/Website/pages/faq.vue +++ b/Website/pages/faq.vue @@ -36,13 +36,18 @@ export default { { question: "Where does the extension get its data?", answer: - "A combination of archived data from before the offical YouTube dislike API shut down, and extrapolated extension user behavior.", + "A combination of archived data from before the official YouTube dislike API shut down, and extrapolated extension user behavior.", }, { question: "Why isn't the dislike count updating?", answer: "Right now video dislikes are cached and they aren't updated very frequently. It varies depending on a video's popularity but can take anywhere between a few hours and a few days to update.", }, + { + question: "Why is the dislike count on my videos inaccurate?", + answer: + "Extrapolated data tends to get better with the increase in diversity and the quantity of voters. \nTo ensure and increase the accuracy of the extrapolated vote data for your videos, you can ask your viewers to uses this extension (or any app that submits votes to returnyoutubedislikeapi.com) ", + }, { question: "How does this work?", answer: From 4ded89c61508195507f0188726024ac5726de1bc Mon Sep 17 00:00:00 2001 From: sy-b <94835959+sy-b@users.noreply.github.com> Date: Sat, 16 Apr 2022 07:42:47 +0530 Subject: [PATCH 05/26] Remove unnecessary escape character, failing check fixed ``` \return-youtube-dislike\Website\pages\index.vue 129:198 error Unnecessary escape character: \/ no-useless-escape ``` --- Website/pages/index.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Website/pages/index.vue b/Website/pages/index.vue index 713cad4..f1a26a6 100644 --- a/Website/pages/index.vue +++ b/Website/pages/index.vue @@ -123,7 +123,7 @@ export default { }; }, mounted() { - const YOUTUBE_REGEX = /(?:http:|https:)*?\/\/(?:www\.|)(?:youtube\.com|m\.youtube\.com|youtu\.|youtube-nocookie\.com).*(?:v=|v%3D|v\/|(?:a|p)\/(?:a|u)\/\d.*\/|watch\?|vi(?:=|\/)|\/embed\/|oembed\?|be\/|e\/)([^&?%#\/\n]*)/; + const YOUTUBE_REGEX = /(?:http:|https:)*?\/\/(?:www\.|)(?:youtube\.com|m\.youtube\.com|youtu\.|youtube-nocookie\.com).*(?:v=|v%3D|v\/|(?:a|p)\/(?:a|u)\/\d.*\/|watch\?|vi(?:=|\/)|\/embed\/|oembed\?|be\/|e\/)([^&?%#/\n]*)/; let lastVideoId = ""; window.oninput = (e) => { const videoId = (e.target.value.match(YOUTUBE_REGEX) || {})[1] || e.target.value; From 23b1c0446c49ec1f0c3033b596f19f978496c6a3 Mon Sep 17 00:00:00 2001 From: sy-b <94835959+sy-b@users.noreply.github.com> Date: Sat, 16 Apr 2022 07:52:47 +0530 Subject: [PATCH 06/26] Update faq.vue --- Website/pages/faq.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Website/pages/faq.vue b/Website/pages/faq.vue index 5fbecd5..ae41236 100644 --- a/Website/pages/faq.vue +++ b/Website/pages/faq.vue @@ -46,7 +46,7 @@ export default { { question: "Why is the dislike count on my videos inaccurate?", answer: - "Extrapolated data tends to get better with the increase in diversity and the quantity of voters. \nTo ensure and increase the accuracy of the extrapolated vote data for your videos, you can ask your viewers to uses this extension (or any app that submits votes to returnyoutubedislikeapi.com) ", + "Extrapolated data tends to get better with the increase in diversity and the quantity of voters. \nTo ensure and increase the accuracy of the extrapolated vote data for your videos, you can encourage your viewers to uses this extension (or any app that submits votes to returnyoutubedislikeapi.com) ", }, { question: "How does this work?", From 8c5c505efc356f9fde354bee648f56a024ccf541 Mon Sep 17 00:00:00 2001 From: sy-b <94835959+sy-b@users.noreply.github.com> Date: Sat, 16 Apr 2022 09:33:34 +0530 Subject: [PATCH 07/26] typo fixed in faq.vue uses --> use --- Website/pages/faq.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Website/pages/faq.vue b/Website/pages/faq.vue index ae41236..af0741d 100644 --- a/Website/pages/faq.vue +++ b/Website/pages/faq.vue @@ -46,7 +46,7 @@ export default { { question: "Why is the dislike count on my videos inaccurate?", answer: - "Extrapolated data tends to get better with the increase in diversity and the quantity of voters. \nTo ensure and increase the accuracy of the extrapolated vote data for your videos, you can encourage your viewers to uses this extension (or any app that submits votes to returnyoutubedislikeapi.com) ", + "Extrapolated data tends to get better with the increase in diversity and the quantity of voters. \nTo ensure and increase the accuracy of the extrapolated vote data for your videos, you can encourage your viewers to use this extension (or any app that submits votes to returnyoutubedislikeapi.com) ", }, { question: "How does this work?", From b73aaddb59e5786e49475ac141e996d895411395 Mon Sep 17 00:00:00 2001 From: sy-b <94835959+sy-b@users.noreply.github.com> Date: Sat, 16 Apr 2022 19:57:36 +0530 Subject: [PATCH 08/26] Show changelog only on installation fixes #534 --- Extensions/combined/ryd.background.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/Extensions/combined/ryd.background.js b/Extensions/combined/ryd.background.js index 18eb0fa..4139bbe 100644 --- a/Extensions/combined/ryd.background.js +++ b/Extensions/combined/ryd.background.js @@ -74,9 +74,12 @@ api.runtime.onMessage.addListener((request, sender, sendResponse) => { } }); -api.runtime.onInstalled.addListener(() => { - api.tabs.create({url: api.runtime.getURL("/changelog/3/changelog_3.0.html")}); -}) +api.storage.sync.get(['newInstallation'], (result) => { + if (result.newInstallation !== false) { + api.tabs.create({url: api.runtime.getURL("/changelog/3/changelog_3.0.html")}); + } +}); +api.storage.sync.set({'newInstallation': false}); async function sendVote(videoId, vote) { api.storage.sync.get(null, async (storageResult) => { From 991f29771a4e2abacdb958b9f28ea97ba59cc970 Mon Sep 17 00:00:00 2001 From: sy-b <94835959+sy-b@users.noreply.github.com> Date: Sat, 16 Apr 2022 14:40:31 +0000 Subject: [PATCH 09/26] add changelog button in popup --- Extensions/combined/popup.html | 94 +++++++++++++++++----------------- Extensions/combined/popup.js | 2 + 2 files changed, 49 insertions(+), 47 deletions(-) diff --git a/Extensions/combined/popup.html b/Extensions/combined/popup.html index aa2d6a8..aeaba4c 100644 --- a/Extensions/combined/popup.html +++ b/Extensions/combined/popup.html @@ -12,54 +12,54 @@ /> -
- - + + + + +

+ __MSG_extensionName__ +

+

+ __MSG_textDeveloper__ +

+ + + + +
+ + + +
+ + +
+
+

API Status:

+ - - -

- __MSG_extensionName__ -

-

- __MSG_textDeveloper__ -

- - - - -
- - - - -
-
-

API Status:

- - -
-
-
+ +
+
+