├── README.md ├── conf.js └── spec.js /README.md: -------------------------------------------------------------------------------- 1 | # InstagramFirstCommenter 2 | This is a bot that will make a comment on a post as soon as it is posted on instagram. Just follow the setup instructions and replace the dummy data by a valid instagram account data for it to work. 3 | 4 | I created this to win tickets for [Vodafone Paredes de Coura](https://www.paredesdecoura.com/). Vodafone had an contest where they posted a total of 8 posts on their instagram page at random times of the day during 2 weeks, this first 10 people to comment those posts won 200 euros worth of tickets for their music festival. This bot did its job and won those tickets. 5 | 6 | # Requirements 7 | 1 - A Windows, Mac or Linux Computer 8 | 9 | 2 - Google Chrome installed 10 | 11 | # Setup 12 | This bot is based on [protractor](https://www.protractortest.org/#/) automated browser testing software. 13 | ### 1 - Open a terminal an make sure you are in the project directory 14 | cd InstagramFirstCommenter 15 | 16 | ### 2 - Make sure you have protractor installed 17 | To check if you have protractor installed run: 18 | 19 | protractor --version 20 | If the output is something like this: 21 | 22 | Version 5.4.0 23 | This means protractor is already installed, otherwise run the command: 24 | 25 | npm install -g protractor 26 | 27 | ### 3 - Install Selenium Webdriver 28 | This is where your program will run, to install it simply execute the command: 29 | 30 | webdriver-manager 31 | 32 | ### 4 - Input valid instagram account credentials 33 | For this bot to work you need to give it an instagram account for it to login into instagram. This can be your personal account, a friend's account or even create an account for this purpose, whatever. 34 | 35 | Go to the file spec.js and change this code with your account login information: 36 | 37 | // My instagram user information 38 | const myUsername = 'myEmail@gmail.com'; 39 | const myPassword = 'myPassword123'; 40 | 41 | ### 5 - Choose the page you want to target 42 | Again, go to spec.js and change this code with the information of the page you want to target, the current amount of posts it has and the comment you want to write: 43 | 44 | // Target page 45 | const targetURL = 'https://www.instagram.com/myTargetPage'; 46 | var numberOfPostsOnTargetProfile = 69; 47 | const commentText = 'This is the comment I am posting'; 48 | 49 | Done, your bot is ready to roll. 50 | 51 | # Running the bot 52 | 53 | ### 1 - Start the Selenium webserver 54 | Open a terminal an make sure you are in the project directory: 55 | 56 | cd InstagramFirstCommenter 57 | 58 | Update and start the server: 59 | 60 | webdriver-manager update 61 | webdriver-manager start 62 | 63 | ### 2 - Run the bot 64 | With the previous terminal still open and running open another terminal an make sure you are in the project directory: 65 | 66 | cd InstagramFirstCommenter 67 | 68 | Run the bot: 69 | 70 | protractor conf.js 71 | 72 | # About the bot 73 | The bot will login once into instagram and go to the target page. 74 | 75 | It will then keep refreshing the page every 2.5 seconds while there is no new post. 76 | 77 | Once there is a new post it will open said post and comment what you previously defined. 78 | 79 | It will then keep refreshing the page until there is a new post and it will always comment that same text. 80 | 81 | To stop the bot you can, in the bot's terminal, press Ctr+C and then y and the Enter. Or you can wait until it does all the iterations, by default it is set to 30000 iterations which is equivalent to aproximately 21 hours. 82 | -------------------------------------------------------------------------------- /conf.js: -------------------------------------------------------------------------------- 1 | 2 | exports.config = { 3 | framework: 'jasmine', 4 | seleniumAddress: 'http://localhost:4444/wd/hub', 5 | specs: ['spec.js'], 6 | multiCapabilities: [ 7 | { 8 | browserName: 'chrome' 9 | } 10 | ] 11 | } 12 | -------------------------------------------------------------------------------- /spec.js: -------------------------------------------------------------------------------- 1 | 2 | // This bot will post a predefined comment as fast as possible to a new post on the target profile 3 | describe('Instagram fast commenter', function() { 4 | 5 | // Edit the information bellow! 6 | // Target page 7 | const targetURL = 'https://www.instagram.com/myTargetPage'; 8 | // You need to change this information before running the script! 9 | var numberOfPostsOnTargetProfile = 69; 10 | const commentText = 'This is the comment I am posting'; 11 | // My instagram user information 12 | const myUsername = 'myEmail@gmail.com'; 13 | const myPassword = 'myPassword123'; 14 | // Number of times the page should refresh 15 | // Each iteration takes around 2.5 seconds 16 | // Recommended value: 30000 17 | // 30000 iterations take aproximately 21 hours to complete ((2.5*30000)/3600) = 20.88 hours 18 | var numberOfIterations = 30000; 19 | 20 | // Do not edit the information bellow! 21 | var numberOfCommentsPosted = 0 22 | 23 | // This code runs once for loging into your account 24 | browser.driver.get('https://www.instagram.com/accounts/login/'); 25 | browser.driver.sleep(1000); 26 | browser.driver.findElement(by.css('[name="username"]')).sendKeys(myUsername); 27 | browser.driver.findElement(by.css('[name="password"]')).sendKeys(myPassword); 28 | browser.driver.findElement(by.xpath('//*[@id="react-root"]/section/main/div/article/div/div[1]/div/form/div[4]/button')).click(); 29 | browser.driver.sleep(2000); 30 | browser.driver.get(targetURL); 31 | browser.driver.sleep(2000); 32 | 33 | // Main function that runs in loop 34 | function instaAutoCommenter(numberOfIterations){ 35 | it('should win me a ticket for that cool music festival', function() { 36 | 37 | browser.driver.findElement(by.xpath('//*[@id="react-root"]/section/main/div/header/section/ul/li[1]/span/span')).getText().then( (numberOfPostsString) => { 38 | // Log run information at each interation 39 | console.log('\nCurrent iteration: ' + (30000 - numberOfIterations) + ' / 30 000'); 40 | console.log('Number of comments posted: ' + numberOfCommentsPosted); 41 | console.log('Current number of posts on page: ' + numberOfPostsString); 42 | 43 | // Convert value of posts on target profile from string to int 44 | var numberOfPostsInt = numberOfPostsString.replace('.',''); 45 | numberOfPostsInt.replace(' ',''); 46 | numberOfPostsInt = parseInt(numberOfPostsInt, 10); 47 | 48 | if(numberOfPostsInt != numberOfPostsOnTargetProfile){ 49 | browser.driver.sleep(1500); 50 | browser.driver.findElement(by.css('._9AhH0')).click(); 51 | browser.driver.sleep(1500); 52 | browser.driver.findElement(by.css('.Ypffh')).click(); 53 | browser.driver.sleep(200); 54 | browser.driver.findElement(by.css('.Ypffh')).sendKeys(commentText); 55 | browser.driver.findElement(by.css('.Ypffh')).sendKeys(protractor.Key.ENTER); 56 | browser.driver.sleep(2000); 57 | numberOfPostsOnTargetProfile++; 58 | numberOfCommentsPosted++; 59 | } 60 | browser.driver.sleep(2500); 61 | browser.driver.get(targetURL); 62 | 63 | }); 64 | 65 | }); 66 | } 67 | 68 | // Very long loop 69 | while(numberOfIterations > 0){ 70 | instaAutoCommenter(numberOfIterations); 71 | if(numberOfIterations != 0){ 72 | numberOfIterations--; 73 | } 74 | } 75 | 76 | }); 77 | --------------------------------------------------------------------------------