Instagram Auto Comment Liker

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

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 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).`);
})();