Instagram Auto Comment Liker

Automatically likes all visible comments on an Instagram post by scrolling through and liking unliked comments.

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         Instagram Auto Comment Liker
// @namespace    http://tampermonkey.net/
// @version      1.0
// @description  Automatically likes all visible comments on an Instagram post by scrolling through and liking unliked comments.
// @author       YourName
// @match        https://www.instagram.com/*
// @grant        none
// @license      MIT
// ==/UserScript==

(async function () {
    const wait = (ms) => new Promise(res => setTimeout(res, ms));

    let likedCount = 0;
    let previousHeight = 0;

    async function likeVisibleComments() {
        const commentContainers = document.querySelectorAll('ul ul > div > li');
        for (let comment of commentContainers) {
            try {
                const likeButton = comment.querySelector('svg[aria-label="Like"]');
                if (likeButton && likeButton.closest('span') && likeButton.getAttribute('fill') !== '#ed4956') {
                    likeButton.closest('span').click();
                    likedCount++;
                    console.log(`❤️ Liked comment #${likedCount}`);
                    await wait(800);
                }
            } catch (err) {
                console.warn('⚠️ Error liking comment:', err);
            }
        }
    }

    async function scrollToLoadMoreComments() {
        const scrollContainer = document.querySelector('div[role="dialog"] ul');
        if (!scrollContainer) return false;

        scrollContainer.scrollTop = scrollContainer.scrollHeight;
        await wait(2000); // Wait for new comments to load

        const newHeight = scrollContainer.scrollHeight;
        const scrolled = newHeight !== previousHeight;
        previousHeight = newHeight;
        return scrolled;
    }

    console.log('🚀 Starting comment like automation...');

    let canScroll = true;
    while (canScroll) {
        await likeVisibleComments();
        canScroll = await scrollToLoadMoreComments();
    }

    console.log(`✅ Done! Liked ${likedCount} comment(s).`);
})();