您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
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. // @include https://www.youtube.com/* // @license MIT // @version 2.1 // ==/UserScript== // You can change the codes to whichever keys you want to use for liking, disliking, and opening comments on Shorts. const codeLike = "NumpadAdd"; const codeDislike = "NumpadSubtract"; const codeComments = "NumpadMultiply"; // Change this to false if you don't want Shorts to refresh on load. const shortsRefresh = true; let isShort = false; let tag, like, dislike, sLike, sDislike, comments, textBox; const observer = new MutationObserver(findButtons); addEventListener('yt-page-data-updated', reset); addEventListener('popstate', reset); function reset() { isShort = /^\/shorts/.test(location.pathname); if (/^\/watch/.test(location.pathname)||isShort) { removeEventListener("keydown", press); observer.observe(document.documentElement, {childList: true, subtree: true}); like = null; dislike = null; sLike = null; sDislike = null; findButtons(); } } function findButtons() { if ((like && dislike) || (sLike && sDislike && comments)) { addEventListener("keydown", press); observer.disconnect(); if (isShort && shortsRefresh) { let currentURL = location.href; let shortInterval = setInterval(() => { if (location.href !== currentURL) { currentURL = location.href; clearInterval(shortInterval); location.reload(); } }, 400); } } if (isShort) { sLike = document.getElementById("like-button")?.getElementsByTagName('button')[0]; sDislike = document.getElementById("dislike-button")?.getElementsByTagName('button')[0]; comments = document.getElementById("comments-button")?.getElementsByTagName('button')[0]; } 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 (e.code) { case codeComments: if (comments) { comments.click(); let textboxInterval = setInterval(() => { if (!textBox) { textBox = document.getElementById("simplebox-placeholder"); } else { textBox.focus(); clearInterval(textboxInterval); } }, 300); } break; case codeLike: if (like) {like.click();} else if (sLike) {sLike.click();} break; case codeDislike: if (dislike) {dislike.click();} else if (sDislike) {sDislike.click();} break; } }
QingJ © 2025
镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址