Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/Anarios/return-youtube-dislike.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CONTRIBUTING.md2
-rw-r--r--Extensions/combined/_locales/en/messages.json6
-rw-r--r--Extensions/combined/_locales/fr/messages.json6
-rw-r--r--Extensions/combined/popup.html94
-rw-r--r--Extensions/combined/popup.js2
-rw-r--r--Extensions/combined/ryd.background.js13
-rw-r--r--Extensions/combined/src/bar.js9
-rw-r--r--Extensions/combined/src/state.js43
-rw-r--r--Extensions/combined/src/utils.js5
-rw-r--r--Website/pages/faq.vue7
-rw-r--r--Website/pages/index.vue2
11 files changed, 120 insertions, 69 deletions
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
diff --git a/Extensions/combined/_locales/en/messages.json b/Extensions/combined/_locales/en/messages.json
index 8493b52..f937645 100644
--- a/Extensions/combined/_locales/en/messages.json
+++ b/Extensions/combined/_locales/en/messages.json
@@ -26,9 +26,15 @@
"textSettings": {
"message": "Disable like/dislike submission"
},
+ "textLikesDisabled": {
+ "message": "disabled by owner"
+ },
"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..1fc16cb 100644
--- a/Extensions/combined/_locales/fr/messages.json
+++ b/Extensions/combined/_locales/fr/messages.json
@@ -23,12 +23,18 @@
"legendSettings": {
"message": "Paramètres"
},
+ "textLikesDisabled": {
+ "message": "Désactivé par le créateur"
+ },
"textSettings": {
"message": "Désactiver l'envoi des likes/dislikes"
},
"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/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 @@
/>
</head>
<body>
-<center>
- <svg width="48" viewBox="0 0 24 24">
- <path
- d="M14.9 3H6c-.9 0-1.6.5-1.9 1.2l-3 7c-.1.3-.1.5-.1.7v2c0 1.1.9 2 2 2h6.3l-.9 4.5c-.1.5 0 1 .4 1.4l1.1 1.1 6.5-6.6c.4-.4.6-.9.6-1.4V5c-.1-1.1-1-2-2.1-2zm7.4 12.8h-2.9c-.4 0-.7-.3-.7-.7V3.9c0-.4.3-.7.7-.7h2.9c.4 0 .7.3.7.7V15c0 .4-.3.8-.7.8z"
- fill="red"
+ <center>
+ <svg width="48" viewBox="0 0 24 24">
+ <path
+ d="M14.9 3H6c-.9 0-1.6.5-1.9 1.2l-3 7c-.1.3-.1.5-.1.7v2c0 1.1.9 2 2 2h6.3l-.9 4.5c-.1.5 0 1 .4 1.4l1.1 1.1 6.5-6.6c.4-.4.6-.9.6-1.4V5c-.1-1.1-1-2-2.1-2zm7.4 12.8h-2.9c-.4 0-.7-.3-.7-.7V3.9c0-.4.3-.7.7-.7h2.9c.4 0 .7.3.7.7V15c0 .4-.3.8-.7.8z"
+ fill="red"
+ />
+ <path d="m8 12.5 5.1-2.9L8 6.7v5.8z" fill="#fff"/>
+ </svg>
+ <h1 style="margin-bottom: 0.75rem" title="__MSG_extensionName__">
+ __MSG_extensionName__
+ </h1>
+ <p style="color: var(--lightGrey)" title="__MSG_textDeveloper__">
+ __MSG_textDeveloper__
+ </p>
+
+ <button id="link_website" title="__MSG_linkWebsite__">
+ __MSG_linkWebsite__
+ </button>
+ <button style="margin-top: 0.3em; background: #ff0000" id="link_donate" title="__MSG_linkDonate__">
+ __MSG_linkDonate__
+ </button>
+ <button id="link_discord">Discord</button>
+ <br/>
+ <button style="margin-top: 0.3rem" id="link_faq" title="__MSG_linkFAQ__">
+ __MSG_linkFAQ__
+ </button>
+ <button id="link_github">GitHub</button>
+ <button style="margin-top: 0.3em" id="link_help" title="__MSG_linkHelp__">
+ __MSG_linkHelp__
+ </button>
+ <br>
+ <button style="margin-top: 0.3em" id="link_changelog" title="__MSG_linkChangelog__">
+ Change Log
+ </button>
+
+ <br/>
+ <br/>
+ <p style="display: none">API Status: <b id="status"></b></p>
+ <img
+ id="server-status"
+ style="display: none; width: 0.75rem; height: 0.75rem"
+ src="./icons/server.svg"
+ alt=""
/>
- <path d="m8 12.5 5.1-2.9L8 6.7v5.8z" fill="#fff"/>
- </svg>
- <h1 style="margin-bottom: 0.75rem" title="__MSG_extensionName__">
- __MSG_extensionName__
- </h1>
- <p style="color: var(--lightGrey)" title="__MSG_textDeveloper__">
- __MSG_textDeveloper__
- </p>
-
- <button id="link_website" title="__MSG_linkWebsite__">
- __MSG_linkWebsite__
- </button>
- <button
- style="margin-top: 0.3em; background: #ff0000"
- id="link_donate"
- title="__MSG_linkDonate__"
- >
- __MSG_linkDonate__
- </button>
- <button id="link_discord">Discord</button>
- <br/>
- <button style="margin-top: 0.3rem" id="link_faq" title="__MSG_linkFAQ__">
- __MSG_linkFAQ__
- </button>
- <button id="link_github">GitHub</button>
- <button style="margin-top: 0.3em" id="link_help" title="__MSG_linkHelp__">
- __MSG_linkHelp__
- </button>
-
- <br/>
- <br/>
- <p style="display: none">API Status: <b id="status"></b></p>
- <img
- id="server-status"
- style="display: none; width: 0.75rem; height: 0.75rem"
- src="./icons/server.svg"
- alt=""
- />
-
- <br/>
- <br/>
-</center>
+
+ <br/>
+ <br/>
+ </center>
<!-- top-right -->
<button id="advancedToggle">
diff --git a/Extensions/combined/popup.js b/Extensions/combined/popup.js
index 83ee423..53eb179 100644
--- a/Extensions/combined/popup.js
+++ b/Extensions/combined/popup.js
@@ -19,6 +19,7 @@ const config = {
donate: "https://returnyoutubedislike.com/donate",
faq: "https://returnyoutubedislike.com/faq",
help: "https://returnyoutubedislike.com/help",
+ changelog: "/changelog/3/changelog_3.0.html"
},
};
@@ -49,6 +50,7 @@ createLink(config.links.discord, "link_discord");
createLink(config.links.faq, "link_faq");
createLink(config.links.donate, "link_donate");
createLink(config.links.help, "link_help");
+createLink(config.links.changelog, "link_changelog");
function createLink(url, id) {
document.getElementById(id).addEventListener("click", () => {
diff --git a/Extensions/combined/ryd.background.js b/Extensions/combined/ryd.background.js
index 18eb0fa..08f6afa 100644
--- a/Extensions/combined/ryd.background.js
+++ b/Extensions/combined/ryd.background.js
@@ -74,9 +74,16 @@ 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(['lastShowChangelogVersion'], (details) => {
+ if (extConfig.showUpdatePopup === true &&
+ details.lastShowChangelogVersion !== chrome.runtime.getManifest().version
+ ) {
+ // keep it inside get to avoid race condition
+ api.storage.sync.set({'lastShowChangelogVersion ': chrome.runtime.getManifest().version});
+ // wait until async get runs & don't steal tab focus
+ api.tabs.create({url: api.runtime.getURL("/changelog/3/changelog_3.0.html"), active: false});
+ }
+ });
async function sendVote(videoId, vote) {
api.storage.sync.get(null, async (storageResult) => {
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 6a85e8c..4ca7d35 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";
@@ -15,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,
@@ -32,8 +31,6 @@ let storedData = {
previousState: NEUTRAL_STATE,
};
-let likesDisabledState = true;
-
function isMobile() {
return location.hostname == "m.youtube.com";
}
@@ -42,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 (
@@ -78,7 +85,7 @@ function setLikes(likesCount) {
}
function setDislikes(dislikesCount) {
- if (!likesDisabledState) {
+ if (!isLikesDisabled()) {
if (isMobile()) {
getButtons().children[1].querySelector(
".button-renderer-text"
@@ -91,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"
+ );
}
}
@@ -124,6 +132,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,14 +159,14 @@ 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 =
- numberFormat(response.dislikes) == 0 &&
- numberFormat(response.likes) == 0 &&
- numberFormat(response.viewCount) == 0;
if (response !== undefined && !("traceId" in response) && !statsSet) {
processResponse(response, storedData);
}
@@ -250,5 +265,5 @@ export {
extConfig,
initExtConfig,
storedData,
- likesDisabledState,
+ isLikesDisabled
};
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,
};
diff --git a/Website/pages/faq.vue b/Website/pages/faq.vue
index 1df8900..af0741d 100644
--- a/Website/pages/faq.vue
+++ b/Website/pages/faq.vue
@@ -36,7 +36,7 @@ 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?",
@@ -44,6 +44,11 @@ export default {
"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 encourage your viewers to use this extension (or any app that submits votes to returnyoutubedislikeapi.com) ",
+ },
+ {
question: "How does this work?",
answer:
"The extension collects the video ID of the video you are watching, fetches the dislike (and other fields like views, likes etc) using our API. The extension then displays the dislike count and ratio on the page. If you like or dislike a video, that is recorded and sent to the database so an accurate dislike count can be extrapolated.",
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;