From 03da33736dc512b10327f31efd55947a8c328e5f Mon Sep 17 00:00:00 2001 From: thesusian Date: Fri, 7 Jan 2022 12:58:19 +0300 Subject: removed dist folder --- .../combined/dist/chrome/bundled-content-script.js | 421 --------------------- Extensions/combined/dist/chrome/content-style.css | 26 -- Extensions/combined/dist/chrome/icons/icon128.png | Bin 7093 -> 0 bytes Extensions/combined/dist/chrome/icons/icon48.png | Bin 4454 -> 0 bytes .../combined/dist/chrome/icons/icon_hold128.png | Bin 1931 -> 0 bytes Extensions/combined/dist/chrome/icons/server.svg | 1 - Extensions/combined/dist/chrome/manifest.json | 41 -- Extensions/combined/dist/chrome/popup.css | 127 ------- Extensions/combined/dist/chrome/popup.html | 61 --- Extensions/combined/dist/chrome/popup.js | 126 ------ Extensions/combined/dist/chrome/ryd.background.js | 272 ------------- .../dist/firefox/bundled-content-script.js | 421 --------------------- Extensions/combined/dist/firefox/content-style.css | 26 -- Extensions/combined/dist/firefox/icons/icon128.png | Bin 7093 -> 0 bytes Extensions/combined/dist/firefox/icons/icon48.png | Bin 4454 -> 0 bytes .../combined/dist/firefox/icons/icon_hold128.png | Bin 1931 -> 0 bytes Extensions/combined/dist/firefox/icons/server.svg | 1 - Extensions/combined/dist/firefox/manifest.json | 26 -- Extensions/combined/dist/firefox/popup.css | 127 ------- Extensions/combined/dist/firefox/popup.html | 61 --- Extensions/combined/dist/firefox/popup.js | 126 ------ Extensions/combined/dist/firefox/ryd.background.js | 272 ------------- 22 files changed, 2135 deletions(-) delete mode 100644 Extensions/combined/dist/chrome/bundled-content-script.js delete mode 100644 Extensions/combined/dist/chrome/content-style.css delete mode 100644 Extensions/combined/dist/chrome/icons/icon128.png delete mode 100644 Extensions/combined/dist/chrome/icons/icon48.png delete mode 100644 Extensions/combined/dist/chrome/icons/icon_hold128.png delete mode 100644 Extensions/combined/dist/chrome/icons/server.svg delete mode 100644 Extensions/combined/dist/chrome/manifest.json delete mode 100644 Extensions/combined/dist/chrome/popup.css delete mode 100644 Extensions/combined/dist/chrome/popup.html delete mode 100644 Extensions/combined/dist/chrome/popup.js delete mode 100644 Extensions/combined/dist/chrome/ryd.background.js delete mode 100644 Extensions/combined/dist/firefox/bundled-content-script.js delete mode 100644 Extensions/combined/dist/firefox/content-style.css delete mode 100644 Extensions/combined/dist/firefox/icons/icon128.png delete mode 100644 Extensions/combined/dist/firefox/icons/icon48.png delete mode 100644 Extensions/combined/dist/firefox/icons/icon_hold128.png delete mode 100644 Extensions/combined/dist/firefox/icons/server.svg delete mode 100644 Extensions/combined/dist/firefox/manifest.json delete mode 100644 Extensions/combined/dist/firefox/popup.css delete mode 100644 Extensions/combined/dist/firefox/popup.html delete mode 100644 Extensions/combined/dist/firefox/popup.js delete mode 100644 Extensions/combined/dist/firefox/ryd.background.js diff --git a/Extensions/combined/dist/chrome/bundled-content-script.js b/Extensions/combined/dist/chrome/bundled-content-script.js deleted file mode 100644 index df6cf9b..0000000 --- a/Extensions/combined/dist/chrome/bundled-content-script.js +++ /dev/null @@ -1,421 +0,0 @@ -/******/ (() => { // webpackBootstrap -/******/ "use strict"; -var __webpack_exports__ = {}; - -;// CONCATENATED MODULE: ./Extensions/combined/src/utils.js -function roundDown(num) { - if (num < 1000) return num; - - var _int = Math.floor(Math.log10(num) - 2); - - var decimal = _int + (_int % 3 ? 1 : 0); - var value = Math.floor(num / Math.pow(10, decimal)); - return value * Math.pow(10, decimal); -} - -function numberFormat(numberState) { - var userLocales; - - try { - var _URL, _URL$searchParams, _Array$from, _Array$from$find; - - userLocales = (_URL = new URL((_Array$from = Array.from(document.querySelectorAll("head > link[rel='search']"))) === null || _Array$from === void 0 ? void 0 : (_Array$from$find = _Array$from.find(function (n) { - var _n$getAttribute; - - return n === null || n === void 0 ? void 0 : (_n$getAttribute = n.getAttribute("href")) === null || _n$getAttribute === void 0 ? void 0 : _n$getAttribute.includes("?locale="); - })) === null || _Array$from$find === void 0 ? void 0 : _Array$from$find.getAttribute("href"))) === null || _URL === void 0 ? void 0 : (_URL$searchParams = _URL.searchParams) === null || _URL$searchParams === void 0 ? void 0 : _URL$searchParams.get("locale"); - } catch (_unused) {} - - var formatter = Intl.NumberFormat(document.documentElement.lang || userLocales || navigator.language, { - notation: "compact" - }); - return formatter.format(roundDown(numberState)); -} - -function getBrowser() { - if (typeof chrome !== "undefined" && typeof chrome.runtime !== "undefined") { - return chrome; - } else if (typeof browser !== "undefined" && typeof browser.runtime !== "undefined") { - return browser; - } else { - console.log("browser is not supported"); - return false; - } -} - -function getVideoId(url) { - var urlObject = new URL(url); - var pathname = urlObject.pathname; - - if (pathname.startsWith("/clip")) { - return document.querySelector("meta[itemprop='videoId']").content; - } else { - return urlObject.searchParams.get("v"); - } -} - -function isVideoLoaded() { - var videoId = getVideoId(window.location.href); - return document.querySelector("ytd-watch-flexy[video-id='".concat(videoId, "']")) !== null || // mobile: no video-id attribute - document.querySelector('#player[loading="false"]:not([hidden])') !== null; -} - -function cLog(message, writer) { - message = "[return youtube dislike]: ".concat(message); - - if (writer) { - writer(message); - } else { - console.log(message); - } -} - - -;// CONCATENATED MODULE: ./Extensions/combined/src/bar.js - - - - -function createRateBar(likes, dislikes) { - if (!likesDisabledState) { - var rateBar = document.getElementById("ryd-bar-container"); - var widthPx = buttons_getButtons().children[0].clientWidth + buttons_getButtons().children[1].clientWidth + 8; - var widthPercent = likes + dislikes > 0 ? likes / (likes + dislikes) * 100 : 50; - - if (!rateBar) { - (document.getElementById("menu-container") || document.querySelector("ytm-slim-video-action-bar-renderer")).insertAdjacentHTML("beforeend", "\n
\n
\n \n
\n
\n \n \n ").concat(likes.toLocaleString(), " / ").concat(dislikes.toLocaleString(), "\n \n \n ")); - } else { - document.getElementById("ryd-bar-container").style.width = widthPx + "px"; - document.getElementById("ryd-bar").style.width = widthPercent + "%"; - document.querySelector("#ryd-dislike-tooltip > #tooltip").innerHTML = "".concat(likes.toLocaleString(), " / ").concat(dislikes.toLocaleString()); - } - } else { - cLog('removing bar'); - var ratebar = document.getElementById("ryd-bar-container"); - ratebar.parentNode.removeChild(ratebar); - } -} - - -;// CONCATENATED MODULE: ./Extensions/combined/src/events.js - - - - - -function sendVote(vote) { - if (extConfig.disableVoteSubmission !== true) { - getBrowser().runtime.sendMessage({ - message: "send_vote", - vote: vote, - videoId: getVideoId(window.location.href) - }); - } -} - -function sendVideoIds() { - var links = Array.from(document.getElementsByClassName("yt-simple-endpoint ytd-compact-video-renderer")).concat(Array.from(document.getElementsByClassName("yt-simple-endpoint ytd-thumbnail"))); // Also try mobile - - if (links.length < 1) links = Array.from(document.querySelectorAll(".large-media-item-metadata > a, a.large-media-item-thumbnail-container")); - var ids = links.filter(function (x) { - return x.href && x.href.indexOf("/watch?v=") > 0; - }).map(function (x) { - return getVideoId(x.href); - }); - getBrowser().runtime.sendMessage({ - message: "send_links", - videoIds: ids - }); -} - -function likeClicked() { - if (checkForSignInButton() === false) { - if (storedData.previousState === DISLIKED_STATE) { - sendVote(1); - storedData.dislikes--; - storedData.likes++; - createRateBar(storedData.likes, storedData.dislikes); - setDislikes(numberFormat(storedData.dislikes)); - storedData.previousState = LIKED_STATE; - } else if (storedData.previousState === NEUTRAL_STATE) { - sendVote(1); - storedData.likes++; - createRateBar(storedData.likes, storedData.dislikes); - storedData.previousState = LIKED_STATE; - } else if (storedData.previousState = LIKED_STATE) { - sendVote(0); - storedData.likes--; - createRateBar(storedData.likes, storedData.dislikes); - storedData.previousState = NEUTRAL_STATE; - } - } -} - -function dislikeClicked() { - if (checkForSignInButton() == false) { - if (storedData.previousState === NEUTRAL_STATE) { - sendVote(-1); - storedData.dislikes++; - setDislikes(numberFormat(storedData.dislikes)); - createRateBar(storedData.likes, storedData.dislikes); - storedData.previousState = DISLIKED_STATE; - } else if (storedData.previousState === DISLIKED_STATE) { - sendVote(0); - storedData.dislikes--; - setDislikes(numberFormat(storedData.dislikes)); - createRateBar(storedData.likes, storedData.dislikes); - storedData.previousState = NEUTRAL_STATE; - } else if (storedData.previousState === LIKED_STATE) { - sendVote(-1); - storedData.likes--; - storedData.dislikes++; - setDislikes(numberFormat(storedData.dislikes)); - createRateBar(storedData.likes, storedData.dislikes); - storedData.previousState = DISLIKED_STATE; - } - } -} - -function addLikeDislikeEventListener() { - var buttons = buttons_getButtons(); - - if (!window.returnDislikeButtonlistenersSet) { - buttons.children[0].addEventListener("click", likeClicked); - buttons.children[1].addEventListener("click", dislikeClicked); - window.returnDislikeButtonlistenersSet = true; - } -} - -function storageChangeHandler(changes, area) { - if (changes.disableVoteSubmission !== undefined) { - handleDisableVoteSubmissionChangeEvent(changes.disableVoteSubmission.newValue); - } -} - -function handleDisableVoteSubmissionChangeEvent(value) { - extConfig.disableVoteSubmission = value; -} - - -;// CONCATENATED MODULE: ./Extensions/combined/src/state.js - - - - -var LIKED_STATE = "LIKED_STATE"; -var DISLIKED_STATE = "DISLIKED_STATE"; -var NEUTRAL_STATE = "NEUTRAL_STATE"; -var DISLIKES_DISABLED_TEXT = "DISLIKES DISABLED"; -var extConfig = { - disableVoteSubmission: false -}; -var storedData = { - likes: 0, - dislikes: 0, - previousState: NEUTRAL_STATE -}; -var likesDisabledState = true; - -function isMobile() { - return location.hostname == "m.youtube.com"; -} - -function isVideoLiked() { - if (isMobile()) { - return getLikeButton().querySelector("button").getAttribute("aria-label") == "true"; - } - - return getLikeButton().classList.contains("style-default-active"); -} - -function isVideoDisliked() { - if (isMobile()) { - return getDislikeButton().querySelector("button").getAttribute("aria-label") == "true"; - } - - return getDislikeButton().classList.contains("style-default-active"); -} - -function getState(storedData) { - 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) { - if (!likesDisabledState) { - if (isMobile()) { - buttons_getButtons().children[1].querySelector(".button-renderer-text").innerText = dislikesCount; - return; - } - - buttons_getButtons().children[1].querySelector("#text").innerText = dislikesCount; - } else { - cLog("likes count diabled by creator"); - - if (isMobile()) { - buttons_getButtons().children[1].querySelector(".button-renderer-text").innerText = DISLIKES_DISABLED_TEXT; - return; - } - - buttons_getButtons().children[1].querySelector("#text").innerText = DISLIKES_DISABLED_TEXT; - } -} - -function getLikeCountFromButton() { - var likesStr = getLikeButton().querySelector("button").getAttribute("aria-label").replace(/\D/g, ""); - return likesStr.length > 0 ? parseInt(likesStr) : false; -} - -function processResponse(response, storedData) { - var formattedDislike = numberFormat(response.dislikes); - setDislikes(formattedDislike); - storedData.dislikes = parseInt(response.dislikes); - storedData.likes = getLikeCountFromButton() || parseInt(response.likes); - - if (!likesDisabledState) { - createRateBar(storedData.likes, storedData.dislikes); - } -} - -function setState(storedData) { - storedData.previousState = isVideoDisliked() ? DISLIKED_STATE : isVideoLiked() ? LIKED_STATE : NEUTRAL_STATE; - var statsSet = false; - getBrowser().runtime.sendMessage({ - message: "set_state", - videoId: getVideoId(window.location.href), - state: getState(storedData).current, - likeCount: getLikeCountFromButton() || null - }, function (response) { - 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); - } - }); -} - -function setInitialState() { - setState(storedData); - setTimeout(function () { - sendVideoIds(); - }, 1500); -} - -function initExtConfig() { - initializeDisableVoteSubmission(); -} - -function initializeDisableVoteSubmission() { - getBrowser().storage.sync.get(['disableVoteSubmission'], function (res) { - if (res.disableVoteSubmission === undefined) { - getBrowser().storage.sync.set({ - disableVoteSubmission: false - }); - } else { - extConfig.disableVoteSubmission = res.disableVoteSubmission; - } - }); -} - - -;// CONCATENATED MODULE: ./Extensions/combined/src/buttons.js - - -function buttons_getButtons() { - var _document$getElementB; - - if (isMobile()) { - return document.querySelector(".slim-video-action-bar-actions"); - } //--- If Menu Element Is Displayed: ---// - - - if (((_document$getElementB = document.getElementById("menu-container")) === null || _document$getElementB === void 0 ? void 0 : _document$getElementB.offsetParent) === null) { - return document.querySelector("ytd-menu-renderer.ytd-watch-metadata > div"); //--- If Menu Element Isnt Displayed: ---// - } else { - var _document$getElementB2; - - return (_document$getElementB2 = document.getElementById("menu-container")) === null || _document$getElementB2 === void 0 ? void 0 : _document$getElementB2.querySelector("#top-level-buttons-computed"); - } -} - -function getLikeButton() { - return buttons_getButtons().children[0]; -} - -function getDislikeButton() { - return buttons_getButtons().children[1]; -} - -function checkForSignInButton() { - if (document.querySelector("a[href^='https://accounts.google.com/ServiceLogin']")) { - return true; - } else { - return false; - } -} - - -;// CONCATENATED MODULE: ./Extensions/combined/ryd.content-script.js -//--- Import Button Functions ---// - //--- Import State Functions ---// - - //--- Import Video & Browser Functions ---// - - - - -initExtConfig(); -var jsInitChecktimer = null; - -function setEventListeners(evt) { - function checkForJS_Finish() { - var _getButtons; - - if ((_getButtons = buttons_getButtons()) !== null && _getButtons !== void 0 && _getButtons.offsetParent && isVideoLoaded()) { - clearInterval(jsInitChecktimer); - jsInitChecktimer = null; - addLikeDislikeEventListener(); - setInitialState(); - getBrowser().storage.onChanged.addListener(storageChangeHandler); - } - } - - if (window.location.href.indexOf("watch?") >= 0) { - jsInitChecktimer = setInterval(checkForJS_Finish, 111); - } -} - -setEventListeners(); -document.addEventListener("yt-navigate-finish", function (event) { - if (jsInitChecktimer !== null) clearInterval(jsInitChecktimer); - window.returnDislikeButtonlistenersSet = false; - setEventListeners(); -}); -setTimeout(function () { - return sendVideoIds(); -}, 2500); -/******/ })() -; \ No newline at end of file diff --git a/Extensions/combined/dist/chrome/content-style.css b/Extensions/combined/dist/chrome/content-style.css deleted file mode 100644 index c06b29c..0000000 --- a/Extensions/combined/dist/chrome/content-style.css +++ /dev/null @@ -1,26 +0,0 @@ -#ryd-bar-container { - background: var(--yt-spec-icon-disabled); - border-radius: 2px; -} - -#ryd-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/combined/dist/chrome/icons/icon128.png b/Extensions/combined/dist/chrome/icons/icon128.png deleted file mode 100644 index 23b4958..0000000 Binary files a/Extensions/combined/dist/chrome/icons/icon128.png and /dev/null differ diff --git a/Extensions/combined/dist/chrome/icons/icon48.png b/Extensions/combined/dist/chrome/icons/icon48.png deleted file mode 100644 index f2a5951..0000000 Binary files a/Extensions/combined/dist/chrome/icons/icon48.png and /dev/null differ diff --git a/Extensions/combined/dist/chrome/icons/icon_hold128.png b/Extensions/combined/dist/chrome/icons/icon_hold128.png deleted file mode 100644 index 359a686..0000000 Binary files a/Extensions/combined/dist/chrome/icons/icon_hold128.png and /dev/null differ diff --git a/Extensions/combined/dist/chrome/icons/server.svg b/Extensions/combined/dist/chrome/icons/server.svg deleted file mode 100644 index 869a391..0000000 --- a/Extensions/combined/dist/chrome/icons/server.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/Extensions/combined/dist/chrome/manifest.json b/Extensions/combined/dist/chrome/manifest.json deleted file mode 100644 index bc00d83..0000000 --- a/Extensions/combined/dist/chrome/manifest.json +++ /dev/null @@ -1,41 +0,0 @@ -{ - "name": "Return YouTube Dislike", - "description": "Returns ability to see dislikes", - "version": "2.0.0.3", - "manifest_version": 3, - "background": { - "service_worker": "ryd.background.js" - }, - "icons": { - "48": "icons/icon48.png", - "128": "icons/icon128.png" - }, - "host_permissions": ["*://*.youtube.com/*"], - "permissions": [ - "storage" - ], - "action": { - "default_popup": "popup.html" - }, - "content_scripts": [ - { - "matches": [ - "*://youtube.com/*", - "*://www.youtube.com/*", - "*://m.youtube.com/*" - ], - "exclude_matches": ["*://*.music.youtube.com/*"], - "js": ["bundled-content-script.js"], - "css": ["content-style.css"] - } - ], - "externally_connectable": { - "matches": ["*://*.youtube.com/*"] - }, - "web_accessible_resources": [ - { - "resources": ["ryd.script.js"], - "matches": ["*://*.youtube.com/*"] - } - ] -} diff --git a/Extensions/combined/dist/chrome/popup.css b/Extensions/combined/dist/chrome/popup.css deleted file mode 100644 index 757692d..0000000 --- a/Extensions/combined/dist/chrome/popup.css +++ /dev/null @@ -1,127 +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: 0.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; -} - -#server-status { - height: 72px; - width: 90px; - /* filter: invert(21%) sepia(100%) saturate(3618%) hue-rotate(102deg) - brightness(96%) contrast(108%); */ -} diff --git a/Extensions/combined/dist/chrome/popup.html b/Extensions/combined/dist/chrome/popup.html deleted file mode 100644 index 130f557..0000000 --- a/Extensions/combined/dist/chrome/popup.html +++ /dev/null @@ -1,61 +0,0 @@ - - - - - Return YouTube Dislike - - - - - - -
- - - - -

Return YouTube Dislike

- -

API Status:

-

by Dmitrii Selivanov & Community

-

- - - - - -

- - -
- -
- -
-
- -
- Settings - - -
- - -
- - - diff --git a/Extensions/combined/dist/chrome/popup.js b/Extensions/combined/dist/chrome/popup.js deleted file mode 100644 index 291f555..0000000 --- a/Extensions/combined/dist/chrome/popup.js +++ /dev/null @@ -1,126 +0,0 @@ -/* Config */ -const config = { - advanced: false, - showAdvancedMessage: "Show Settings", - hideAdvancedMessage: "Hide Settings", - disableVoteSubmission: false, -} - - function initConfig() { - initializeVersionNumber(); - } - - function initializeVersionNumber() { - const version = chrome.runtime.getManifest().version; - document.getElementById('ext-version').innerHTML = 'v' + version; -} - - links: { - website: "https://returnyoutubedislike.com", - github: "https://github.com/Anarios/return-youtube-dislike", - discord: "https://discord.gg/mYnESY4Md5", - donate: "https://returnyoutubedislike.com/donate", - faq: "https://returnyoutubedislike.com/faq", - }, -}; - -/* 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_faq").addEventListener("click", () => { - chrome.tabs.create({ url: config.links.faq }); -}); - -document.getElementById("link_donate").addEventListener("click", () => { - chrome.tabs.create({ url: config.links.donate }); -}); - -document - .getElementById("disable_vote_submission") - .addEventListener("click", (ev) => { - chrome.storage.sync.set({ disableVoteSubmission: ev.target.checked }); - }); - -/* Advanced Toggle */ -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; - } -}); - -initConfig(); - -function initConfig() { - initializeDisableVoteSubmission(); -} - -function initializeDisableVoteSubmission() { - chrome.storage.sync.get(["disableVoteSubmission"], (res) => { - handleDisableVoteSubmissionChangeEvent(res.disableVoteSubmission); - }); -} - -chrome.storage.onChanged.addListener(storageChangeHandler); - -function storageChangeHandler(changes, area) { - if (changes.disableVoteSubmission !== undefined) { - handleDisableVoteSubmissionChangeEvent( - changes.disableVoteSubmission.newValue - ); - } -} - -function handleDisableVoteSubmissionChangeEvent(value) { - config.disableVoteSubmission = value; - document.getElementById("disable_vote_submission").checked = value; -} - -(async function getStatus() { - let status = document.getElementById("status"); - let serverStatus = document.getElementById("server-status"); - let resp = await fetch( - "https://returnyoutubedislikeapi.com/votes?videoId=YbJOTdZBX1g" - ); - let result = await resp.status; - if (result === 200) { - status.innerText = "Online"; - status.style.color = "green"; - serverStatus.style.filter = - "invert(58%) sepia(81%) saturate(2618%) hue-rotate(81deg) brightness(119%) contrast(129%)"; - } else { - status.innerText = "Offline"; - status.style.color = "red"; - serverStatus.style.filter = - "invert(11%) sepia(100%) saturate(6449%) hue-rotate(3deg) brightness(116%) contrast(115%)"; - } -})(); - -/* 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/combined/dist/chrome/ryd.background.js b/Extensions/combined/dist/chrome/ryd.background.js deleted file mode 100644 index e332d8d..0000000 --- a/Extensions/combined/dist/chrome/ryd.background.js +++ /dev/null @@ -1,272 +0,0 @@ -const apiUrl = "https://returnyoutubedislikeapi.com"; -const voteDisabledIconName = 'icon_hold128.png'; -const defaultIconName = 'icon128.png'; -let api; - -/** stores extension's global config */ -let extConfig = { - disableVoteSubmission: false -} - -if (isChrome()) api = chrome; -else if (isFirefox()) api = browser; - -initExtConfig() - -api.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") { - // 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}&likeCount=${request.likeCount || ''}`, { - method: "GET", - headers: { - Accept: "application/json", - }, - }) - .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 == "register") { - register(); - return true; - } else if (request.message == "send_vote") { - sendVote(request.videoId, request.vote); - return true; - } -}); - -async function sendVote(videoId, vote) { - api.storage.sync.get(null, async (storageResult) => { - if (!storageResult.userId || !storageResult.registrationConfirmed) { - await register(); - return; - } - fetch(`${apiUrl}/interact/vote`, { - method: "POST", - headers: { - "Content-Type": "application/json", - }, - body: JSON.stringify({ - userId: storageResult.userId, - videoId, - value: vote, - }), - }) - .then(async (response) => { - if (response.status == 401) { - await register(); - await sendVote(videoId, vote); - return; - } - return response.json() - }) - .then((response) => { - solvePuzzle(response).then((solvedPuzzle) => { - fetch(`${apiUrl}/interact/confirmVote`, { - method: "POST", - headers: { - "Content-Type": "application/json", - }, - body: JSON.stringify({ - ...solvedPuzzle, - userId: storageResult.userId, - videoId, - }), - }); - }); - }); - }); -} - -function register() { - let userId = generateUserID(); - api.storage.sync.set({ userId }); - return fetch(`${apiUrl}/puzzle/registration?userId=${userId}`, { - method: "GET", - headers: { - Accept: "application/json", - }, - }) - .then((response) => response.json()) - .then((response) => { - return solvePuzzle(response).then((solvedPuzzle) => { - return fetch(`${apiUrl}/puzzle/registration?userId=${userId}`, { - method: "POST", - headers: { - "Content-Type": "application/json", - }, - body: JSON.stringify(solvedPuzzle), - }).then((response) => - response.json().then((result) => { - if (result === true) { - return api.storage.sync.set({ registrationConfirmed: true }); - } - }) - ); - }); - }) - .catch(); -} - -api.storage.sync.get(null, (res) => { - if (!res || !res.userId || !res.registrationConfirmed) { - register(); - } -}); - -const sentIds = new Set(); -let toSend = []; - -function sendUserSubmittedStatisticsToApi(statistics) { - fetch(`${apiUrl}/votes/user-submitted`, { - method: "POST", - headers: { - "Content-Type": "application/json", - }, - body: JSON.stringify(statistics), - }); -} - -function countLeadingZeroes(uInt8View, limit) { - let zeroes = 0; - let value = 0; - for (let i = 0; i < uInt8View.length; i++) { - value = uInt8View[i]; - if (value === 0) { - zeroes += 8; - } else { - let count = 1; - if (value >>> 4 === 0) { - count += 4; - value <<= 4; - } - if (value >>> 6 === 0) { - count += 2; - value <<= 2; - } - zeroes += count - (value >>> 7); - break; - } - if (zeroes >= limit) { - break; - } - } - return zeroes; -} - -async function solvePuzzle(puzzle) { - let challenge = Uint8Array.from(atob(puzzle.challenge), (c) => - c.charCodeAt(0) - ); - let buffer = new ArrayBuffer(20); - let uInt8View = new Uint8Array(buffer); - let uInt32View = new Uint32Array(buffer); - let maxCount = Math.pow(2, puzzle.difficulty) * 5; - for (let i = 4; i < 20; i++) { - uInt8View[i] = challenge[i - 4]; - } - - for (let i = 0; i < maxCount; i++) { - uInt32View[0] = i; - let hash = await crypto.subtle.digest("SHA-512", buffer); - let hashUint8 = new Uint8Array(hash); - if (countLeadingZeroes(hashUint8) >= puzzle.difficulty) { - return { - solution: btoa(String.fromCharCode.apply(null, uInt8View.slice(0, 4))), - }; - } - } -} - -function generateUserID(length = 36) { - const charset = - "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"; - let result = ""; - if (crypto && crypto.getRandomValues) { - const values = new Uint32Array(length); - crypto.getRandomValues(values); - for (let i = 0; i < length; i++) { - result += charset[values[i] % charset.length]; - } - return result; - } else { - for (let i = 0; i < length; i++) { - result += charset[Math.floor(Math.random() * charset.length)]; - } - return result; - } -} - -function storageChangeHandler(changes, area) { - if (changes.disableVoteSubmission !== undefined) { - handleDisableVoteSubmissionChangeEvent(changes.disableVoteSubmission.newValue); - } -} - -function handleDisableVoteSubmissionChangeEvent(value) { - extConfig.disableVoteSubmission = value; - if (value === true) { - changeIcon(voteDisabledIconName); - } else { - changeIcon(defaultIconName); - } -} - -function changeIcon(iconName) { - if (api.action !== undefined) api.action.setIcon({path: "/icons/" + iconName}); - else if (api.browserAction !== undefined) api.browserAction.setIcon({path: "/icons/" + iconName}); - else console.log('changing icon is not supported'); -} - -api.storage.onChanged.addListener(storageChangeHandler); - -function initExtConfig() { - initializeDisableVoteSubmission(); -} - -function initializeDisableVoteSubmission() { - api.storage.sync.get(['disableVoteSubmission'], (res) => { - if (res.disableVoteSubmission === undefined) { - api.storage.sync.set({disableVoteSubmission: false}); - } - else { - extConfig.disableVoteSubmission = res.disableVoteSubmission; - if (res.disableVoteSubmission) changeIcon(voteDisabledIconName); - } - }); -} - -function isChrome() { - return typeof chrome !== "undefined" && typeof chrome.runtime !== "undefined"; -} - -function isFirefox() { - return typeof browser !== "undefined" && typeof browser.runtime !== "undefined"; -} \ No newline at end of file diff --git a/Extensions/combined/dist/firefox/bundled-content-script.js b/Extensions/combined/dist/firefox/bundled-content-script.js deleted file mode 100644 index df6cf9b..0000000 --- a/Extensions/combined/dist/firefox/bundled-content-script.js +++ /dev/null @@ -1,421 +0,0 @@ -/******/ (() => { // webpackBootstrap -/******/ "use strict"; -var __webpack_exports__ = {}; - -;// CONCATENATED MODULE: ./Extensions/combined/src/utils.js -function roundDown(num) { - if (num < 1000) return num; - - var _int = Math.floor(Math.log10(num) - 2); - - var decimal = _int + (_int % 3 ? 1 : 0); - var value = Math.floor(num / Math.pow(10, decimal)); - return value * Math.pow(10, decimal); -} - -function numberFormat(numberState) { - var userLocales; - - try { - var _URL, _URL$searchParams, _Array$from, _Array$from$find; - - userLocales = (_URL = new URL((_Array$from = Array.from(document.querySelectorAll("head > link[rel='search']"))) === null || _Array$from === void 0 ? void 0 : (_Array$from$find = _Array$from.find(function (n) { - var _n$getAttribute; - - return n === null || n === void 0 ? void 0 : (_n$getAttribute = n.getAttribute("href")) === null || _n$getAttribute === void 0 ? void 0 : _n$getAttribute.includes("?locale="); - })) === null || _Array$from$find === void 0 ? void 0 : _Array$from$find.getAttribute("href"))) === null || _URL === void 0 ? void 0 : (_URL$searchParams = _URL.searchParams) === null || _URL$searchParams === void 0 ? void 0 : _URL$searchParams.get("locale"); - } catch (_unused) {} - - var formatter = Intl.NumberFormat(document.documentElement.lang || userLocales || navigator.language, { - notation: "compact" - }); - return formatter.format(roundDown(numberState)); -} - -function getBrowser() { - if (typeof chrome !== "undefined" && typeof chrome.runtime !== "undefined") { - return chrome; - } else if (typeof browser !== "undefined" && typeof browser.runtime !== "undefined") { - return browser; - } else { - console.log("browser is not supported"); - return false; - } -} - -function getVideoId(url) { - var urlObject = new URL(url); - var pathname = urlObject.pathname; - - if (pathname.startsWith("/clip")) { - return document.querySelector("meta[itemprop='videoId']").content; - } else { - return urlObject.searchParams.get("v"); - } -} - -function isVideoLoaded() { - var videoId = getVideoId(window.location.href); - return document.querySelector("ytd-watch-flexy[video-id='".concat(videoId, "']")) !== null || // mobile: no video-id attribute - document.querySelector('#player[loading="false"]:not([hidden])') !== null; -} - -function cLog(message, writer) { - message = "[return youtube dislike]: ".concat(message); - - if (writer) { - writer(message); - } else { - console.log(message); - } -} - - -;// CONCATENATED MODULE: ./Extensions/combined/src/bar.js - - - - -function createRateBar(likes, dislikes) { - if (!likesDisabledState) { - var rateBar = document.getElementById("ryd-bar-container"); - var widthPx = buttons_getButtons().children[0].clientWidth + buttons_getButtons().children[1].clientWidth + 8; - var widthPercent = likes + dislikes > 0 ? likes / (likes + dislikes) * 100 : 50; - - if (!rateBar) { - (document.getElementById("menu-container") || document.querySelector("ytm-slim-video-action-bar-renderer")).insertAdjacentHTML("beforeend", "\n
\n
\n \n
\n
\n \n \n ").concat(likes.toLocaleString(), " / ").concat(dislikes.toLocaleString(), "\n \n \n ")); - } else { - document.getElementById("ryd-bar-container").style.width = widthPx + "px"; - document.getElementById("ryd-bar").style.width = widthPercent + "%"; - document.querySelector("#ryd-dislike-tooltip > #tooltip").innerHTML = "".concat(likes.toLocaleString(), " / ").concat(dislikes.toLocaleString()); - } - } else { - cLog('removing bar'); - var ratebar = document.getElementById("ryd-bar-container"); - ratebar.parentNode.removeChild(ratebar); - } -} - - -;// CONCATENATED MODULE: ./Extensions/combined/src/events.js - - - - - -function sendVote(vote) { - if (extConfig.disableVoteSubmission !== true) { - getBrowser().runtime.sendMessage({ - message: "send_vote", - vote: vote, - videoId: getVideoId(window.location.href) - }); - } -} - -function sendVideoIds() { - var links = Array.from(document.getElementsByClassName("yt-simple-endpoint ytd-compact-video-renderer")).concat(Array.from(document.getElementsByClassName("yt-simple-endpoint ytd-thumbnail"))); // Also try mobile - - if (links.length < 1) links = Array.from(document.querySelectorAll(".large-media-item-metadata > a, a.large-media-item-thumbnail-container")); - var ids = links.filter(function (x) { - return x.href && x.href.indexOf("/watch?v=") > 0; - }).map(function (x) { - return getVideoId(x.href); - }); - getBrowser().runtime.sendMessage({ - message: "send_links", - videoIds: ids - }); -} - -function likeClicked() { - if (checkForSignInButton() === false) { - if (storedData.previousState === DISLIKED_STATE) { - sendVote(1); - storedData.dislikes--; - storedData.likes++; - createRateBar(storedData.likes, storedData.dislikes); - setDislikes(numberFormat(storedData.dislikes)); - storedData.previousState = LIKED_STATE; - } else if (storedData.previousState === NEUTRAL_STATE) { - sendVote(1); - storedData.likes++; - createRateBar(storedData.likes, storedData.dislikes); - storedData.previousState = LIKED_STATE; - } else if (storedData.previousState = LIKED_STATE) { - sendVote(0); - storedData.likes--; - createRateBar(storedData.likes, storedData.dislikes); - storedData.previousState = NEUTRAL_STATE; - } - } -} - -function dislikeClicked() { - if (checkForSignInButton() == false) { - if (storedData.previousState === NEUTRAL_STATE) { - sendVote(-1); - storedData.dislikes++; - setDislikes(numberFormat(storedData.dislikes)); - createRateBar(storedData.likes, storedData.dislikes); - storedData.previousState = DISLIKED_STATE; - } else if (storedData.previousState === DISLIKED_STATE) { - sendVote(0); - storedData.dislikes--; - setDislikes(numberFormat(storedData.dislikes)); - createRateBar(storedData.likes, storedData.dislikes); - storedData.previousState = NEUTRAL_STATE; - } else if (storedData.previousState === LIKED_STATE) { - sendVote(-1); - storedData.likes--; - storedData.dislikes++; - setDislikes(numberFormat(storedData.dislikes)); - createRateBar(storedData.likes, storedData.dislikes); - storedData.previousState = DISLIKED_STATE; - } - } -} - -function addLikeDislikeEventListener() { - var buttons = buttons_getButtons(); - - if (!window.returnDislikeButtonlistenersSet) { - buttons.children[0].addEventListener("click", likeClicked); - buttons.children[1].addEventListener("click", dislikeClicked); - window.returnDislikeButtonlistenersSet = true; - } -} - -function storageChangeHandler(changes, area) { - if (changes.disableVoteSubmission !== undefined) { - handleDisableVoteSubmissionChangeEvent(changes.disableVoteSubmission.newValue); - } -} - -function handleDisableVoteSubmissionChangeEvent(value) { - extConfig.disableVoteSubmission = value; -} - - -;// CONCATENATED MODULE: ./Extensions/combined/src/state.js - - - - -var LIKED_STATE = "LIKED_STATE"; -var DISLIKED_STATE = "DISLIKED_STATE"; -var NEUTRAL_STATE = "NEUTRAL_STATE"; -var DISLIKES_DISABLED_TEXT = "DISLIKES DISABLED"; -var extConfig = { - disableVoteSubmission: false -}; -var storedData = { - likes: 0, - dislikes: 0, - previousState: NEUTRAL_STATE -}; -var likesDisabledState = true; - -function isMobile() { - return location.hostname == "m.youtube.com"; -} - -function isVideoLiked() { - if (isMobile()) { - return getLikeButton().querySelector("button").getAttribute("aria-label") == "true"; - } - - return getLikeButton().classList.contains("style-default-active"); -} - -function isVideoDisliked() { - if (isMobile()) { - return getDislikeButton().querySelector("button").getAttribute("aria-label") == "true"; - } - - return getDislikeButton().classList.contains("style-default-active"); -} - -function getState(storedData) { - 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) { - if (!likesDisabledState) { - if (isMobile()) { - buttons_getButtons().children[1].querySelector(".button-renderer-text").innerText = dislikesCount; - return; - } - - buttons_getButtons().children[1].querySelector("#text").innerText = dislikesCount; - } else { - cLog("likes count diabled by creator"); - - if (isMobile()) { - buttons_getButtons().children[1].querySelector(".button-renderer-text").innerText = DISLIKES_DISABLED_TEXT; - return; - } - - buttons_getButtons().children[1].querySelector("#text").innerText = DISLIKES_DISABLED_TEXT; - } -} - -function getLikeCountFromButton() { - var likesStr = getLikeButton().querySelector("button").getAttribute("aria-label").replace(/\D/g, ""); - return likesStr.length > 0 ? parseInt(likesStr) : false; -} - -function processResponse(response, storedData) { - var formattedDislike = numberFormat(response.dislikes); - setDislikes(formattedDislike); - storedData.dislikes = parseInt(response.dislikes); - storedData.likes = getLikeCountFromButton() || parseInt(response.likes); - - if (!likesDisabledState) { - createRateBar(storedData.likes, storedData.dislikes); - } -} - -function setState(storedData) { - storedData.previousState = isVideoDisliked() ? DISLIKED_STATE : isVideoLiked() ? LIKED_STATE : NEUTRAL_STATE; - var statsSet = false; - getBrowser().runtime.sendMessage({ - message: "set_state", - videoId: getVideoId(window.location.href), - state: getState(storedData).current, - likeCount: getLikeCountFromButton() || null - }, function (response) { - 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); - } - }); -} - -function setInitialState() { - setState(storedData); - setTimeout(function () { - sendVideoIds(); - }, 1500); -} - -function initExtConfig() { - initializeDisableVoteSubmission(); -} - -function initializeDisableVoteSubmission() { - getBrowser().storage.sync.get(['disableVoteSubmission'], function (res) { - if (res.disableVoteSubmission === undefined) { - getBrowser().storage.sync.set({ - disableVoteSubmission: false - }); - } else { - extConfig.disableVoteSubmission = res.disableVoteSubmission; - } - }); -} - - -;// CONCATENATED MODULE: ./Extensions/combined/src/buttons.js - - -function buttons_getButtons() { - var _document$getElementB; - - if (isMobile()) { - return document.querySelector(".slim-video-action-bar-actions"); - } //--- If Menu Element Is Displayed: ---// - - - if (((_document$getElementB = document.getElementById("menu-container")) === null || _document$getElementB === void 0 ? void 0 : _document$getElementB.offsetParent) === null) { - return document.querySelector("ytd-menu-renderer.ytd-watch-metadata > div"); //--- If Menu Element Isnt Displayed: ---// - } else { - var _document$getElementB2; - - return (_document$getElementB2 = document.getElementById("menu-container")) === null || _document$getElementB2 === void 0 ? void 0 : _document$getElementB2.querySelector("#top-level-buttons-computed"); - } -} - -function getLikeButton() { - return buttons_getButtons().children[0]; -} - -function getDislikeButton() { - return buttons_getButtons().children[1]; -} - -function checkForSignInButton() { - if (document.querySelector("a[href^='https://accounts.google.com/ServiceLogin']")) { - return true; - } else { - return false; - } -} - - -;// CONCATENATED MODULE: ./Extensions/combined/ryd.content-script.js -//--- Import Button Functions ---// - //--- Import State Functions ---// - - //--- Import Video & Browser Functions ---// - - - - -initExtConfig(); -var jsInitChecktimer = null; - -function setEventListeners(evt) { - function checkForJS_Finish() { - var _getButtons; - - if ((_getButtons = buttons_getButtons()) !== null && _getButtons !== void 0 && _getButtons.offsetParent && isVideoLoaded()) { - clearInterval(jsInitChecktimer); - jsInitChecktimer = null; - addLikeDislikeEventListener(); - setInitialState(); - getBrowser().storage.onChanged.addListener(storageChangeHandler); - } - } - - if (window.location.href.indexOf("watch?") >= 0) { - jsInitChecktimer = setInterval(checkForJS_Finish, 111); - } -} - -setEventListeners(); -document.addEventListener("yt-navigate-finish", function (event) { - if (jsInitChecktimer !== null) clearInterval(jsInitChecktimer); - window.returnDislikeButtonlistenersSet = false; - setEventListeners(); -}); -setTimeout(function () { - return sendVideoIds(); -}, 2500); -/******/ })() -; \ No newline at end of file diff --git a/Extensions/combined/dist/firefox/content-style.css b/Extensions/combined/dist/firefox/content-style.css deleted file mode 100644 index c06b29c..0000000 --- a/Extensions/combined/dist/firefox/content-style.css +++ /dev/null @@ -1,26 +0,0 @@ -#ryd-bar-container { - background: var(--yt-spec-icon-disabled); - border-radius: 2px; -} - -#ryd-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/combined/dist/firefox/icons/icon128.png b/Extensions/combined/dist/firefox/icons/icon128.png deleted file mode 100644 index 23b4958..0000000 Binary files a/Extensions/combined/dist/firefox/icons/icon128.png and /dev/null differ diff --git a/Extensions/combined/dist/firefox/icons/icon48.png b/Extensions/combined/dist/firefox/icons/icon48.png deleted file mode 100644 index f2a5951..0000000 Binary files a/Extensions/combined/dist/firefox/icons/icon48.png and /dev/null differ diff --git a/Extensions/combined/dist/firefox/icons/icon_hold128.png b/Extensions/combined/dist/firefox/icons/icon_hold128.png deleted file mode 100644 index 359a686..0000000 Binary files a/Extensions/combined/dist/firefox/icons/icon_hold128.png and /dev/null differ diff --git a/Extensions/combined/dist/firefox/icons/server.svg b/Extensions/combined/dist/firefox/icons/server.svg deleted file mode 100644 index 869a391..0000000 --- a/Extensions/combined/dist/firefox/icons/server.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/Extensions/combined/dist/firefox/manifest.json b/Extensions/combined/dist/firefox/manifest.json deleted file mode 100644 index c0f2941..0000000 --- a/Extensions/combined/dist/firefox/manifest.json +++ /dev/null @@ -1,26 +0,0 @@ -{ - "name": "Return YouTube Dislike", - "description": "Returns ability to see dislikes", - "version": "2.0.0.3", - "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": ["bundled-content-script.js"] - } - ] -} diff --git a/Extensions/combined/dist/firefox/popup.css b/Extensions/combined/dist/firefox/popup.css deleted file mode 100644 index 757692d..0000000 --- a/Extensions/combined/dist/firefox/popup.css +++ /dev/null @@ -1,127 +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: 0.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; -} - -#server-status { - height: 72px; - width: 90px; - /* filter: invert(21%) sepia(100%) saturate(3618%) hue-rotate(102deg) - brightness(96%) contrast(108%); */ -} diff --git a/Extensions/combined/dist/firefox/popup.html b/Extensions/combined/dist/firefox/popup.html deleted file mode 100644 index 130f557..0000000 --- a/Extensions/combined/dist/firefox/popup.html +++ /dev/null @@ -1,61 +0,0 @@ - - - - - Return YouTube Dislike - - - - - - -
- - - - -

