博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
How to unfollow masively users on Instagram using a little trick with JavaScript in the Browser
阅读量:5979 次
发布时间:2019-06-20

本文共 6342 字,大约阅读时间需要 21 分钟。

 

How to unfollow masively users on Instagram using a little trick with JavaScript in the Browser


Although this article breaks the standards of Our Code World as usually our articles are very technical, it seems to be a good example to learn how to write a very simple automatization script. Many users apply the follow x follow to get a lot of followers, however when you let your account to a "social network manager" and this end up doing the mentioned follow x follow, many users will be angry 'cause of obvious reasons.

The other day, trying to undo such thing on a friend's account decided to write a simple bot script in JS that automatically clicks the unfollow button of the users that the account follows, however wasn't too surprised when i discovered that Instagram has a request limit between every "Unfollow" action. You can't, even with a mobile device and doing it manually, unfollow more than 60 users/hour (trying to do this will end up in 403 responses in the action to unfollow):

Note

Even with the script, you will see someday this error in the console. You will need to wait 10-15 minutes (or less) before running the script again.

Instagram Unfollow 403 error

That's why the script needed to be modified in order to unfollow an user every minute, so it won't be blocked (sometimes it gets blocked as well and you need to wait 10 minutes to run the script again) and i want to share with you this simple script.

Advantages of this approach

  • Instead of unfollow every user manually, you can run the script in the background and let it running for an entire day in the office.
  • The computer unfollows for you, you will only need to inject the script in the browser and that's it.

Limitations

  • Instagram has a known protection algorithm against "bots" and other automatization scripts, like the one that we're writing (even with humans, if you try to unfollow more than 15 users manually from your app or desktop immediately, instagram will impose its limitation). To skip and prevent any error on the script, the logic is to click every Unfollow button every 60 seconds. This will allow you to unfollow so many users as the dialog can list.
  • It is pretty time consuming as you will need a minute for every user that you want to unfollow.

Unfollow script

The following script is the one that does the trick and works as follows:

var jqueryScript = document.createElement('script');jqueryScript.src = "//code.jquery.com/jquery-3.3.1.min.js";jqueryScript.onload = function(){        // Important: change those text according to the text of the following button in your language    // e.g in Spanish it would be "Seguido"    let unfollowButtonText = "Following";    // Recently, a new confirmation dialog appears asking if you really want to unfollow the user    // change this text as well    // e.g in Spanish it would be "Dejar de seguir"    let unfollowConfirmationText = "Unfollow";    // Prepare jQuery Selector for buttons that contain "Following"    let selector = `button:contains('${unfollowButtonText}')`;    // You need to wait 60 seconds after every unfollow, otherwise you will    // be blocked temporary by the Instagram API and you'll see a 403 error in the network !    let currentTime = 0;    let step = 60 * 1000;    // Query the button    let unfollowButtons = $(selector);    // Total of buttons found    let totalUnfollowButtons = unfollowButtons.length;    if(!totalUnfollowButtons){        alert("Error: no Following buttons found, maybe change the text of the button?");    }    // Iterate on every button    unfollowButtons.each(function(index){        let button = $(this);        setTimeout(function(){            (function(i){                console.log(`Unfollowing ${i} of ${totalUnfollowButtons}`);                if(i == totalUnfollowButtons){                    console.log("Script finished succesfully !");                }                button.trigger("click");                // Important: recently, a confirmation dialog was added when  you click                // on unfollow, so simply click the confirmation button as well to unfollow the user                setTimeout(function(){                    var btn = $(`button:contains('${unfollowConfirmationText}')`);                    if(btn){                        btn.trigger("click");                    }                }, 100);            })(index + 1);        }, currentTime);        currentTime += step;    });};// Inject Script !document.getElementsByTagName('head')[0].appendChild(jqueryScript);

How to use it

The execution of the previous script can be done within seconds by only pasting it in the JS console of the browser. If you aren't a developer, we'll guide you through the process:

1. Open Instagram in your desktop/laptop with Google Chrome

As first step you need to open your instagram account in the official website on your desktop computer, where you can open the desktop version of Chrome. After logging in, proceed with the next step.

2. Open Browser Devtools

Open Google Chrome and open the Developer Tools either pressing CTRL + Shift + I or doing right click in the Instagram webpage and selecting from the context menu the Inspect Element Option to open the dev tools. Once it appears, go to the Console tab. Let this window open as we'll inject the script here in the step #4.

3. Open Following List Dialog

As mentioned, the logic of the script is that the script will automatically click every "Unfollow" button of the users on the list of users that you're following. This list is a dialog that can be shown by simply clicking on the Following xx button of your profile:

Following List Dialog Button

This should open a dialog from users that you're currently following:

Open Following List Dialog

Now that you have the dialog of users that you're following, you need to scroll and display all the users that you want to unfollow during the execution of the script. All the buttons with "Following" will be clicked, so the dialog needs to be always opened (recently a new confirmation dialog was added in Instagram, so the script will click that button as well). As next, you will only need to inject the script.

4. Inject Script

Copy the code at the beginning of the article and paste it into the console, then press enter to execute the code and the unfollow process will start:

Unfollow Massive Instagram

The script automatically shows in the console the progress and says when the process finishes or if there's any error (read initial warning).

Happy unfollowing !

 

转载于:https://www.cnblogs.com/eYeah/p/9597559.html

你可能感兴趣的文章
正确释放WORD对象(COM组件) COMException: 被调用的对象已与其客户端断开连接
查看>>
重谈设计
查看>>
mac 查看python路径
查看>>
【转】asm.js 和 Emscripten 入门教程
查看>>
office2007word文档设置多级目录
查看>>
SASS详解之编译输出的样式
查看>>
利用内存分析工具(Memory Analyzer Tool,MAT)分析java项目内存泄露
查看>>
linux查看CPU性能及工作状态的指令mpstat,vmstat,iostat,sar,top
查看>>
论iOS开发与Android开发的前景与薪资水平
查看>>
三叶虫为什么可以成为地球生物圈的第一个霸主?
查看>>
聚焦数据智能,袋鼠云亮相2018云栖大会
查看>>
华为发布首款全面屏+四摄手机 主流手机市场迎新貌
查看>>
智慧城市物联网收入将在2026年达620亿美元
查看>>
NBA公布新秀赛名单:塔图姆、西蒙斯领衔 欧文成教练
查看>>
120幅中国近现代国画大师真迹长沙展出
查看>>
中诚信报告预计2019年中国GDP增长率约6.3%
查看>>
DataCamp推出的Python数据科学速查表,已经翻译成中文啦!
查看>>
Python开发必备利器之Virtual Environment
查看>>
这是一条保证看饿的消息 老字号天福号280岁了!
查看>>
RSAC 2018:人工智能成为驱动网络安全的新 “引擎”
查看>>