/** * How to use * 1. Open developer tools in browser * 2. Go to network tab * 3. Go to the post you want to comment and post a comment * 4. Search for the request called "add" and copy the cookies, csrf token, app id, www claim, asbd id and post id * 5. Paste the cookies, csrf token, app id, www claim, asbd id and post id in the variables * 6. Paste the users in the users array * 7. Run the script. * * Happy commenting 🥰 */ const axios = require("axios"); const users = []; //All users to be tagged const usersChunck = chunk(users, 2); //Users chunked into arrays of 2 function chunk(list, size) { const chunks = []; for (let i = 0; i < list.length; i += size) { chunks.push(list.slice(i, i + size)); } return chunks; } let lastIndex = 0; async function init() { console.log("Starting"); const chunkUsers = usersChunck[lastIndex].map((user) => `@${user}`).join(" "); console.log("Sending", chunkUsers); let cookies = ""; //Cookies copied from browser let Cookies = ""; //Cookies copied from browser let csrftoken = ""; //csrf token copied from browser let appId = ""; //app id token copied from browser let wwwClaim = ""; //claim token copied from browser let asbdId = ""; //asbd id token copied from browser const postId = ""; //Post id copied from browser request var options = { method: "POST", url: `https://i.instagram.com/api/v1/web/comments/${postId}/add/`, headers: { "Content-Type": "application/x-www-form-urlencoded", cookie: cookies, Cookie: Cookies, "x-csrftoken": csrftoken, "x-ig-app-id": appId, "x-ig-www-claim": wwwClaim, "x-asbd-id": asbdId, "user-agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/106.0.0.0 Safari/537.36", "sec-fetch-mode": "cors", }, data: { comment_text: chunkUsers }, }; axios .request(options) .then(function (response) { console.log(response.data); lastIndex++; setTimeout(() => { init(); }, 5000); }) .catch(function (error) { console.error(error.data); }); } init();