Return YouTube Dislike

- -

API Status:

-

by Dmitrii Selivanov & Community

-

- - - - - -

- - -
- -
- -
-
- -
- Settings - - -
- - -
- - - diff --git a/Extensions/combined/dist/firefox/popup.js b/Extensions/combined/dist/firefox/popup.js deleted file mode 100644 index 291f555..0000000 --- a/Extensions/combined/dist/firefox/popup.js +++ /dev/null @@ -1,126 +0,0 @@ -/* Config */ -const config = { - advanced: false, - showAdvancedMessage: "Show Settings", - hideAdvancedMessage: "Hide Settings", - disableVoteSubmission: false, -} - - function initConfig() { - initializeVersionNumber(); - } - - function initializeVersionNumber() { - const version = chrome.runtime.getManifest().version; - document.getElementById('ext-version').innerHTML = 'v' + version; -} - - links: { - website: "https://returnyoutubedislike.com", - github: "https://github.com/Anarios/return-youtube-dislike", - discord: "https://discord.gg/mYnESY4Md5", - donate: "https://returnyoutubedislike.com/donate", - faq: "https://returnyoutubedislike.com/faq", - }, -}; - -/* 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_faq").addEventListener("click", () => { - chrome.tabs.create({ url: config.links.faq }); -}); - -document.getElementById("link_donate").addEventListener("click", () => { - chrome.tabs.create({ url: config.links.donate }); -}); - -document - .getElementById("disable_vote_submission") - .addEventListener("click", (ev) => { - chrome.storage.sync.set({ disableVoteSubmission: ev.target.checked }); - }); - -/* Advanced Toggle */ -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; - } -}); - -initConfig(); - -function initConfig() { - initializeDisableVoteSubmission(); -} - -function initializeDisableVoteSubmission() { - chrome.storage.sync.get(["disableVoteSubmission"], (res) => { - handleDisableVoteSubmissionChangeEvent(res.disableVoteSubmission); - }); -} - -chrome.storage.onChanged.addListener(storageChangeHandler); - -function storageChangeHandler(changes, area) { - if (changes.disableVoteSubmission !== undefined) { - handleDisableVoteSubmissionChangeEvent( - changes.disableVoteSubmission.newValue - ); - } -} - -function handleDisableVoteSubmissionChangeEvent(value) { - config.disableVoteSubmission = value; - document.getElementById("disable_vote_submission").checked = value; -} - -(async function getStatus() { - let status = document.getElementById("status"); - let serverStatus = document.getElementById("server-status"); - let resp = await fetch( - "https://returnyoutubedislikeapi.com/votes?videoId=YbJOTdZBX1g" - ); - let result = await resp.status; - if (result === 200) { - status.innerText = "Online"; - status.style.color = "green"; - serverStatus.style.filter = - "invert(58%) sepia(81%) saturate(2618%) hue-rotate(81deg) brightness(119%) contrast(129%)"; - } else { - status.innerText = "Offline"; - status.style.color = "red"; - serverStatus.style.filter = - "invert(11%) sepia(100%) saturate(6449%) hue-rotate(3deg) brightness(116%) contrast(115%)"; - } -})(); - -/* 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/combined/dist/firefox/ryd.background.js b/Extensions/combined/dist/firefox/ryd.background.js deleted file mode 100644 index e332d8d..0000000 --- a/Extensions/combined/dist/firefox/ryd.background.js +++ /dev/null @@ -1,272 +0,0 @@ -const apiUrl = "https://returnyoutubedislikeapi.com"; -const voteDisabledIconName = 'icon_hold128.png'; -const defaultIconName = 'icon128.png'; -let api; - -/** stores extension's global config */ -let extConfig = { - disableVoteSubmission: false -} - -if (isChrome()) api = chrome; -else if (isFirefox()) api = browser; - -initExtConfig() - -api.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") { - // 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}&likeCount=${request.likeCount || ''}`, { - method: "GET", - headers: { - Accept: "application/json", - }, - }) - .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 == "register") { - register(); - return true; - } else if (request.message == "send_vote") { - sendVote(request.videoId, request.vote); - return true; - } -}); - -async function sendVote(videoId, vote) { - api.storage.sync.get(null, async (storageResult) => { - if (!storageResult.userId || !storageResult.registrationConfirmed) { - await register(); - return; - } - fetch(`${apiUrl}/interact/vote`, { - method: "POST", - headers: { - "Content-Type": "application/json", - }, - body: JSON.stringify({ - userId: storageResult.userId, - videoId, - value: vote, - }), - }) - .then(async (response) => { - if (response.status == 401) { - await register(); - await sendVote(videoId, vote); - return; - } - return response.json() - }) - .then((response) => { - solvePuzzle(response).then((solvedPuzzle) => { - fetch(`${apiUrl}/interact/confirmVote`, { - method: "POST", - headers: { - "Content-Type": "application/json", - }, - body: JSON.stringify({ - ...solvedPuzzle, - userId: storageResult.userId, - videoId, - }), - }); - }); - }); - }); -} - -function register() { - let userId = generateUserID(); - api.storage.sync.set({ userId }); - return fetch(`${apiUrl}/puzzle/registration?userId=${userId}`, { - method: "GET", - headers: { - Accept: "application/json", - }, - }) - .then((response) => response.json()) - .then((response) => { - return solvePuzzle(response).then((solvedPuzzle) => { - return fetch(`${apiUrl}/puzzle/registration?userId=${userId}`, { - method: "POST", - headers: { - "Content-Type": "application/json", - }, - body: JSON.stringify(solvedPuzzle), - }).then((response) => - response.json().then((result) => { - if (result === true) { - return api.storage.sync.set({ registrationConfirmed: true }); - } - }) - ); - }); - }) - .catch(); -} - -api.storage.sync.get(null, (res) => { - if (!res || !res.userId || !res.registrationConfirmed) { - register(); - } -}); - -const sentIds = new Set(); -let toSend = []; - -function sendUserSubmittedStatisticsToApi(statistics) { - fetch(`${apiUrl}/votes/user-submitted`, { - method: "POST", - headers: { - "Content-Type": "application/json", - }, - body: JSON.stringify(statistics), - }); -} - -function countLeadingZeroes(uInt8View, limit) { - let zeroes = 0; - let value = 0; - for (let i = 0; i < uInt8View.length; i++) { - value = uInt8View[i]; - if (value === 0) { - zeroes += 8; - } else { - let count = 1; - if (value >>> 4 === 0) { - count += 4; - value <<= 4; - } - if (value >>> 6 === 0) { - count += 2; - value <<= 2; - } - zeroes += count - (value >>> 7); - break; - } - if (zeroes >= limit) { - break; - } - } - return zeroes; -} - -async function solvePuzzle(puzzle) { - let challenge = Uint8Array.from(atob(puzzle.challenge), (c) => - c.charCodeAt(0) - ); - let buffer = new ArrayBuffer(20); - let uInt8View = new Uint8Array(buffer); - let uInt32View = new Uint32Array(buffer); - let maxCount = Math.pow(2, puzzle.difficulty) * 5; - for (let i = 4; i < 20; i++) { - uInt8View[i] = challenge[i - 4]; - } - - for (let i = 0; i < maxCount; i++) { - uInt32View[0] = i; - let hash = await crypto.subtle.digest("SHA-512", buffer); - let hashUint8 = new Uint8Array(hash); - if (countLeadingZeroes(hashUint8) >= puzzle.difficulty) { - return { - solution: btoa(String.fromCharCode.apply(null, uInt8View.slice(0, 4))), - }; - } - } -} - -function generateUserID(length = 36) { - const charset = - "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"; - let result = ""; - if (crypto && crypto.getRandomValues) { - const values = new Uint32Array(length); - crypto.getRandomValues(values); - for (let i = 0; i < length; i++) { - result += charset[values[i] % charset.length]; - } - return result; - } else { - for (let i = 0; i < length; i++) { - result += charset[Math.floor(Math.random() * charset.length)]; - } - return result; - } -} - -function storageChangeHandler(changes, area) { - if (changes.disableVoteSubmission !== undefined) { - handleDisableVoteSubmissionChangeEvent(changes.disableVoteSubmission.newValue); - } -} - -function handleDisableVoteSubmissionChangeEvent(value) { - extConfig.disableVoteSubmission = value; - if (value === true) { - changeIcon(voteDisabledIconName); - } else { - changeIcon(defaultIconName); - } -} - -function changeIcon(iconName) { - if (api.action !== undefined) api.action.setIcon({path: "/icons/" + iconName}); - else if (api.browserAction !== undefined) api.browserAction.setIcon({path: "/icons/" + iconName}); - else console.log('changing icon is not supported'); -} - -api.storage.onChanged.addListener(storageChangeHandler); - -function initExtConfig() { - initializeDisableVoteSubmission(); -} - -function initializeDisableVoteSubmission() { - api.storage.sync.get(['disableVoteSubmission'], (res) => { - if (res.disableVoteSubmission === undefined) { - api.storage.sync.set({disableVoteSubmission: false}); - } - else { - extConfig.disableVoteSubmission = res.disableVoteSubmission; - if (res.disableVoteSubmission) changeIcon(voteDisabledIconName); - } - }); -} - -function isChrome() { - return typeof chrome !== "undefined" && typeof chrome.runtime !== "undefined"; -} - -function isFirefox() { - return typeof browser !== "undefined" && typeof browser.runtime !== "undefined"; -} \ No newline at end of file -- cgit v1.2.3