Pārlūkot izejas kodu

Old extensions removed, sponsors added to website

Dmitrii Selivanov 3 gadi atpakaļ
vecāks
revīzija
3cb09e6fd2

+ 0 - 26
Extensions/chrome/content-style.css

@@ -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;
-}

BIN
Extensions/chrome/icons/icon128.png


BIN
Extensions/chrome/icons/icon48.png


+ 0 - 119
Extensions/chrome/popup.css

@@ -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;
-}

+ 0 - 50
Extensions/chrome/popup.html

@@ -1,50 +0,0 @@
-<!DOCTYPE html>
-<html lang="en">
-  <head>
-    <meta content="text/html; charset=utf-8" />
-    <title>Return YouTube Dislike</title>
-    <link rel="stylesheet" href="popup.css" />
-    <link rel="preconnect" href="https://fonts.googleapis.com">
-    <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
-    <link href="https://fonts.googleapis.com/css2?family=Roboto:wght@100;300;400;500;700;900&display=swap" rel="stylesheet">
-  </head>
-  <body>
-    <center>
-      <svg width="48" viewBox="0 0 24 24"><path d="M14.9 3H6c-.9 0-1.6.5-1.9 1.2l-3 7c-.1.3-.1.5-.1.7v2c0 1.1.9 2 2 2h6.3l-.9 4.5c-.1.5 0 1 .4 1.4l1.1 1.1 6.5-6.6c.4-.4.6-.9.6-1.4V5c-.1-1.1-1-2-2.1-2zm7.4 12.8h-2.9c-.4 0-.7-.3-.7-.7V3.9c0-.4.3-.7.7-.7h2.9c.4 0 .7.3.7.7V15c0 .4-.3.8-.7.8z" fill="red"/><path d="m8 12.5 5.1-2.9L8 6.7v5.8z" fill="#fff"/></svg>
-      <h1>Return YouTube Dislike</h1>
-      <p>by Dmitrii Selivanov & Community</p>
-
-      <button id="link_website">Website</button>
-      <button id="link_github">GitHub</button>
-      <button id="link_discord">Discord</button>
-
-      <br><br>
-      <p>Donate</p>
-      <button id="link_patreon">Patreon</button>
-      <button id="link_yoomoney">Yoomoney</button>
-      <br>
-
-      <br>
-<!--      <button id="advancedToggle">Show Settings</button>-->
-      <br>
-
-    </center>
-
-    <fieldset id="advancedSettings">
-      <legend id="advancedLegend">Settings</legend>
-
-      <label class="switch">
-        <input type="checkbox" id="disable_ratio_bar" />
-        <span class="slider" />
-        <span class="switchLabel">Lorem ipsum dolor sit amet</span> </label
-      ><br />
-
-      <label class="switch">
-        <input type="checkbox" id="disable_api_unlisted" />
-        <span class="slider" />
-        <span class="switchLabel">Lorem ipsum dolor sit amet</span> </label
-      ><br />
-    </fieldset>
-  </body>
-  <script src="popup.js"></script>
-</html>

+ 0 - 63
Extensions/chrome/popup.js

@@ -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" });
-});
-*/

+ 0 - 111
Extensions/chrome/return-youtube-dislike.background.js

@@ -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),
-  });
-}

+ 0 - 10
Extensions/chrome/return-youtube-dislike.content-script.js

@@ -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);
-});

+ 0 - 314
Extensions/chrome/return-youtube-dislike.script.js

@@ -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",
-        `
-          <div class="ryd-tooltip" style="width: ${widthPx}px">
-          <div class="ryd-tooltip-bar-container">
-             <div
-                id="return-youtube-dislike-bar-container"
-                style="width: 100%; height: 2px;"
-                >
-                <div
-                   id="return-youtube-dislike-bar"
-                   style="width: ${widthPercent}%; height: 100%"
-                   ></div>
-             </div>
-          </div>
-          <tp-yt-paper-tooltip position="top" id="ryd-dislike-tooltip" class="style-scope ytd-sentiment-bar-renderer" role="tooltip" tabindex="-1">
-             <!--css-build:shady-->${likes.toLocaleString()}&nbsp;/&nbsp;${dislikes.toLocaleString()}
-          </tp-yt-paper-tooltip>
-          </div>
-  `
-      );
-    } 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()}&nbsp;/&nbsp;${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"));

BIN
Extensions/combined/icons.zip


+ 11 - 25
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"]
     }
   ]
+
 }

+ 0 - 27
Extensions/combined/manifestv2.json

@@ -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"]
-    }
-  ]
-
-}

