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:
- Getting all the names that have shared a specific picture
- 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:
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++) { console.debug(lis[i].text); } 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:
- Scroll down to the end of the list of people to make sure that all of them have been loaded
- Click on the bookmarklet below inyour bookmark bar
The source code behind this bookmarklet is the following:
var x=document.getElementsByTagName("input"); for(var i=0;i if (x[i].type == 'checkbox') { x[i].click(); } }; alert('Done, all your friends have been selected');