您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Auto likes a video or livestream on YouTube
当前为
// ==UserScript== // @name YouTube Auto Like // @namespace http://tampermonkey.net/ // @version 1.01 // @description Auto likes a video or livestream on YouTube // @author Yukiteru // @match https://www.youtube.com/watch* // @icon https://www.google.com/s2/favicons?sz=64&domain=youtube.com // @grant none // @license MIT // ==/UserScript== function printLog(message) { console.log(`[YouTube Auto Like]: ${message}`); } function getLikeButton() { return document.querySelector("like-button-view-model button"); } function isLiked() { return getLikeButton().getAttribute("aria-pressed") === "true"; } function isSubscribed() { const subscribeButton = document.querySelector( "ytd-subscribe-button-renderer" ); return subscribeButton.hasAttribute("subscribed"); } function isLivestream() { const metaTag = document.querySelector("meta[itemprop='isLiveBroadcast']"); return metaTag !== null; } function like(video) { if (isLiked()) printLog('user liked manually') else getLikeButton().click(); video.removeEventListener("timeupdate", listener); } function listener() { const video = document.querySelector("video.video-stream"); if (video.currentTime / video.duration > 0.8 && isSubscribed()) { like(video); // like after watched 80 percent of the video } } function findLikeButton() { const observer = new MutationObserver((mutations, observer) => { if (!getLikeButton()) return; // Keep trying to check like status const likeStatus = getLikeButton().getAttribute("aria-pressed"); if (!likeStatus) return; printLog("like status checked"); observer.disconnect(); if (isLiked() || !isSubscribed()) return false; // exit if already liked or not subscribed if (isLivestream() && isSubscribed()) return like(); // like and exit if subscribed and is a livestream const video = document.querySelector("video.video-stream"); video.addEventListener("timeupdate", listener); }); observer.observe(document, { childList: true, subtree: true }); } findLikeButton();
QingJ © 2025
镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址