YouTube Mobile Auto Like

Reliably clicks like on m.youtube.com videos using aggressive polling and proper event listeners for mobile YouTube SPA navigation.

当前为 2025-07-18 提交的版本,查看 最新版本

// ==UserScript==
// @name         YouTube Mobile Auto Like
// @namespace    http://tampermonkey.net/
// @version      2.0
// @description  Reliably clicks like on m.youtube.com videos using aggressive polling and proper event listeners for mobile YouTube SPA navigation.
// @author       Seth@WiiPlaza
// @match        https://m.youtube.com/watch*
// @run-at       document-idle
// @grant        none
// @icon         https://images-wixmp-ed30a86b8c4ca887773594c2.wixmp.com/f/85aa6584-7ebf-439b-b994-59802e194f0b/djm0ls4-ac1eba6a-6058-4454-9ce9-6eba6ad26b23.png?token=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJ1cm46YXBwOjdlMGQxODg5ODIyNjQzNzNhNWYwZDQxNWVhMGQyNmUwIiwiaXNzIjoidXJuOmFwcDo3ZTBkMTg4OTgyMjY0MzczYTVmMGQ0MTVlYTBkMjZlMCIsIm9iaiI6W1t7InBhdGgiOiJcL2ZcLzg1YWE2NTg0LTdlYmYtNDM5Yi1iOTk0LTU5ODAyZTE5NGYwYlwvZGptMGxzNC1hYzFlYmE2YS02MDU4LTQ0NTQtOWNlOS02ZWJhNmFkMjZiMjMucG5nIn1dXSwiYXVkIjpbInVybjpzZXJ2aWNlOmZpbGUuZG93bmxvYWQiXX0.ei28OmVYY6hrSLNsa61AIocsIhsN2VKBCRUv2N6lTc4
// ==/UserScript==

(function() {
    'use strict';

    function tryClickLikeButton(maxAttempts = 30) {
        let attempts = 0;
        const interval = setInterval(() => {
            const likeBtn = Array.from(document.querySelectorAll('like-button-view-model button'))
                .find(btn => btn.getAttribute('aria-pressed') === 'false' && btn.getAttribute('aria-label')?.includes('like this video'));

            if (likeBtn) {
                likeBtn.click();
                console.log('[AutoLike] ✅ Clicked Like button');
                clearInterval(interval);
            }

            attempts++;
            if (attempts >= maxAttempts) {
                console.warn('[AutoLike] ❌ Gave up after too many tries.');
                clearInterval(interval);
            }
        }, 1000);
    }

    function onPageReady() {
        setTimeout(tryClickLikeButton, 1000);
    }

    onPageReady();

    document.addEventListener('yt-page-data-updated', () => {
        setTimeout(tryClickLikeButton, 1000);
    });
})();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址