Simple Instagram Like Bot

This is a very simple Instagram like bot written in JavaScript. It’s described in more detail in the Making Web Bots zine that I’m currently working on. If you’re interested in the zine, which will cost $10, please email me.

JavaScript Version

This script takes a little work but it’s free. Here are the steps to use the JavaScript version of this Instagram like bot.

  • Highlight and copy the entire code block below
  • Open your browser and visit intagram.com
  • Enter a hash tag in the search box
  • Open the first post under “Most Recent”
  • Open the JavaScript console in your browser
  • Paste this code into the console

The code is below. Because of frequent changes at Instagram this code is sometimes broken. Instagram is also cracking down on bot use like this and there is some risk to your Instagram account. Use this script at your own risk or see the Chrome extension listed above for a safer option.

function getHeartElement() {
    var knownHeartElementNames = ["coreSpriteHeartOpen", "coreSpriteLikeHeartOpen"];
    var i = 0;
    // Loop through the known heart elements until one works
    for (i = 0; i < knownHeartElementNames.length; i++) {
        var heartElement = document.querySelector("." + knownHeartElementNames[i]);
        if (heartElement != undefined) {
            break;
        }
    }
    return heartElement;
}

function doLike() {
    var likeMax = 100;
    var likeElement = getHeartElement();
    var nextElement = document.querySelector(".coreSpriteRightPaginationArrow");
    likeCount++;
    var nextTime = Math.random() * (14000 - 4000) + 4000;
    if (likeElement.innerHTML.match("Unlike") == null) {
        likeElement.click();
        console.log(likeCount + " - liked");
    } else {
        console.log(likeCount + " - skipped");
    }
    setTimeout(function() {nextElement.click();}, 1000);
    if (likeCount < likeMax) {
        setTimeout(doLike, nextTime);
    } else {
        console.log("Nice! Time for a break.");
    }
}

var likeCount = 0;
doLike();

This code is also available in my web-bots repo on GitHub. If you’d like to contribute changes, please submit a pull request.

Opening the Console

The easiest way to open the javascript console is using the shortcut key combination. Here are the key combinations for several popular browsers.

Browser Keys
Google Chrome for Mac //command//, //option//, //J//
Firefox for Mac //command//, //option//, //K//
Safari for Mac //command//, //option//, //C//
Google Chrome for Windows //control//, //shift//, //J//
Firefox for Windows //control//, //shift//, //I//
Google Chrome for Linux //control//, //shift//, //J//
Firefox for Linux //control//, //shift//, //I//

Legacy Version

This is a very simple Instagram like bot written for the iMacros plugin. The plugin is available for IE, Chrome, and Firefox. This version is out of date and, although shorter, is much more complicated to use than the version above; use that instead.

Getting Ready

In order to run this bot you need to install the iMacros plugin for your browser platform. Here are the links for Chrome and Firefox (it’s also available for IE but you’ll have to search for that one yourself).

iMacros for Chrome
iMacros for Firefox

Running the Bot

In order to use the bot, do the following:

  • Open Instagram in your browser
  • Search for a specific tag you want
  • Click on the first image
  • Open the iMacros plugin in your browser
  • Run the bot with the “Play Loop” option

The Macro Code

iMacros scripts are stored in the browser as bookmarks, so you’ll want to save the script before you can use it. To start a new script hit “Record” and then stop. Overwrite the macro with the code below then save it with a name like “Instagram Like Bot”.

Here’s the code for the bot itself.

SET !VAR1 EVAL("var randomNumber=Math.floor(Math.random()*5 + 3); randomNumber;")
TAG POS=1 TYPE=A ATTR=TXT:Like
TAG POS=1 TYPE=A ATTR=TXT:Next
WAIT SECONDS={{!VAR1}}

Features

  • Very simple script
  • Random pauses so it acts like a human
  • You can watch it run
  • You can run it in a background tab

2 thoughts on “Simple Instagram Like Bot

  1. Hi Joel, noticed that you have just changed the first code above to what looks like a more updated version. However, it is not immediately clear for noobs like me how many times this code will run (unlike the previous code where it is clear that it will run for 25 times). I understand that the Math Random line is for duration between the loops, but how can I change how many times the loop is run? P.S. I tried changing ‘1000’ to ‘5’ but it still ran more than 5 times. Thanks.

    1. It’s the following line that tells it how many times to loop. This updated version loops 100 times by default. Be careful with this setting; if you go too high Instagram might detect you as a bot and limit your account. In my experience, the limits are temporary but don’t abuse it.

      var likeMax = 100;

Leave a Reply

Your email address will not be published. Required fields are marked *