diff --git a/Extensions/chrome/content-style.css b/Extensions/chrome/content-style.css
deleted file mode 100644
index b613f6a..0000000
--- a/Extensions/chrome/content-style.css
+++ /dev/null
@@ -1,26 +0,0 @@
-#return-youtube-dislike-bar-container {
- background: var(--yt-spec-icon-disabled);
- border-radius: 2px;
-}
-
-#return-youtube-dislike-bar {
- background: var(--yt-spec-text-primary);
- border-radius: 2px;
- transition: all 0.15s ease-in-out;
-}
-
-.ryd-tooltip {
- position: relative;
- display: block;
- height: 2px;
- top: 9px;
-}
-
-.ryd-tooltip-bar-container {
- width: 100%;
- height: 2px;
- position: absolute;
- padding-top: 6px;
- padding-bottom: 28px;
- top: -6px;
-}
diff --git a/Extensions/chrome/icons/icon128.png b/Extensions/chrome/icons/icon128.png
deleted file mode 100644
index 23b4958..0000000
Binary files a/Extensions/chrome/icons/icon128.png and /dev/null differ
diff --git a/Extensions/chrome/icons/icon48.png b/Extensions/chrome/icons/icon48.png
deleted file mode 100644
index f2a5951..0000000
Binary files a/Extensions/chrome/icons/icon48.png and /dev/null differ
diff --git a/Extensions/chrome/popup.css b/Extensions/chrome/popup.css
deleted file mode 100644
index 3075989..0000000
--- a/Extensions/chrome/popup.css
+++ /dev/null
@@ -1,119 +0,0 @@
-/* Variables */
-:root {
- --primary: #cc2929;
- --accent: #581111;
-
- --background: #111;
- --secondary: #272727;
- --tertiary: #333333;
- --lightGrey: #999;
- --white: #fff;
-}
-
-/* Window Styling */
-html,
-body {
- background-color: var(--background);
- color: var(--white);
- min-width: 300px;
- padding: 0.5em;
- font-family: 'Roboto', Arial, Helvetica, sans-serif;
- font-size: 14px;
-}
-
-h1 {
- font-size: 26px;
-}
-
-button {
- color: var(--white);
- background: var(--secondary);
- cursor: pointer;
- padding: 5px 16px;
- border: none;
- border-radius: 4px;
- font-weight: 500;
- box-shadow: 0 2px 4px -1px rgb(0 0 0 / 20%), 0 4px 5px 0 rgb(0 0 0 / 14%), 0 1px 10px 0 rgb(0 0 0 / 12%);
- transition: .4s;
-}
-
-button:hover {
- background: #444;
-}
-
-#advancedToggle {
- margin-top: 1em;
- margin-bottom: 2em;
-}
-
-#advancedSettings {
- display: none;
- border: 2px solid var(--secondary);
- border-radius: 0.5rem;
- padding: 1rem;
-}
-
-#advancedLegend {
- color: var(--tertiary) !important;
- /* margin: auto; */ /* Center the label */
- /* padding: .25rem .5rem; */
- /* border-radius: .25rem; */
- /* border: .25rem solid var(--secondary); */
-}
-
-/* Switches */
-.switch {
- position: relative;
- display: inline-block;
- width: 30px;
- height: 17px;
- margin-bottom: 1rem;
-}
-
-.switch:last-of-type {
- margin-bottom: 0;
-}
-
-.switch input {
- display: none;
-}
-
-.slider {
- position: absolute;
- cursor: pointer;
- top: 0;
- left: 0;
- right: 0;
- bottom: 0;
- background: var(--secondary);
- transition: 0.4s;
- border-radius: 34px;
-}
-
-.slider:before {
- position: absolute;
- content: "";
- height: 13px;
- width: 13px;
- left: 2px;
- bottom: 2px;
- background: var(--lightGrey);
- transition: 0.4s;
- border-radius: 50%;
-}
-
-input:checked + .slider {
- background: var(--accent);
-}
-
-input:checked + .slider:before {
- transform: translateX(13px);
- background: var(--primary);
-}
-
-.switchLabel {
- margin-left: 0.5rem;
- width: 250px !important;
- transform: translateX(35px);
- display: inline-block;
-}
diff --git a/Extensions/chrome/popup.html b/Extensions/chrome/popup.html
deleted file mode 100644
index d82a72e..0000000
--- a/Extensions/chrome/popup.html
+++ /dev/null
@@ -1,50 +0,0 @@
-
-
-
-
- Return YouTube Dislike
-
-
-
-
-
-
-
-
- Return YouTube Dislike
- by Dmitrii Selivanov & Community
-
-
-
-
-
-
- Donate
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/Extensions/chrome/popup.js b/Extensions/chrome/popup.js
deleted file mode 100644
index aeec1b1..0000000
--- a/Extensions/chrome/popup.js
+++ /dev/null
@@ -1,63 +0,0 @@
-/* Config */
-const config = {
- advanced: false,
- showAdvancedMessage: "Show Settings",
- hideAdvancedMessage: "Hide Settings",
-
- links: {
- website: "https://returnyoutubedislike.com",
- github: "https://github.com/Anarios/return-youtube-dislike",
- discord: "https://discord.gg/mYnESY4Md5",
- patreon: "https://www.patreon.com/returnyoutubedislike",
- yoomoney: "https://returnyoutubedislike.com/pay/yoomoney"
- },
-};
-
-/* Links */
-document.getElementById("link_website").addEventListener("click", () => {
- chrome.tabs.create({ url: config.links.website });
-});
-
-document.getElementById("link_github").addEventListener("click", () => {
- chrome.tabs.create({ url: config.links.github });
-});
-
-document.getElementById("link_discord").addEventListener("click", () => {
- chrome.tabs.create({ url: config.links.discord });
-});
-
-document.getElementById("link_patreon").addEventListener("click", () => {
- chrome.tabs.create({ url: config.links.patreon });
-});
-
-document.getElementById("link_yoomoney").addEventListener("click", () => {
- chrome.tabs.create({ url: config.links.yoomoney });
-});
-
-/* Advanced Toggle */
-/* Not currently used in this version
-const advancedToggle = document.getElementById("advancedToggle");
-advancedToggle.addEventListener("click", () => {
- const adv = document.getElementById("advancedSettings");
- if (config.advanced) {
- adv.style.display = "none";
- advancedToggle.innerHTML = config.showAdvancedMessage;
- config.advanced = false;
- } else {
- adv.style.display = "block";
- advancedToggle.innerHTML = config.hideAdvancedMessage;
- config.advanced = true;
- }
-});
-*/
-
-/* popup-script.js
-document.querySelector('#login')
-.addEventListener('click', function () {
- chrome.runtime.sendMessage({ message: 'get_auth_token' });
-});
-
-document.querySelector("#log_off").addEventListener("click", function () {
- chrome.runtime.sendMessage({ message: "log_off" });
-});
-*/
diff --git a/Extensions/chrome/return-youtube-dislike.background.js b/Extensions/chrome/return-youtube-dislike.background.js
deleted file mode 100644
index b9fefe2..0000000
--- a/Extensions/chrome/return-youtube-dislike.background.js
+++ /dev/null
@@ -1,111 +0,0 @@
-const apiUrl = "https://returnyoutubedislikeapi.com";
-
-// Security token causes issues if extension is reloaded/updated while several tabs are open
-// const securityToken = Math.random().toString(36).substring(2, 15);
-//
-// chrome.runtime.onMessage.addListener((request, sender, sendResponse) => {
-// sendResponse(securityToken);
-// });
-
-chrome.runtime.onMessageExternal.addListener(
- (request, sender, sendResponse) => {
- if (request.message === "get_auth_token") {
- // chrome.identity.getAuthToken({ interactive: true }, function (token) {
- // console.log(token);
- // chrome.identity.getProfileUserInfo(function (userInfo) {
- // console.log(JSON.stringify(userInfo));
- // });
- // });
- } else if (request.message === "log_off") {
- // chrome.identity.clearAllCachedAuthTokens(() => console.log("logged off"));
- } else if (request.message == "set_state") {
- // chrome.identity.getAuthToken({ interactive: true }, function (token) {
- let token = "";
- fetch(`${apiUrl}/votes?videoId=${request.videoId}`, {
- method: "GET",
- headers: {
- Accept: "application/json",
- Authorization: "Bearer " + token,
- },
- })
- .then((response) => response.json())
- .then((response) => {
- sendResponse(response);
- })
- .catch();
- return true;
- } else if (request.message == "send_links") {
- toSend = toSend.concat(request.videoIds.filter((x) => !sentIds.has(x)));
- if (toSend.length >= 20) {
- fetch(`${apiUrl}/votes`, {
- method: "POST",
- headers: {
- "Content-Type": "application/json",
- },
- body: JSON.stringify(toSend),
- });
- for (const toSendUrl of toSend) {
- sentIds.add(toSendUrl);
- }
- toSend = [];
- }
- } else if (request.message == "fetch_from_youtube") {
- fetch(`https://www.youtube.com/watch?v=${request.videoId}`, {
- method: "GET",
- })
- .then((response) => response.text())
- .then((text) => {
- let result = getDislikesFromYoutubeResponse(text);
- sendUserSubmittedStatisticsToApi({
- ...result,
- videoId: request.videoId,
- });
- sendResponse(result);
- });
- }
- }
-);
-
-const sentIds = new Set();
-let toSend = [];
-
-function getDislikesFromYoutubeResponse(htmlResponse) {
- let start =
- htmlResponse.indexOf('"videoDetails":') + '"videoDetails":'.length;
- let end =
- htmlResponse.indexOf('"isLiveContent":false}', start) +
- '"isLiveContent":false}'.length;
- if (end < start) {
- end =
- htmlResponse.indexOf('"isLiveContent":true}', start) +
- '"isLiveContent":true}'.length;
- }
- let jsonStr = htmlResponse.substring(start, end);
- let jsonResult = JSON.parse(jsonStr);
- let rating = jsonResult.averageRating;
-
- start = htmlResponse.indexOf('"topLevelButtons":[', end);
- start =
- htmlResponse.indexOf('"accessibilityData":', start) +
- '"accessibilityData":'.length;
- end = htmlResponse.indexOf("}", start);
- let likes = +htmlResponse.substring(start, end).replace(/\D/g, "");
- let dislikes = (likes * (5 - rating)) / (rating - 1);
- let result = {
- likes,
- dislikes: Math.round(dislikes),
- rating,
- viewCount: +jsonResult.viewCount,
- };
- return result;
-}
-
-function sendUserSubmittedStatisticsToApi(statistics) {
- fetch(`${apiUrl}/votes/user-submitted`, {
- method: "POST",
- headers: {
- "Content-Type": "application/json",
- },
- body: JSON.stringify(statistics),
- });
-}
diff --git a/Extensions/chrome/return-youtube-dislike.content-script.js b/Extensions/chrome/return-youtube-dislike.content-script.js
deleted file mode 100644
index 37d679c..0000000
--- a/Extensions/chrome/return-youtube-dislike.content-script.js
+++ /dev/null
@@ -1,10 +0,0 @@
-chrome.runtime.sendMessage({}, (securityToken) => {
- let script = document.createElement("script");
- script.setAttribute("security-token", securityToken);
- script.setAttribute("extension-id", chrome.runtime.id);
- script.src = chrome.runtime.getURL("return-youtube-dislike.script.js");
- script.onload = function () {
- this.remove();
- };
- (document.head || document.documentElement).appendChild(script);
-});
diff --git a/Extensions/chrome/return-youtube-dislike.script.js b/Extensions/chrome/return-youtube-dislike.script.js
deleted file mode 100644
index 5389f54..0000000
--- a/Extensions/chrome/return-youtube-dislike.script.js
+++ /dev/null
@@ -1,314 +0,0 @@
-const LIKED_STATE = "LIKED_STATE";
-const DISLIKED_STATE = "DISLIKED_STATE";
-const NEUTRAL_STATE = "NEUTRAL_STATE";
-
-(function (extensionId) {
- let storedData = {
- likes: 0,
- dislikes: 0,
- previousState: NEUTRAL_STATE,
- };
-
- function cLog(message, writer) {
- message = `[return youtube dislike]: ${message}`;
- if (writer) {
- writer(message);
- } else {
- console.log(message);
- }
- }
-
- function getButtons() {
- //--- If Menu Element Is Displayed: ---//
- if (document.getElementById("menu-container")?.offsetParent === null) {
- return document.querySelector(
- "ytd-menu-renderer.ytd-watch-metadata > div"
- );
- //--- If Menu Element Isnt Displayed: ---//
- } else {
- return document
- .getElementById("menu-container")
- ?.querySelector("#top-level-buttons-computed");
- }
- }
-
- function getLikeButton() {
- return getButtons().children[0];
- }
-
- function getDislikeButton() {
- return getButtons().children[1];
- }
-
- function isVideoLiked() {
- return getLikeButton().classList.contains("style-default-active");
- }
-
- function isVideoDisliked() {
- return getDislikeButton().classList.contains("style-default-active");
- }
-
- function isVideoNotLiked() {
- return getLikeButton().classList.contains("style-text");
- }
-
- function isVideoNotDisliked() {
- return getDislikeButton().classList.contains("style-text");
- }
-
- function hasAvatarButton() {
- return !!document.querySelector('#avatar-btn')
- }
-
- function getState() {
- if (isVideoLiked()) {
- return { current: LIKED_STATE, previous: storedData.previousState };
- }
- if (isVideoDisliked()) {
- return { current: DISLIKED_STATE, previous: storedData.previousState };
- }
- return { current: NEUTRAL_STATE, previous: storedData.previousState };
- }
-
- //--- Sets The Likes And Dislikes Values ---//
- function setLikes(likesCount) {
- getButtons().children[0].querySelector("#text").innerText = likesCount;
- }
- function setDislikes(dislikesCount) {
- getButtons().children[1].querySelector("#text").innerText = dislikesCount;
- }
-
- function setState() {
- let statsSet = false;
- chrome.runtime.sendMessage(
- extensionId,
- {
- message: "fetch_from_youtube",
- videoId: getVideoId(window.location.href),
- },
- function (response) {
- if (response != undefined) {
- cLog("response from youtube:");
- cLog(JSON.stringify(response));
- try {
- if ("likes" in response && "dislikes" in response) {
- const formattedDislike = numberFormat(response.dislikes);
- setDislikes(formattedDislike);
- storedData.dislikes = parseInt(response.dislikes);
- storedData.likes = parseInt(response.likes);
- createRateBar(response.likes, response.dislikes);
- statsSet = true;
- }
- } catch (e) {
- statsSet = false;
- }
- }
- }
- );
-
- chrome.runtime.sendMessage(
- extensionId,
- {
- message: "set_state",
- videoId: getVideoId(window.location.href),
- state: getState().current,
- },
- function (response) {
- cLog("response from api:");
- cLog(JSON.stringify(response));
- if (response != undefined && !("traceId" in response) && !statsSet) {
- const formattedDislike = numberFormat(response.dislikes);
- // setLikes(response.likes);
- setDislikes(formattedDislike);
- createRateBar(response.likes, response.dislikes);
- } else {
- }
- }
- );
- }
-
- function likeClicked() {
- if (hasAvatarButton()) {
- if (storedData.previousState == DISLIKED_STATE) {
- storedData.dislikes--;
- storedData.likes++;
- createRateBar(storedData.likes, storedData.dislikes);
- setDislikes(numberFormat(storedData.dislikes));
- storedData.previousState = LIKED_STATE;
- } else if (storedData.previousState == NEUTRAL_STATE) {
- storedData.likes++;
- createRateBar(storedData.likes, storedData.dislikes);
- storedData.previousState = LIKED_STATE;
- } else if (storedData.previousState == LIKED_STATE) {
- storedData.likes--;
- createRateBar(storedData.likes, storedData.dislikes)
- storedData.previousState = NEUTRAL_STATE;
- }
- }
- }
-
- function dislikeClicked() {
- if (hasAvatarButton()) {
- if (storedData.previousState == NEUTRAL_STATE) {
- storedData.dislikes++;
- setDislikes(numberFormat(storedData.dislikes));
- createRateBar(storedData.likes, storedData.dislikes);
- storedData.previousState = DISLIKED_STATE;
- } else if (storedData.previousState == DISLIKED_STATE) {
- storedData.dislikes--;
- setDislikes(numberFormat(storedData.dislikes));
- createRateBar(storedData.likes, storedData.dislikes);
- storedData.previousState = NEUTRAL_STATE;
- } else if (storedData.previousState == LIKED_STATE) {
- storedData.likes--;
- storedData.dislikes++;
- setDislikes(numberFormat(storedData.dislikes));
- createRateBar(storedData.likes, storedData.dislikes);
- storedData.previousState = DISLIKED_STATE;
- }
- }
- }
-
- function setInitialState() {
- setState();
- setTimeout(() => sendVideoIds(), 1500);
- }
-
- function getVideoId(url) {
- const urlObject = new URL(url);
- const pathname = urlObject.pathname;
- if (pathname.startsWith("/clip")) {
- return document.querySelector("meta[itemprop='videoId']").content;
- } else {
- return urlObject.searchParams.get("v");
- }
- }
-
- function isVideoLoaded() {
- const videoId = getVideoId(window.location.href);
- return (
- document.querySelector(`ytd-watch-flexy[video-id='${videoId}']`) !== null
- );
- }
-
- function roundDown(num) {
- if (num < 1000) return num;
- const int = Math.floor(Math.log10(num) - 2);
- const decimal = int + (int % 3 ? 1 : 0);
- const value = Math.floor(num / 10 ** decimal);
- return value * 10 ** decimal;
- }
-
- function numberFormat(numberState) {
- const userLocales = new URL(
- Array.from(document.querySelectorAll("head > link[rel='search']"))
- ?.find((n) => n?.getAttribute("href")?.includes("?locale="))
- ?.getAttribute("href")
- )?.searchParams?.get("locale");
-
- const formatter = Intl.NumberFormat(document.documentElement.lang || userLocales || navigator.language, {
- notation: "compact",
- });
-
- return formatter.format(roundDown(numberState));
- }
-
- let jsInitChecktimer = null;
-
- function setEventListeners(evt) {
- function checkForJS_Finish() {
- if (getButtons()?.offsetParent && isVideoLoaded()) {
- clearInterval(jsInitChecktimer);
- jsInitChecktimer = null;
- const buttons = getButtons();
- if (!window.returnDislikeButtonlistenersSet) {
- buttons.children[0].addEventListener("click", likeClicked);
- buttons.children[1].addEventListener("click", dislikeClicked);
- window.returnDislikeButtonlistenersSet = true;
- }
- setInitialState();
- }
- }
-
- if (window.location.href.indexOf("watch?") >= 0) {
- jsInitChecktimer = setInterval(checkForJS_Finish, 111);
- }
- }
-
- function createRateBar(likes, dislikes) {
- let rateBar = document.getElementById(
- "return-youtube-dislike-bar-container"
- );
-
- const widthPx =
- getButtons().children[0].clientWidth +
- getButtons().children[1].clientWidth +
- 8;
-
- const widthPercent =
- likes + dislikes > 0 ? (likes / (likes + dislikes)) * 100 : 50;
-
- if (!rateBar) {
- document.getElementById("menu-container").insertAdjacentHTML(
- "beforeend",
- `
-
- `
- );
- } else {
- document.getElementById(
- "return-youtube-dislike-bar-container"
- ).style.width = widthPx + "px";
- document.getElementById("return-youtube-dislike-bar").style.width =
- widthPercent + "%";
-
- document.querySelector(
- "#ryd-dislike-tooltip > #tooltip"
- ).innerHTML = `${likes.toLocaleString()} / ${dislikes.toLocaleString()}`;
- }
- }
-
- function sendVideoIds() {
- const ids = Array.from(
- document.getElementsByClassName(
- "yt-simple-endpoint ytd-compact-video-renderer"
- )
- )
- .concat(
- Array.from(
- document.getElementsByClassName("yt-simple-endpoint ytd-thumbnail")
- )
- )
- .filter((x) => x.href && x.href.indexOf("/watch?v=") > 0)
- .map((x) => getVideoId(x.href));
- chrome.runtime.sendMessage(extensionId, {
- message: "send_links",
- videoIds: ids,
- });
- }
-
- setEventListeners();
-
- document.addEventListener("yt-navigate-finish", function (event) {
- if (jsInitChecktimer !== null) clearInterval(jsInitChecktimer);
- window.returnDislikeButtonlistenersSet = false;
- setEventListeners();
- });
-
- setTimeout(() => sendVideoIds(), 2500);
-})(document.currentScript.getAttribute("extension-id"));
diff --git a/Extensions/combined/icons.zip b/Extensions/combined/icons.zip
new file mode 100644
index 0000000..19240a7
Binary files /dev/null and b/Extensions/combined/icons.zip differ
diff --git a/Extensions/combined/manifest.json b/Extensions/combined/manifest.json
index 59b3ea9..fc60ec9 100644
--- a/Extensions/combined/manifest.json
+++ b/Extensions/combined/manifest.json
@@ -1,41 +1,27 @@
{
"name": "Return YouTube Dislike",
"description": "Returns ability to see dislikes",
- "version": "2.0.0.1",
- "manifest_version": 3,
+ "version": "2.0.0.2",
+ "manifest_version": 2,
"background": {
- "service_worker": "ryd.background.js"
+ "scripts": ["ryd.background.js"]
},
"icons": {
"48": "icons/icon48.png",
- "128": "icons/icon128.png"
+ "128": "icons/icon128.png"
},
- "host_permissions": ["*://*.youtube.com/*"],
- "permissions": [
- "storage"
- ],
- "action": {
+ "permissions": ["activeTab", "*://*.youtube.com/*", "storage"],
+ "browser_action": {
"default_popup": "popup.html"
},
"content_scripts": [
{
- "matches": [
- "*://youtube.com/*",
- "*://www.youtube.com/*",
- "*://m.youtube.com/*"
- ],
+ "matches": ["*://*.youtube.com/*"],
"exclude_matches": ["*://*.music.youtube.com/*"],
- "js": ["ryd.content-script.js", "ryd.tools.js", "/init/init.js"],
- "css": ["content-style.css"]
- }
- ],
- "externally_connectable": {
- "matches": ["*://*.youtube.com/*"]
- },
- "web_accessible_resources": [
- {
- "resources": ["ryd.script.js"],
- "matches": ["*://*.youtube.com/*"]
+ "run_at": "document_idle",
+ "css": ["content-style.css"],
+ "js": ["ryd.content-script.js", "ryd.tools.js", "/init/init.js"]
}
]
+
}
diff --git a/Extensions/combined/manifestv2.json b/Extensions/combined/manifestv2.json
deleted file mode 100644
index d7119dd..0000000
--- a/Extensions/combined/manifestv2.json
+++ /dev/null
@@ -1,27 +0,0 @@
-{
- "name": "Return YouTube Dislike",
- "description": "Returns ability to see dislikes",
- "version": "2.0.0.1",
- "manifest_version": 2,
- "background": {
- "scripts": ["ryd.background.js"]
- },
- "icons": {
- "48": "icons/icon48.png",
- "128": "icons/icon128.png"
- },
- "permissions": ["activeTab", "*://*.youtube.com/*", "storage"],
- "browser_action": {
- "default_popup": "popup.html"
- },
- "content_scripts": [
- {
- "matches": ["*://*.youtube.com/*"],
- "exclude_matches": ["*://*.music.youtube.com/*"],
- "run_at": "document_idle",
- "css": ["content-style.css"],
- "js": ["ryd.content-script.js", "ryd.tools.js", "/init/init.js"]
- }
- ]
-
-}
diff --git a/Extensions/chrome/manifest.json b/Extensions/combined/manifestv3.json
similarity index 56%
rename from Extensions/chrome/manifest.json
rename to Extensions/combined/manifestv3.json
index 60c7ede..19f12c2 100644
--- a/Extensions/chrome/manifest.json
+++ b/Extensions/combined/manifestv3.json
@@ -1,29 +1,31 @@
{
"name": "Return YouTube Dislike",
"description": "Returns ability to see dislikes",
- "version": "1.1.0.2",
+ "version": "2.0.0.2",
"manifest_version": 3,
"background": {
- "service_worker": "return-youtube-dislike.background.js"
+ "service_worker": "ryd.background.js"
},
"icons": {
"48": "icons/icon48.png",
- "128": "icons/icon128.png"
+ "128": "icons/icon128.png"
},
"host_permissions": ["*://*.youtube.com/*"],
+ "permissions": [
+ "storage"
+ ],
"action": {
"default_popup": "popup.html"
},
- "oauth2": {
- "client_id": "292556337651-kbmq2pduaejrol457a5s1089ut6ug0u9.apps.googleusercontent.com",
- "scopes": ["openid"]
- },
"content_scripts": [
{
- "matches": ["*://*.youtube.com/*"],
+ "matches": [
+ "*://youtube.com/*",
+ "*://www.youtube.com/*",
+ "*://m.youtube.com/*"
+ ],
"exclude_matches": ["*://*.music.youtube.com/*"],
- "js": ["return-youtube-dislike.content-script.js"],
- "run_at": "document_start",
+ "js": ["ryd.content-script.js", "ryd.tools.js", "/init/init.js"],
"css": ["content-style.css"]
}
],
@@ -32,7 +34,7 @@
},
"web_accessible_resources": [
{
- "resources": ["return-youtube-dislike.script.js"],
+ "resources": ["ryd.script.js"],
"matches": ["*://*.youtube.com/*"]
}
]
diff --git a/Extensions/combined/ryd.background.js b/Extensions/combined/ryd.background.js
index 79350a1..0b146a4 100644
--- a/Extensions/combined/ryd.background.js
+++ b/Extensions/combined/ryd.background.js
@@ -48,20 +48,6 @@ api.runtime.onMessage.addListener((request, sender, sendResponse) => {
}
toSend = [];
}
- } else if (request.message == "fetch_from_youtube") {
- fetch(`https://www.youtube.com/watch?v=${request.videoId}`, {
- method: "GET",
- })
- .then((response) => response.text())
- .then((text) => {
- let result = getDislikesFromYoutubeResponse(text);
- sendUserSubmittedStatisticsToApi({
- ...result,
- videoId: request.videoId,
- });
- sendResponse(result);
- });
- return true;
} else if (request.message == "register") {
register();
return true;
diff --git a/Extensions/combined/ryd.content-script.js b/Extensions/combined/ryd.content-script.js
index 4e9c41f..d4c4c33 100644
--- a/Extensions/combined/ryd.content-script.js
+++ b/Extensions/combined/ryd.content-script.js
@@ -135,29 +135,6 @@ function RYD() {
? LIKED_STATE
: NEUTRAL_STATE;
let statsSet = false;
- RYDTools.getBrowser().runtime.sendMessage(
- {
- message: "fetch_from_youtube",
- videoId: getVideoId(window.location.href),
- },
- function (response) {
- if (response !== undefined) {
- cLog("response from youtube:");
- cLog(JSON.stringify(response));
- try {
- if (
- "likes" in response &&
- "dislikes" in response &&
- response.dislikes !== null &&
- !Number.isNaN(response.dislikes)
- ) {
- processResponse(response);
- statsSet = true;
- }
- } catch (e) {}
- }
- }
- );
RYDTools.getBrowser().runtime.sendMessage(
{
diff --git a/Extensions/firefox/content-style.css b/Extensions/firefox/content-style.css
deleted file mode 100644
index 94278f6..0000000
--- a/Extensions/firefox/content-style.css
+++ /dev/null
@@ -1,42 +0,0 @@
-html {
- /* fallback values for mobile */
- --yt-spec-icon-disabled: #909090;
- --yt-spec-text-primary: #030303;
-}
-
-#return-youtube-dislike-bar-container {
- background: var(--yt-spec-icon-disabled);
- border-radius: 2px;
-}
-
-#return-youtube-dislike-bar {
- background: var(--yt-spec-text-primary);
- border-radius: 2px;
- transition: all 0.15s ease-in-out;
-}
-
-.ryd-tooltip {
- position: relative;
- display: block;
- height: 2px;
- top: 9px;
-}
-
-ytm-slim-video-action-bar-renderer > .ryd-tooltip {
- padding-left: 12px;
- top: 0px;
-}
-
-/* tp-yt-paper-tooltip not supported on mobile */
-ytm-slim-video-action-bar-renderer tp-yt-paper-tooltip {
- display: none;
-}
-
-.ryd-tooltip-bar-container {
- width: 100%;
- height: 2px;
- position: absolute;
- padding-top: 6px;
- padding-bottom: 28px;
- top: -6px;
-}
diff --git a/Extensions/firefox/icons/icon128.png b/Extensions/firefox/icons/icon128.png
deleted file mode 100644
index 23b4958..0000000
Binary files a/Extensions/firefox/icons/icon128.png and /dev/null differ
diff --git a/Extensions/firefox/icons/icon48.png b/Extensions/firefox/icons/icon48.png
deleted file mode 100644
index f2a5951..0000000
Binary files a/Extensions/firefox/icons/icon48.png and /dev/null differ
diff --git a/Extensions/firefox/manifest.json b/Extensions/firefox/manifest.json
deleted file mode 100644
index dbe9f41..0000000
--- a/Extensions/firefox/manifest.json
+++ /dev/null
@@ -1,26 +0,0 @@
-{
- "name": "Return YouTube Dislike",
- "description": "Returns ability to see dislikes",
- "version": "1.1.0.2",
- "manifest_version": 2,
- "background": {
- "scripts": ["return-youtube-dislike.background.js"]
- },
- "icons": {
- "48": "icons/icon48.png",
- "128": "icons/icon128.png"
- },
- "permissions": ["activeTab", "*://*.youtube.com/*"],
- "browser_action": {
- "default_popup": "popup.html"
- },
- "content_scripts": [
- {
- "matches": ["*://*.youtube.com/*"],
- "exclude_matches": ["*://*.music.youtube.com/*"],
- "run_at": "document_idle",
- "css": ["content-style.css"]
- }
- ]
-
-}
diff --git a/Extensions/firefox/popup.css b/Extensions/firefox/popup.css
deleted file mode 100644
index 83f1c7e..0000000
--- a/Extensions/firefox/popup.css
+++ /dev/null
@@ -1,105 +0,0 @@
-/* Variables */
-:root {
- --primary: #CC2929;
- --accent: #581111;
-
- --background: #111;
- --secondary: #272727;
- --lightGrey: #999;
- --white: #fff;
-}
-
-/* Window Styling */
-html,body {
- background-color: var(--background);
- color: var(--white);
- width: 300px;
- padding: 0.5em;
- font-family: 'Roboto', Arial, Helvetica, sans-serif;
- font-size: 14px;
-}
-
-h1 {
- font-size: 26px;
-}
-
-button {
- color: var(--white);
- background: var(--secondary);
- cursor: pointer;
- padding: 5px 16px;
- border: none;
- border-radius: 4px;
- font-weight: 500;
- box-shadow: 0 2px 4px -1px rgb(0 0 0 / 20%), 0 4px 5px 0 rgb(0 0 0 / 14%), 0 1px 10px 0 rgb(0 0 0 / 12%);
- transition: .4s;
-}
-
-button:hover {
- background: #444;
-}
-
-#advancedToggle {
- margin-top: 1em;
- margin-bottom: 2em;
-}
-
-#advancedSettings {
- display: none;
- border: 2px solid var(--secondary);
- border-radius: 4px;
- padding: 0.5em;
- margin-right: 1em; /* FIREFOX ONLY */
-}
-
-/* Switches */
-.switch {
- position: relative;
- display: inline-block;
- width: 30px;
- height: 17px;
- margin-bottom: 0.5em;
-}
-
-.switch input {
- display: none;
-}
-
-.slider {
- position: absolute;
- cursor: pointer;
- top: 0;
- left: 0;
- right: 0;
- bottom: 0;
- background: var(--secondary);
- transition: .4s;
- border-radius: 34px;
-}
-
-.slider:before {
- position: absolute;
- content: '';
- height: 13px;
- width: 13px;
- left: 2px;
- bottom: 2px;
- background: var(--lightGrey);
- transition: .4s;
- border-radius: 50%;
-}
-
-input:checked+.slider {
- background: var(--accent);
-}
-
-input:checked+.slider:before {
- transform: translateX(13px);
- background: var(--primary);
-}
-
-.switchLabel {
- width: 250px !important;
- transform: translateX(35px);
- display: inline-block;
-}
\ No newline at end of file
diff --git a/Extensions/firefox/popup.html b/Extensions/firefox/popup.html
deleted file mode 100644
index 8e2f9c4..0000000
--- a/Extensions/firefox/popup.html
+++ /dev/null
@@ -1,54 +0,0 @@
-
-
-
-
- Return YouTube Dislike
-
-
-
-
-
-
-
-
-
-
- Return YouTube Dislike
- by Dmitrii Selivanov & Community
-
-
-
-
-
-
- Donate
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/Extensions/firefox/popup.js b/Extensions/firefox/popup.js
deleted file mode 100644
index 0a58786..0000000
--- a/Extensions/firefox/popup.js
+++ /dev/null
@@ -1,65 +0,0 @@
-/* Config */
-const config = {
- advanced: false,
- showAdvancedMessage: "Show Settings",
- hideAdvancedMessage: "Hide Settings",
-
- links: {
- website: 'https://returnyoutubedislike.com',
- github: 'https://github.com/Anarios/return-youtube-dislike',
- discord: 'https://discord.gg/mYnESY4Md5',
- patreon: 'https://www.patreon.com/returnyoutubedislike',
- yoomoney: 'https://returnyoutubedislike.com/pay/yoomoney'
- },
-};
-
-/* Links */
-document.getElementById('link_website').addEventListener('click', () => {
- chrome.tabs.create({url: config.links.website});
-});
-
-document.getElementById('link_github').addEventListener('click', () => {
- chrome.tabs.create({url: config.links.github});
-});
-
-document.getElementById('link_discord').addEventListener('click', () => {
- chrome.tabs.create({url: config.links.discord});
-});
-
-document.getElementById('link_patreon').addEventListener('click', () => {
- chrome.tabs.create({url: config.links.patreon});
-});
-
-document.getElementById('link_yoomoney').addEventListener('click', () => {
- chrome.tabs.create({url: config.links.yoomoney});
-});
-
-
-/* Advanced Toggle */
-/* Not currently used in this version
-const advancedToggle = document.getElementById('advancedToggle');
-advancedToggle.addEventListener('click', () => {
- const adv = document.getElementById('advancedSettings');
- if (config.advanced) {
- adv.style.display = "none";
- advancedToggle.innerHTML = config.showAdvancedMessage;
- config.advanced = false;
- } else {
- adv.style.display = "block";
- advancedToggle.innerHTML = config.hideAdvancedMessage;
- config.advanced = true;
- }
-});
-*/
-
-
-/* popup-script.js
-document.querySelector('#login')
-.addEventListener('click', function () {
- chrome.runtime.sendMessage({ message: 'get_auth_token' });
-});
-
-document.querySelector("#log_off").addEventListener("click", function () {
- chrome.runtime.sendMessage({ message: "log_off" });
-});
-*/
diff --git a/Extensions/firefox/return-youtube-dislike.background.js b/Extensions/firefox/return-youtube-dislike.background.js
deleted file mode 100644
index 3beed31..0000000
--- a/Extensions/firefox/return-youtube-dislike.background.js
+++ /dev/null
@@ -1,130 +0,0 @@
-const apiUrl = "https://returnyoutubedislikeapi.com";
-
-browser.runtime.onMessage.addListener((request, sender, sendResponse) => {
- if (request.message === "get_auth_token") {
- // chrome.identity.getAuthToken({ interactive: true }, function (token) {
- // console.log(token);
- // chrome.identity.getProfileUserInfo(function (userInfo) {
- // console.log(JSON.stringify(userInfo));
- // });
- // });
- } else if (request.message === "log_off") {
- // console.log("logging off");
- // chrome.identity.clearAllCachedAuthTokens(() => console.log("logged off"));
- } else if (request.message == "set_state") {
- console.log(request);
- // chrome.identity.getAuthToken({ interactive: true }, function (token) {
- let token = "";
- fetch(`${apiUrl}/votes?videoId=${request.videoId}`, {
- method: "GET",
- headers: {
- Accept: "application/json",
- Authorization: "Bearer " + token,
- },
- })
- .then((response) => response.json())
- .then((response) => {
- console.log(response);
- sendResponse(response);
- })
- .catch();
- //});
- return true;
- } else if (request.message == "send_links") {
- toSend = toSend.concat(request.videoIds.filter((x) => !sentIds.has(x)));
- if (toSend.length >= 20) {
- fetch(`${apiUrl}/votes`, {
- method: "POST",
- headers: {
- "Content-Type": "application/json",
- },
- body: JSON.stringify(toSend),
- });
- for (const toSendUrl of toSend) {
- sentIds.add(toSendUrl);
- }
- toSend = [];
- }
- } else if (request.message == "fetch_from_youtube") {
- let headers = {}
- if (navigator && navigator.userAgent) {
- // Never request mobile version
- headers["User-Agent"] = navigator.userAgent.replace(/\(.*Mobile;/,"(X11; Linux x86_64;");
- }
- fetch(`https://www.youtube.com/watch?v=${request.videoId}`, {
- method: "GET",
- headers: headers
- })
- .then((response) => response.text())
- .then((text) => {
- let result = getDislikesFromYoutubeResponse(text);
- sendResponse(result);
- try {
- sendUserSubmittedStatisticsToApi({
- ...result,
- videoId: request.videoId,
- });
- } catch {}
- });
- return true;
- }
-});
-
-const sentIds = new Set();
-let toSend = [];
-let lastCalled = new Date();
-
-browser.tabs.onUpdated.addListener(async (tabId, changeInfo, tab) => {
- if (changeInfo.status == "complete" && new Date() - lastCalled > 100) {
- lastCalled = new Date();
- console.log("Tab update complete");
-
- if (tab.url && tab.url.indexOf("youtube.") < 0) return;
- browser.tabs.get(tabId, (tab) => {
- browser.tabs.executeScript(tab.id, {
- file: "return-youtube-dislike.script.js",
- });
- });
- }
-});
-
-function getDislikesFromYoutubeResponse(htmlResponse) {
- let start =
- htmlResponse.indexOf('"videoDetails":') + '"videoDetails":'.length;
- let end =
- htmlResponse.indexOf('"isLiveContent":false}', start) +
- '"isLiveContent":false}'.length;
- if (end < start) {
- end =
- htmlResponse.indexOf('"isLiveContent":true}', start) +
- '"isLiveContent":true}'.length;
- }
- let jsonStr = htmlResponse.substring(start, end);
- let jsonResult = JSON.parse(jsonStr);
- let rating = jsonResult.averageRating;
-
- start = htmlResponse.indexOf('"topLevelButtons":[', end);
- start =
- htmlResponse.indexOf('"accessibilityData":', start) +
- '"accessibilityData":'.length;
- end = htmlResponse.indexOf("}", start);
- let likes = +htmlResponse.substring(start, end).replace(/\D/g, "");
- let dislikes = (likes * (5 - rating)) / (rating - 1);
- let result = {
- likes,
- dislikes: Math.round(dislikes),
- rating,
- viewCount: +jsonResult.viewCount,
- };
- return result;
-}
-
-function sendUserSubmittedStatisticsToApi(statistics) {
- fetch(`${apiUrl}/votes/user-submitted`, {
- method: "POST",
- headers: {
- "Content-Type": "application/json",
- },
- body: JSON.stringify(statistics),
- });
-}
diff --git a/Extensions/firefox/return-youtube-dislike.script.js b/Extensions/firefox/return-youtube-dislike.script.js
deleted file mode 100644
index 612a236..0000000
--- a/Extensions/firefox/return-youtube-dislike.script.js
+++ /dev/null
@@ -1,335 +0,0 @@
-var LIKED_STATE = "LIKED_STATE";
-var DISLIKED_STATE = "DISLIKED_STATE";
-var NEUTRAL_STATE = "NEUTRAL_STATE";
-
-if (!storedData) {
- var storedData = {
- likes: 0,
- dislikes: 0,
- previousState: NEUTRAL_STATE,
- };
-}
-
-function cLog(message, writer) {
- message = `[return youtube dislike]: ${message}`;
- if (writer) {
- writer(message);
- } else {
- console.log(message);
- }
-}
-
-function getButtons() {
- let menu_container = document.getElementById("menu-container");
- //--- m.youtube.com: ---//
- if (menu_container === null) {
- return document.querySelector(".slim-video-action-bar-actions");
- //--- If Menu Element Is Displayed: ---//
- } else if (menu_container.offsetParent === null) {
- return document.querySelector("ytd-menu-renderer.ytd-watch-metadata > div");
- //--- If Menu Element Isnt Displayed: ---//
- } else {
- return menu_container.querySelector("#top-level-buttons-computed");
- }
-}
-
-function getLikeButton() {
- return getButtons().children[0];
-}
-
-function getDislikeButton() {
- return getButtons().children[1];
-}
-
-function isVideoLiked() {
- return getLikeButton().classList.contains("style-default-active")
- || getLikeButton().querySelector('[aria-pressed="true"]') !== null;
-}
-
-function isVideoDisliked() {
- return getDislikeButton().classList.contains("style-default-active")
- || getDislikeButton().querySelector('[aria-pressed="true"]') !== null;
-}
-
-function isVideoNotLiked() {
- return getLikeButton().classList.contains("style-text")
- || getLikeButton().querySelector('[aria-pressed="false"]') !== null;
-}
-
-function isVideoNotDisliked() {
- return getDislikeButton().classList.contains("style-text")
- || getDislikeButton().querySelector('[aria-pressed="false"]') !== null;
-}
-
-function checkForUserAvatarButton() {
- if (document.querySelector('#avatar-btn')) {
- return true
- } else {
- return false
- }
-}
-
-function getState() {
- if (isVideoLiked()) {
- return { current: LIKED_STATE, previous: storedData.previousState };
- }
- if (isVideoDisliked()) {
- return { current: DISLIKED_STATE, previous: storedData.previousState };
- }
- return { current: NEUTRAL_STATE, previous: storedData.previousState };
-}
-
-//--- Sets The Likes And Dislikes Values ---//
-function setLikes(likesCount) {
- getLikeButton().querySelector("#text, .button-renderer-text").innerText = likesCount;
-}
-function setDislikes(dislikesCount) {
- getDislikeButton().querySelector("#text, .button-renderer-text").innerText = dislikesCount;
-}
-
-function setState() {
- let statsSet = false;
- browser.runtime.sendMessage(
- {
- message: "fetch_from_youtube",
- videoId: getVideoId(window.location.href),
- },
- function (response) {
- if (response != undefined) {
- cLog("response from youtube:");
- cLog(JSON.stringify(response));
- try {
- if ("likes" in response && "dislikes" in response) {
- const formattedDislike = numberFormat(response.dislikes);
- setDislikes(formattedDislike);
- storedData.dislikes = parseInt(response.dislikes);
- storedData.likes = parseInt(response.likes)
- createRateBar(response.likes, response.dislikes);
- statsSet = true;
- }
- } catch (e) {
- statsSet = false;
- }
- }
- }
- );
-
- browser.runtime.sendMessage(
- {
- message: "set_state",
- videoId: getVideoId(window.location.href),
- state: getState().current,
- },
- function (response) {
- cLog("response from api:");
- cLog(JSON.stringify(response));
- if (response != undefined && !("traceId" in response) && !statsSet) {
- const formattedDislike = numberFormat(response.dislikes);
- storedData.dislikes = response.dislikes;
- // setLikes(response.likes);
- console.log(response);
- setDislikes(formattedDislike);
- createRateBar(response.likes, response.dislikes);
- } else {
- }
- }
- );
-}
-
-function likeClicked() {
- if (checkForUserAvatarButton() == true) {
- if (storedData.previousState == DISLIKED_STATE) {
- storedData.dislikes--;
- storedData.likes++;
- createRateBar(storedData.likes, storedData.dislikes);
- setDislikes(numberFormat(storedData.dislikes));
- storedData.previousState = LIKED_STATE;
- } else if (storedData.previousState == NEUTRAL_STATE) {
- storedData.likes++;
- createRateBar(storedData.likes, storedData.dislikes);
- storedData.previousState = LIKED_STATE;
- } else if (storedData.previousState == LIKED_STATE) {
- storedData.likes--;
- createRateBar(storedData.likes, storedData.dislikes)
- storedData.previousState = NEUTRAL_STATE;
- }
- }
-}
-
-function dislikeClicked() {
- if (checkForUserAvatarButton() == true) {
- if (storedData.previousState == NEUTRAL_STATE) {
- storedData.dislikes++;
- setDislikes(numberFormat(storedData.dislikes));
- createRateBar(storedData.likes, storedData.dislikes);
- storedData.previousState = DISLIKED_STATE;
- } else if (storedData.previousState == DISLIKED_STATE) {
- storedData.dislikes--;
- setDislikes(numberFormat(storedData.dislikes));
- createRateBar(storedData.likes, storedData.dislikes);
- storedData.previousState = NEUTRAL_STATE;
- } else if (storedData.previousState == LIKED_STATE) {
- storedData.likes--;
- storedData.dislikes++;
- setDislikes(numberFormat(storedData.dislikes));
- createRateBar(storedData.likes, storedData.dislikes);
- storedData.previousState = DISLIKED_STATE;
- }
- }
-}
-
-function setInitialState() {
- setState();
- // setTimeout(() => sendVideoIds(), 1500);
-}
-
-function getVideoId(url) {
- const urlObject = new URL(url);
- const pathname = urlObject.pathname;
- if (pathname.startsWith("/clip")) {
- return document.querySelector("meta[itemprop='videoId']").content;
- } else {
- return urlObject.searchParams.get("v");
- }
-}
-
-function isVideoLoaded() {
- const videoId = getVideoId(window.location.href);
- return (
- document.querySelector(`ytd-watch-flexy[video-id='${videoId}']`) !== null ||
- // mobile: no video-id attribute
- document.querySelector('#player[loading="false"]:not([hidden])') !== null
- );
-}
-
-function roundDown(num) {
- if (num < 1000) return num;
- const int = Math.floor(Math.log10(num) - 2);
- const decimal = int + (int % 3 ? 1 : 0);
- const value = Math.floor(num / 10 ** decimal);
- return value * 10 ** decimal;
-}
-
-function numberFormat(numberState) {
- const userLocales = new URL(
- Array.from(document.querySelectorAll("head > link[rel='search']"))
- ?.find((n) => n?.getAttribute("href")?.includes("?locale="))
- ?.getAttribute("href")
- )?.searchParams?.get("locale");
- const formatter = Intl.NumberFormat(document.documentElement.lang || userLocales || navigator.language, {
- notation: "compact",
- });
-
- return formatter.format(roundDown(numberState));
-}
-
-function setEventListeners(evt) {
- let jsInitChecktimer;
- function checkForJS_Finish() {
- if (getButtons()?.offsetParent && isVideoLoaded()) {
- clearInterval(jsInitChecktimer);
- const buttons = getButtons();
- if (!window.returnDislikeButtonlistenersSet) {
- getLikeButton().addEventListener("click", likeClicked);
- getDislikeButton().addEventListener("click", dislikeClicked);
- let lastKnownScrollPosition = 0;
- let ticking = false;
- // document.addEventListener('scroll', function(e) {
- // lastKnownScrollPosition = window.scrollY;
- //
- // if (!ticking) {
- // window.requestAnimationFrame(function() {
- // // sendVideoIds();
- // ticking = false;
- // });
- //
- // ticking = true;
- // }
- // });
- window.returnDislikeButtonlistenersSet = true;
- }
- setInitialState();
- }
- }
-
- if (window.location.href.indexOf("watch?") >= 0) {
- jsInitChecktimer = setInterval(checkForJS_Finish, 111);
- }
-}
-
-function createRateBar(likes, dislikes) {
- let rateBar = document.getElementById("return-youtube-dislike-bar-container");
-
- const widthPx =
- getLikeButton().clientWidth +
- getDislikeButton().clientWidth +
- 8;
-
- const widthPercent =
- likes + dislikes > 0 ? (likes / (likes + dislikes)) * 100 : 50;
-
- if (!rateBar) {
- (
- document.getElementById("actions-inner") ||
- document.getElementById("menu-container") ||
- document.querySelector("ytm-slim-video-action-bar-renderer")
- ).insertAdjacentHTML(
- "beforeend",
- `
-