+ 13 - 11
Extensions/chrome/manifest.json → 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/*"]
     }
   ]

+ 0 - 14
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;

+ 0 - 23
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(
       {

+ 0 - 42
Extensions/firefox/content-style.css

@@ -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;
-}

BIN
Extensions/firefox/icons/icon128.png


BIN
Extensions/firefox/icons/icon48.png


+ 0 - 26
Extensions/firefox/manifest.json

@@ -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"]
-    }
-  ]
-
-}

+ 0 - 105
Extensions/firefox/popup.css

@@ -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;
-}

+ 0 - 54
Extensions/firefox/popup.html

@@ -1,54 +0,0 @@
-<!DOCTYPE html>
-<html lang="en">
-  <head>
-    <meta content="text/html; charset=utf-8">
-    <title>Return YouTube Dislike</title>
-    <link rel="stylesheet" href="popup.css">
-    <link rel="preconnect" href="https://fonts.googleapis.com">
-    <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
-    <link href="https://fonts.googleapis.com/css2?family=Roboto:wght@100;300;400;500;700;900&display=swap" rel="stylesheet">
-  </head>
-  <body>
-
-
-    <center>
-      <svg width="48" viewBox="0 0 24 24"><path d="M14.9 3H6c-.9 0-1.6.5-1.9 1.2l-3 7c-.1.3-.1.5-.1.7v2c0 1.1.9 2 2 2h6.3l-.9 4.5c-.1.5 0 1 .4 1.4l1.1 1.1 6.5-6.6c.4-.4.6-.9.6-1.4V5c-.1-1.1-1-2-2.1-2zm7.4 12.8h-2.9c-.4 0-.7-.3-.7-.7V3.9c0-.4.3-.7.7-.7h2.9c.4 0 .7.3.7.7V15c0 .4-.3.8-.7.8z" fill="red"/><path d="m8 12.5 5.1-2.9L8 6.7v5.8z" fill="#fff"/></svg>
-      <h1>Return YouTube Dislike</h1>
-      <p>by Dmitrii Selivanov & Community</p>
-
-      <button id="link_website">Website</button>
-      <button id="link_github">GitHub</button>
-      <button id="link_discord">Discord</button>
-
-      <br><br>
-      <p>Donate</p>
-      <button id="link_patreon">Patreon</button>
-      <button id="link_yoomoney">Yoomoney</button>
-      <br>
-
-      <br>
-<!--      <button id="advancedToggle">Show Settings</button>-->
-      <br>
-
-    </center>
-
-    <div id="advancedSettings">
-
-      <label class="switch">
-        <input type="checkbox" id="disable_ratio_bar" />
-        <span class="slider" />
-        <span class="switchLabel">Lorem ipsum dolor sit amet</span>
-    </label><br>
-
-    <label class="switch">
-        <input type="checkbox" id="disable_api_unlisted" />
-        <span class="slider" />
-        <span class="switchLabel">Lorem ipsum dolor sit amet</span>
-    </label><br>
-
-    </div>
-
-
-  </body>
-  <script src="popup.js"></script>
-</html>

+ 0 - 65
Extensions/firefox/popup.js

@@ -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" });
-});
-*/

+ 0 - 130
Extensions/firefox/return-youtube-dislike.background.js

@@ -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),
-  });
-}

+ 0 - 335
Extensions/firefox/return-youtube-dislike.script.js

@@ -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",
-      `
-          <div class="ryd-tooltip" style="width: ${widthPx}px">
-          <div class="ryd-tooltip-bar-container">
-             <div
-                id="return-youtube-dislike-bar-container"
-                style="width: 100%; height: 2px;"
-                >
-                <div
-                   id="return-youtube-dislike-bar"
-                   style="width: ${widthPercent}%; height: 100%"
-                   ></div>
-             </div>
-          </div>
-          <tp-yt-paper-tooltip position="top" id="ryd-dislike-tooltip" class="style-scope ytd-sentiment-bar-renderer" role="tooltip" tabindex="-1">
-          <div>
-             <!--css-build:shady-->${likes.toLocaleString()}&nbsp;/&nbsp;${dislikes.toLocaleString()}
-          </tp-yt-paper-tooltip>
-          </div>
-  `
-    );
-  } 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()}&nbsp;/&nbsp;${dislikes.toLocaleString()}`;
-  }
-}
-
-function sendVideoIds() {
-  let 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")
-  );
-  const ids = links.filter((x) => x.href && x.href.indexOf("/watch?v=") > 0)
-    .map((x) => getVideoId(x.href));
-  browser.runtime.sendMessage({
-    message: "send_links",
-    videoIds: ids,
-  });
-}
-
-setEventListeners();
-
-setTimeout(() => sendVideoIds(), 1500);

+ 15 - 1
Website/pages/index.vue

@@ -27,11 +27,19 @@
       <v-icon style="margin-right: 0.5em;">mdi-discord</v-icon>
       Discord
     </v-btn>
-
+    <div id="sponsors">
+      <h3>Sponsors:</h3>
+      <p v-for="sponsor in sponsors" style="margin: 0px 0px ">
+        <a :href="sponsor.link">{{sponsor.name}}</a>
+      </p>
+    </div>
   </div>
 </template>
 
 <style scoped>
+#sponsors {
+  margin-top: 200px;
+}
 #thumbslogo {
   opacity: 0;
   fill: transparent;
@@ -129,6 +137,12 @@ export default {
       installLink: "/install",
       githubLink: "https://github.com/Anarios/return-youtube-dislike",
       discordLink: "https://discord.gg/mYnESY4Md5",
+      sponsors: [
+        {name: "Piepacker", link: "https://piepacker.com/" },
+        {name: "nodetube", link: "https://github.com/mayeaux/nodetube"},
+        {name: "trig404"},
+        {name: "Peter33"}
+      ]
     }
   }
 }