Advertisement
AndhikaNurdyans

Autounfollow

Oct 18th, 2018
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var jqueryScript = document.createElement('script');
  2. jqueryScript.src = "//code.jquery.com/jquery-3.3.1.min.js";
  3. jqueryScript.onload = function(){
  4.    
  5.     // Important: change those text according to the text of the following button in your language
  6.     // e.g in Spanish it would be "Seguido"
  7.     let unfollowButtonText = "Following";
  8.     // Recently, a new confirmation dialog appears asking if you really want to unfollow the user
  9.     // change this text as well
  10.     // e.g in Spanish it would be "Dejar de seguir"
  11.     let unfollowConfirmationText = "Unfollow";
  12.  
  13.     // Prepare jQuery Selector for buttons that contain "Following"
  14.     let selector = `button:contains('${unfollowButtonText}')`;
  15.  
  16.     // You need to wait 60 seconds after every unfollow, otherwise you will
  17.     // be blocked temporary by the Instagram API and you'll see a 403 error in the network !
  18.     let currentTime = 0;
  19.     let step = 60 * 1000;
  20.  
  21.     // Query the button
  22.     let unfollowButtons = $(selector);
  23.     // Total of buttons found
  24.     let totalUnfollowButtons = unfollowButtons.length;
  25.  
  26.     if(!totalUnfollowButtons){
  27.         alert("Error: no Following buttons found, maybe change the text of the button?");
  28.     }
  29.  
  30.     // Iterate on every button
  31.     unfollowButtons.each(function(index){
  32.         let button = $(this);
  33.  
  34.         setTimeout(function(){
  35.             (function(i){
  36.                 console.log(`Unfollowing ${i} of ${totalUnfollowButtons}`);
  37.  
  38.                 if(i == totalUnfollowButtons){
  39.                     console.log("Script finished succesfully !");
  40.                 }
  41.  
  42.                 button.trigger("click");
  43.  
  44.                 // Important: recently, a confirmation dialog was added when  you click
  45.                 // on unfollow, so simply click the confirmation button as well to unfollow the user
  46.                 setTimeout(function(){
  47.                     var btn = $(`button:contains('${unfollowConfirmationText}')`);
  48.  
  49.                     if(btn){
  50.                         btn.trigger("click");
  51.                     }
  52.                 }, 100);
  53.             })(index + 1);
  54.         }, currentTime);
  55.  
  56.         currentTime += step;
  57.     });
  58. };
  59.  
  60. // Inject Script !
  61. document.getElementsByTagName('head')[0].appendChild(jqueryScript);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement