Facebook logo

Automating 2 common facebook actions using bookmarklets

This article presents 2 different bookmarklets (and their source code) we cas use to automate 2 common facebook actions:

  1. Getting all the names that have shared a specific picture
  2. Ticking all the names in a friends list window, when the select all option is not available (e.g. when sharing events)

What’s a bookmarklet?

Bookmarklets are ‘smart bookmarks’, that perform actions or enhance the website you’re visiting with a single click. They are written in JavaScript and can be as simple as one line of code.

To add a bookmarklet to your web browser just drag it to the book mark bar. For detailed information on how to add a bookmarklet to your web browser, click here. Below the bookmarklets are presented like buttons. You just drag and drop the appropriate button to your bookmark bar.

Getting a list of all the people that have shared something in Facebook

First you have to open the list of shares by clicking on the “Show shares” link:

When the windows that shows all the people that have shared your content appears, scroll down to the end of the list to make sure that all tha names have been loaded. Then just click on the following bookmarklet in your bookmark bar:

Get FB shares

The source code behind this bookmarklet is the following:

var lis = document.getElementById('share_feed').getElementsByClassName('passiveName');
for (var i = 0; i < lis.length; i++) {
alert('Done, check your console window');

“Invite all people” action

To invite all your contacts, when the select contas facebook window appears, follow the steps below:

  1. Scroll down to the end of the list of people to make sure that all of them have been loaded
  2. Click on the bookmarklet below inyour bookmark bar

Invite all

The source code behind this bookmarklet is the following:

var x=document.getElementsByTagName("input");
for(var i=0;i  if (x[i].type == 'checkbox') {
alert('Done, all your friends have been selected');

Written By

Panagiotis (pronounced Panayotis) is a passionate G(r)eek with experience in digital analytics projects and website implementation. Fan of clear and effective processes, automation of tasks and problem-solving technical hacks. Hands-on experience with projects ranging from small to enterprise-level companies, starting from the communication with the customers and ending with the transformation of business requirements to the final deliverable.