آنفالو (unfollow) در توییتر به شرط فالو (follow) نکردن شما با جاوا اسکریپت

آنفالو (unfollow) در توییتر به شرط فالو (follow) نکردن شما با جاوا اسکریپت

شاید برای شما هم اتفاق افتاده که وقتی در توییتر هستید شاید نیاز دارید افرادی که شما فالو کردید ولی شمارو فالو نکردند یا به عبارتی بک ندادند رو شما هم آنفالو کنید اوایل که وارد توییتر بشید این مشکل نیست براتون چون تعداد فالور ها کمه و خیلی راحت میتونید افراد رو در لیست following خودتون پیدا کنید و اقدام به آنفالو کردن کنید. (آنفالویاب)

زمان مطالعه: 3 دقیقه
بازدید: 3277
پرسش و پاسخ: 6

آنفالو در توییتر

تا اینجای کار مشکلی نبود !

اما وقتی تعداد فالوورهاتون بالا بره با مشکل جدی برخورد میکنید چون نمیتونید چند ساعت وقت بزارید و داخل 10000 فالوور این افراد رو پیدا کنید.

چیزی که اینجا دارم توضیح میدم از طریق وب قابل انجام هست و شما برای برنامه های دیگه باید سراغ کد دیگه ای برید

و نکته های بعدی اینکه این کد جاوا اسکریپت هستش و در محیط کنسول مرورگر کروم اجرا شده!

من پیش فرض رو گذاشتم رو این مسئله که شما با جاوا اسکریپت آشنایی دارید و میتونید کدهارو متوجه بشید البته این کدهارو من ننوشتم و فقط با تغییری کوچک در اختیار شما قرار میدم و اینکه تست کردم و نتیجه گرفتم.

خب اول کد زیر رو کپی کنید

var LANGUAGE = "EN"; //NOTE: change it to use your language!
var WORDS =
{
	//English language:
	EN:
	{
		followsYouText: "Follows you", //Text that informs that follows you.
		followingButtonText: "Following", //Text of the "Following" button.
		confirmationButtonText: "Unfollow" //Text of the confirmation button. I am not totally sure.
	},
	//Spanish language:
	ES:
	{
		followsYouText: "Te sigue", //Text that informs that follows you.
		followingButtonText: "Siguiendo", //Text of the "Following" button.
		confirmationButtonText: "Dejar de seguir" //Text of the confirmation button. I am not totally sure.
	}
	//NOTE: if needed, add your language here...
}
var SKIP_USERS = //Users that we do not want to unfollow (even if they are not following you back):
[
	//Place the user names that you want to skip here (they will not be unfollowed):
	"user_name_to_skip_example_1",
	"user_name_to_skip_example_2",
	"user_name_to_skip_example_3"
];
SKIP_USERS.forEach(function(value, index) { SKIP_USERS[index] = value.toLowerCase(); }); //Transforms all the user names to lower case as it will be case insensitive.


//Function that unfollows non-followers on Twitter:
var usersFollowingMe = function(followsYouText, followingButtonText, confirmationButtonText)
{
	var nonFollowers = 0;
	followsYouText = followsYouText || WORDS.EN.followsYouText; //Text that informs that follows you.
	followingButtonText = followingButtonText || WORDS.EN.followingButtonText; //Text of the "Following" button.
	confirmationButtonText = confirmationButtonText || WORDS.EN.confirmationButtonText; //Text of the confirmation button.
	
	//Looks through all the containers of each user:
	var userContainers = document.querySelectorAll('[data-testid=UserCell]');
	Array.prototype.filter.call
	(
		userContainers,
		function(userContainer)
		{
			//Checks whether the user is following you:
			var followsYou = false;
			Array.from(userContainer.querySelectorAll("*")).find
			(
				function(element)
				{
					if (element.textContent === followsYouText) { followsYou = true; }
				}
			);

			//If the user is not following you:
			if (!followsYou)
			{
				//Finds the user name and checks whether we want to skip this user or not:
				var skipUser = false;
				Array.from(userContainer.querySelectorAll("[href^='/']")).find
				(
					function (element)
					{
						if (element.href.indexOf("search?q=") !== -1 || element.href.indexOf("/") === -1) { return; }
						var userName = element.href.substring(element.href.lastIndexOf("/") + 1).toLowerCase();
						Array.from(element.querySelectorAll("*")).find
						(
							function (subElement)
							{
								if (subElement.textContent.toLowerCase() === "@" + userName)
								{
									if (SKIP_USERS.indexOf(userName) !== -1)
									{
										console.log("We want to skip: " + userName);
										skipUser = true;
									}
								}
							}
						)
					}
				);
				
				//If we do not want to skip the user:
				if (!skipUser)
				{
					//Finds the unfollow button:
					Array.from(userContainer.querySelectorAll('[role=button]')).find
					(
						function(element)
						{
							//If the unfollow button is found, clicks it:
							if (element.textContent === followingButtonText)
							{
								element.click();
								nonFollowers++;
							}
						}
					);
				}
			}
		}
	);
	
	//If there is a confirmation dialog, press it automatically:
	Array.from(document.querySelectorAll('[role=button]')).find //Finds the confirmation button.
	(
		function(element)
		{
			//If the confirmation button is found, clicks it:
			if (element.textContent === confirmationButtonText)
			{
				element.click();
			}
		}
	);
	
	return nonFollowers; //Returns the number of non-followers.
}


//Scrolls and unfollows non-followers, constantly:
var scrollAndUnfollow = function()
{
	window.scrollTo(0, document.body.scrollHeight);
	usersFollowingMe(WORDS[LANGUAGE].followsYouText, WORDS[LANGUAGE].followingButtonText, WORDS[LANGUAGE].confirmationButtonText); //For English, you can try to call it without parameters.
	setTimeout(scrollAndUnfollow, 10);
};
scrollAndUnfollow();

بعد از صفحه inspect بگیرید و در تب کنسول کد بالارو کپی کنید سپس کلید enter را بزنید

کد آنفالو توییتر

صفحه شما اسکرول میشه و اتوماتیک کسانی که شمارو فالو نکردن آنفالو خواهند شد

اگر سوالی دارید میتونید کامنت بزارید

بهزاد میرزازاده
مسیر درست با پرسش های درست ساخته می شود

مشاهده تمام مطالب نویسنده