Hi all, in this article I will share with you a story. This story comprises a problem and also its solution. 🙂 I joined too many social groups on a social media platform without my acceptance and information. When I realized this situation, I tried to unfollow those groups but doing this operation manually was a nightmare. Thus, I wrote a simple script by using XPath selector and JQuery and execute via the Console and the result was awesome. With a single click, I unfollowed all groups. 🙂

You can find the magical script below. You can also modify and use this in this kind of situations.

Here is the flow:

  • I wrote a while loop by using JQuery to click all the links
  • I locate the links which comprise of “Unfollow” text by using XPath (//a[text()=’Unfollow’]).
  • I need to wrap that XPath locator by $x(“XPATH Locator”)
  • Then, I select specific element with [$index] 
  • Then, I need to click that element by using .click() method.
  • Final statement is $x(“//a[text()=’Unfollow’]”)[y].click();

Here is the result:

The script, clicked all 153 Unfollow links and I Unfollowed the all the groups. 🙂

See you in the next article.