YouTube Like/Dislike Shortcut

Enables keyboard shortcuts to like/dislike a video on YouTube.

// ==UserScript==
// @name               YouTube Like/Dislike Shortcut
// @name:pt-BR         Atalhos Gostei/Não Gostei no YouTube
// @namespace          will64gamer
// @author             will64gamer
// @description        Enables keyboard shortcuts to like/dislike a video on YouTube.
// @description:pt-BR  Cria atalhos para os botões gostei/não gostei em um vídeo no YouTube.
// @match              *://*.youtube.com/*
// @license            MIT
// @version            4.6
// ==/UserScript==

// You can change the codes to whichever keys you want to use for liking, disliking, and opening or writing comments on Shorts.
const codeLike = "NumpadAdd";
const codeDislike = "NumpadSubtract";
const codeComments = "NumpadMultiply";
// Don't use a key that only types its character once you type another because otherwise it will be typed first when you type your comment.
const codeWrite = "NumpadDivide";

/* Filling in these quotation marks with the code of a key creates an additional shortcut dedicated to removing your like/dislike,
   that makes it so that pressing the regular shortcuts for liking/disliking multiple times has no effect on the state of that button.
   If you want to use the regular shortcuts for removing likes/dislikes as well, leave this blank.                                     */
let codeRemove = " ";

// If you want the shortcut to be triggered only when holding ctrl, alt, or shift, change this value from 0 to 1, 2, or 3, respectively.
const combination = 0;

// Change this to 0 if you don't want the sound alert. 1 only triggers the alert on regular videos, 2 triggers it on Shorts as well.
const alertPlays = 2;

// Change these values if you want to change the volume percentage of the alerts from their default (value must be between in the 0-100 range).
const likeVolumePercentage = 50;
const dislikeVolumePercentage = 30;

// You can change the sounds for the alerts by using your own audio file URLs or base64 encoded data.
const likeSound = new Audio(`
  data:audio/mp3; base64,
  //OEZAAAAAAAAAAAAAAAAAAAAAAAWGluZwAAAA8AAAAKAAAH+AAaGhoaGhoaGhoaSUlJSUlJSUlJSWBgYGBgYGBgYGCBgYGBgYGBgYGBnJycnJycnJycnLa2tra2tra2trbOzs7Ozs7Ozs7O5eXl5eXl5eXl5fz8/Pz8/Pz8/Pz///////////8AAAA5TEFNRTMuOTlyAm4AAAAALCAAABRGJAPnTgAARgAAB/hJttFsAAAAAAAAAAAAAAAAAAAA//OEZAANof9pL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5eNiKbyWbSiDSTJm2WcQ4Mc5jR9zn7vbTw5lUxn6JqtuVuzMmC31vYei/pe6mKHU6zbRVl8zbZb3UL503P+5T/NpP/Hmc/3mTeZnjkbhaoWou6SpFeROBZTkqSnyUCQIIA4MAACg0YAJ5HvV4ujxgYjHxs3ORRt9fbIxKDWQ8hi2MziYoiF2MAAAAAAACkmWwyHLhMtpnczLyZ3Jy0kwbmpc3k5+XKGZiXpjm5EQ2RJm3O6iHLOGUONczBbauw0dwzs9W0UReWulrqaqmrVcWoq0WhrlhwoY2buVluloOzt7n9mYDLj0PjznFVR11Y9vLfSnbc3CP573PG7tnMk6rsSXe9zQFgewAc
`);

//    /\/\/\   Settings   /\/\/\
//  ------------------------------
//    \/\/\/     Code     \/\/\/

let tag, timeout;
let isShort = false, rendererId = 0, shortsArray = [];
let like, dislike, buttons, sLike, sDislike, comments, closeComments, textbox, commentBox, description;

if (codeRemove == null) {codeRemove = "";}
else {codeRemove = codeRemove.trim();}

likeSound.volume = likeVolumePercentage/100;
dislikeSound.volume = dislikeVolumePercentage/100;

const observer = new MutationObserver(findButtons);

addEventListener('yt-page-data-updated', reset);
addEventListener('popstate', reset);

function reset() {
  isVideo = /^\/watch/.test(location.pathname);
  isShort = /^\/shorts/.test(location.pathname);
  if (isVideo||isShort) {
    removeEventListener("keydown", press);
    like = null; dislike = null; sLike = null; sDislike = null;
    comments = null; closeComments = null; textbox = null;
    observer.observe(document.documentElement, {childList: true, subtree: true});
    findButtons();
  }
}

