├── LICENSE.md ├── instagram_unfollow_script.js └── README.md /LICENSE.md: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 Predrag Bradaric 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. -------------------------------------------------------------------------------- /instagram_unfollow_script.js: -------------------------------------------------------------------------------- 1 | var ufwTotalCounter = 0; 2 | var ufwCounter = 0; 3 | var maxUfwsPerBatch = 13; 4 | var fwDialogSelector = "._4gt3b"; 5 | var fwButtonSelector = "._cx1ua button:contains('Following')"; 6 | var delayBetweenUfwClicks = 4000; 7 | var delayRandomness = 4000; 8 | var delayBetweenUfwBatches = 600000; 9 | 10 | var script = document.createElement("script"); 11 | script.src = "https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.1/jquery.min.js"; 12 | document.getElementsByTagName('body')[0].appendChild(script); 13 | 14 | function unfollow() { 15 | var delay = 5000; 16 | if (ufwCounter < maxUfwsPerBatch) { 17 | if (jQuery(fwButtonSelector).length) { 18 | jQuery(jQuery(fwButtonSelector)[0]).click(); 19 | ufwCounter++; 20 | ufwTotalCounter++; 21 | console.log("Unfollowed " + ufwTotalCounter + " person(s)"); 22 | } else { 23 | jQuery(fwDialogSelector).scrollTop(100000000); 24 | console.log("No more 'Follow' buttons. Scrolling down."); 25 | } 26 | delay = Math.random() * delayRandomness + delayBetweenUfwClicks; 27 | } else { 28 | ufwCounter = 0; 29 | delay = delayBetweenUfwBatches; 30 | console.log("Pausing with execution for " + delay/1000 + " seconds..."); 31 | } 32 | setTimeout(function() { 33 | unfollow(); 34 | }, delay); 35 | } 36 | 37 | function waitForjQuery(callback) 38 | { 39 | if ( !window.jQuery ) { 40 | setTimeout(function() { 41 | waitForjQuery(callback); 42 | }, 50); 43 | } else { 44 | callback(); 45 | } 46 | } 47 | 48 | waitForjQuery(function() { 49 | if (!jQuery(fwDialogSelector).length) { 50 | alert("Open the 'Following' dialog!"); 51 | } 52 | unfollow(); 53 | }); -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Instagram Unfollow Script 2 | 3 | ## About 4 | This Javascript snippet automatically unfollows everyone in your Instagram account. It is designed to be used in the Javascript browser console - just copy/paste it (while you are logged into your Instagram account - you have to be on the profile page) and that's it. The speed of the unfollow events is ~67 unfollows per hour. 5 | 6 | ## Usage 7 | 1. Log into your Instagram account 8 | 2. Go to your Profile page 9 | 3. Open the "Following" dialog (by clicking on the line that says "NNN following" - where "NNN" is the number of the people you are following at the moment) 10 | 4. Open browser's developer tools (hit F12 - for Google Chrome and Firefox) and click on the "Console" tab 11 | 5. Copy/paste this Javascript snippet to the "Console" dialog in the browser 12 | 6. That's it - the script should start unfollowing people one by one, slowly (~67 unfollows per hour) 13 | 14 | ## History 15 | Instagram has a time-based limitation on follow/unfollow events. I was specifically interested in unfollow events and at the moment (2. February 2017.) it's ~70 unfollows per hour. 16 | I created this script because my Instagram account was hacked and someone followed ~1400 people with it. Because of the time-based limitation stated above, it's really difficult to correct this issue by hand. Hence, I decided to automate the task using Javascript via browser's developer tools. 17 | 18 | ## Possible Issues 19 | - The script assumes that the "Following" dialog has a class of a certain name (defined in the script as `fwDialogSelector`). That name might be unique on a per user basis - I'm not sure since I didn't have the time to test that. If the script is not doing anything then inspect the DOM tree and see if the "Following" DOM element has a sub-element with the specified class (this can be done quickly using the jQuery command in the "Console" window). 20 | - The script also assumes that the "Unfollow" button has a class of a certain name (defined in the script as `fwButtonSelector`). The story is the same as in the previous case with `fwDialogSelector` (above). 21 | 22 | ## How It Works 23 | The script first imports jQuery Javascript library by injecting the `