function findButtons() {
  if ((like && dislike) || (sLike && sDislike && comments)) {
    addEventListener("keydown", press);
    observer.disconnect();
    let currentURL = location.href, first = true;
    if (isShort) {
      let shortInterval = setInterval(() => {
        if (first) {
          checkId(location.href);
          first = false;
        }
        if (location.href !== currentURL) {
          clearInterval(shortInterval);
          currentURL = location.href;
          if(!checkId(location.href)){rendererId++;}
          reset();
        }
      }, 400);
    }
  }

  if (isShort) {
    adButtons = document?.getElementsByTagName("ytd-reel-video-renderer")[rendererId]
      ?.getElementsByClassName("overlay style-scope ytd-reel-video-renderer")[1]
      ?.getElementsByTagName("ytd-ad-slot-renderer")[0]?.firstElementChild?.firstElementChild?.firstElementChild
      ?.firstElementChild?.getElementsByClassName("YtwReelsPlayerOverlayLayoutViewModelHostActionBar")[0]
      ?.firstElementChild?.getElementsByTagName("button-view-model");
    if(!adButtons){
      buttons = document?.getElementsByTagName("ytd-reel-video-renderer")[rendererId]
        ?.getElementsByClassName("overlay style-scope ytd-reel-video-renderer")[1]?.firstElementChild
        ?.getElementsByClassName("action-container")[0]?.firstElementChild?.querySelectorAll("button");
      if (buttons) {
        sLike = buttons[0];
        sDislike = buttons[1];
        comments = buttons[2];
        closeComments = null;
      }
    } else {
      sLike = adButtons[0]?.firstElementChild?.firstElementChild?.firstElementChild?.firstElementChild;
      sDislike = adButtons[1]?.firstElementChild?.firstElementChild?.firstElementChild?.firstElementChild;
      comments = adButtons[2]?.firstElementChild?.firstElementChild?.firstElementChild;
      closeComments = "ad";
    }
  } else {
    like = document?.getElementsByTagName("like-button-view-model")[0]?.firstElementChild?.firstElementChild?.firstElementChild;
    dislike = document?.getElementsByTagName("dislike-button-view-model")[0]?.firstElementChild?.firstElementChild?.firstElementChild;
  }
}

function press(e) {
  if (e.target.getAttribute("contenteditable") === "true") {return;}

  tag = e.target.tagName.toLowerCase();
  if (tag === "input" || tag === "textarea") {return;}

  switch (combination) {
    case 1:
      if (!e.ctrlKey) {return;}
      break;
    case 2:
      if (!e.altKey) {return;}
      break;
    case 3:
      if (!e.shiftKey) {return;}
      break;
  }

  switch (e.code) {
    case codeComments:
      if (comments) {
        if (closeComments && closeComments != "ad") {
          closeComments.click();
          closeComments = null;
        } else {
          openComments();
        }
      }
      break;
    case codeWrite:
      e.preventDefault();
      e.stopPropagation();
      if (textbox) {
        openComments();
        setTimeout(() => {
          textbox.click();
        }, 100);
      } else if (comments) {
        openComments();
        let textboxInterval = setInterval(() => {
          if (!textbox) {
            textbox = document.getElementById("simplebox-placeholder");
          } else {
            textbox.focus();
            clearInterval(textboxInterval);
          }
        }, 300);
      } else {
        if (commentBox) {
          commentBox.click();
        } else {
          commentBox = document?.getElementsByClassName("style-scope ytd-comment-simplebox-renderer")[1]?.firstElementChild;
          if (!commentBox) {
            if (!description){
              description = document.getElementById("bottom-row");
              description.scrollIntoView();
            }
            let commentBoxInterval = setInterval(() => {
              if (!commentBox) {
                commentBox = document?.getElementsByClassName("style-scope ytd-comment-simplebox-renderer")[1]?.firstElementChild;
              } else {
                commentBox.focus();
                clearInterval(commentBoxInterval);
              }
            }, 300);
          } else {commentBox.click();}
        }
      }
      break;
    case codeLike:
      if (like) {
        if (codeRemove != "") {if (checkPressed(like)) {break;}}
        if (alertPlays !== 0) {alert(like);}
        like.click();
      }
      else if (sLike) {
        if (codeRemove != "") {if (checkPressed(sLike)) {break;}}
        if (alertPlays === 2) {alert(sLike);}
        sLike.click();
      }
      break;
    case codeDislike:
      if (dislike) {
        if (codeRemove != "") {if (checkPressed(dislike)) {break;}}
        if (alertPlays !== 0) {alert(dislike);}
        dislike.click();
      }
      else if (sDislike) {
        if (codeRemove != "") {if (checkPressed(sDislike)) {break;}}
        if (alertPlays === 2) {alert(sDislike);}
        sDislike.click();
      }
      break;
    case codeRemove:
      if (like) {
        if (checkPressed(like)) {like.click();} else if (checkPressed(dislike)) {dislike.click();}
      } else if (sLike) {
        if (checkPressed(sLike)) {sLike.click();} else if (checkPressed(sDislike)) {sDislike.click();}
      }
      break;
  }
}

function checkId(href) {
  for(let i = 0; i < shortsArray.length; i++) {
    if (href === shortsArray[i]) {
      rendererId = i;
      return true;
    }
  }
  shortsArray.push(href);
  return false;
}

function checkPressed(element) {
  return (element.getAttribute("aria-pressed") === "true");
}

function openComments() {
  comments.click();
  let closeCommentsInterval = setInterval(() => {
    if (!closeComments) {
      closeComments = document?.getElementById("visibility-button")?.getElementsByTagName('button')[0];
    } else {
      clearInterval(closeCommentsInterval);
    }
  }, 300);
}

function alert(element) {
  if (checkPressed(element)) {return;}
  if (element === dislike || element === sDislike) {dislikeSound.play();}
  else {likeSound.play();}
}