
While working on the next version of my Facebook Profile Cleaner, I noticed something that I was doing. Every time I would log into Facebook, I would have 3-5 new application invites. Personally, I don’t care too much about them (if you didn’t know already). I set out to see if I could come up with a way to automatically block them upon sign on/request.
That task seemed pretty easy, but it didn’t turn out to be. First of all, Facebook hides their “Block Application” button on you. The first place you see it is on the application’s page itself. Second, on the user’s request page it only shows an add and ignore. If you click ignore, it ignores that specific request, not any future ones. This gets real annoying when a ton of your friends decide to add (and send you requests) of the same application. And third, I was worried that maybe I would want to remove a block later. However Facebook was kind enough to provide a page to “remove” blocked applications. By going to http://facebook.com/privacy.php?view=platform&tab=all, the second half of the page will list applications you have blocked. Notice they are listed by the order they were blocked; most recently blocked will be on the bottom.
That being said, I set out to actually block each application invite I get. After a few hours here and there, I finally got it fully working. The code should be clean enough for anyone interested enough to walk though. But note that if you just want the application and don’t care for the actual code, then just install it and be on your merry way :).
If you have any suggestions, comments, or concerns, be sure to comment below.
To use this script, you need Greasemonkey addon. Once you have it, just go here and click install: http://userscripts.org/scripts/show/12393 or http://karbassi.com/scripts/greasemonkey/autoblockfacebookapps10.user.js.
Here’s the code:
// Auto-Block Facebook Apps // // Version 1.0 // // Date Written: 2007-09-18 // Last Modified: 2007-09-19 12:51 PM (12:51) // // (c) Copyright 2007 Ali Karbassi. // Released under the GPL license // http://www.gnu.org/copyleft/gpl.html // // -------------------------------------------------------------------- // // This is a Greasemonkey user script. // // To install, you need Greasemonkey: http://greasemonkey.mozdev.org/ // Then restart Firefox and revisit this script. // Under Tools, there will be a new menu item to "Install User Script". // Accept the default configuration and install. // // To uninstall, go to Tools/Manage User Scripts, // select "Auto-Block Facebook Apps", and click Uninstall. // // -------------------------------------------------------------------- // // WHAT IT DOES: // After the facebook profile page is loaded, it finds all the // applications that your friends have invited you to and blocks them. // Do not worry though, you can go to // http://facebook.com/privacy.php?view=platform&tab=all and unblock // them // // NOTE: This does not alter, delete, edit, add, or anything else to // your facebook profile. Just remove or disable this script and // everything will be displayed the same as it used to // -------------------------------------------------------------------- // // ==UserScript== // @name Auto-Block Facebook Apps 1.0 // @author Ali Karbassi // @namespace http://www.karbassi.com // @description This script will block app invites sent to you by friends. After the facebook profile page is loaded, it finds all the applications that your friends have invited you to and blocks them. Do not worry though, you can go to http://facebook.com/privacy.php?view=platform&tab=all and unblock them. // @include http://facebook.com/home.php* // @include http://*.facebook.com/home.php* // @include http://facebook.com/reqs.php* // @include http://*.facebook.com/reqs.php* // ==/UserScript== // Find Subdomain var subDomain = getSubDomain(); // Get links on the front page/request page var anchors = document.getElementsByTagName('a'); var appReqExp = /reqs\.php#confirm_(\d*)_(.*)/; for( var i = 0; i < anchors.length; i++ ) { if( appReqExp.exec( anchors[i].href ) ) { prep(RegExp.$1, anchors[i]); } } // Remove any notifications about apps. removeNotifications(); // Functions // PLEASE DO NOT TOUCH IF YOU HAVE NO IDEA WHAT YOU'RE DOING. YOU MIGHT BREAK IT. // Prepares everything. When things are correct, it calls BlockApp. function prep(appID, appNode) { var postformMatch = /name="post_form_id" value="(\w+)"/; var post_form_id = 0; GM_xmlhttpRequest( { method: 'GET', url: 'http://www.facebook.com/apps/block.php?id=' + appID + '&action=block', headers: { 'User-Agent': window.navigator.userAgent, 'Accept': 'text/html', }, onload: function(responseDetails) { if( (responseDetails.status == 200) && (responseDetails.responseText.indexOf('This will not prevent you from seeing') != -1) ) { // Show that we are working on it. appNode.removeAttribute('href'); appNode.innerHTML = 'Reading confirmation page...'; postformMatch.exec( responseDetails.responseText ); // Calls function to block the app BlockApp(RegExp.$1, appID, appNode); } } } ); } function BlockApp(post_form_id, appID, appNode) { GM_xmlhttpRequest( { method: 'POST', url: 'http://' + subDomain + 'facebook.com/apps/block.php?id=' + appID + '&action=block', headers: { 'User-Agent': window.navigator.userAgent, 'Accept': 'text/xml', 'Content-Type': 'application/x-www-form-urlencoded', }, data:'post_form_id=' + post_form_id + '&save=1', onload: function (responseDetails) { if( (responseDetails.status == 200) && (responseDetails.responseText.indexOf('You have blocked this application') != -1) ) { appNode.innerHTML = 'App Blocked!' appNode.href = 'http://facebook.com/reqs.php'; } }, onerror: function (responseDetails) { appNode.removeAttribute('href'); appNode.innerHTML = 'App Block failed!'; } } ); } function removeNotifications() { var inputs = document.getElementsByTagName('input'); for (var i = 0; i < inputs.length; i++) { if( inputs[i].value == 'Ignore' ) { for( var j = 0; j < inputs[i].attributes.length; j++) { if( (inputs[i].attributes[j].nodeName == 'onclick') && (inputs[i].attributes[j].nodeValue.indexOf('click_add_platform_app') != -1) ) { var js = (inputs[i].attributes[j].nodeValue).split(' '); js.shift(); js = js.join(' '); location.href = 'javascript:' + js; } } } } } function getSubDomain() { var subDomainRegExp = /http:\/\/(.*\.)facebook\.com/; var subDomain = ''; if (subDomainRegExp.exec(document.location) != 0) { subDomain = RegExp.$1; } return subDomain; }
Cool.
Did you just figure all of this removal code out by looking at the HTML and DOM for the relevant facebook pages, or did it require some knowledge of the facebook APIs (which I know very little about, so that may be a stupid question)?
I feel your pain on this whole Facebook as an application platform issue. I sit somewhere in the middle I think. It’s a really great idea, and maybe it will make Zuckerberg some money - but almost every application I’ve seen and been “invited” to start using is total crap, and now the usefulness of Facebook has been severely diluted. For instance, a lot of people have the “Funwall” application now - so now there are two walls to write on on their profile, and most people don’t even scroll all the way down to see the original wall. Lame.
Ah well. I still mostly use Facebook to check peoples contact info when I need it. (See, now there is a good facebook app idea - one that prints out a report of all of your friends contact info in a table format - email, phone, etc).
I’ve always wanted to take a look at greasemonkey - it’s like the last “nerd must have” firefox extension that I don’t have. :-) Maybe this will be the spark I need.
@Adam:
Well, I knew that the process that it took to block one application, so I figured out a way to do it automatically.
Basically, I opened up the source, figured out where it was going, and well, did it. I’m not the best at explaining things, that’s why the code is up there.
Mind Mining Medium » Automatically Block Facebook Applications
[...] et si vous voulez automatiser le rejets d’invitation et le blocage des applications, il un autre script qui fait l’affaire. Merci Ali Karbassi d’avoir fait un si bon [...]
[...] Mind Mining Medium » Automatically Block Facebook Applications Scripts greasemonkey pour bloquer les invitations des applications et faire disparaitre les blocs inutiles de FB. Je publierai ma version optimisée. (tags: greasemonkey facebook filter) [...]
Thank you soooooo much.
I have been incredibly frustrated by the plethora of friends who send me such absolute crap.
I am a long time web developer and believe facebook is seriously wicked, however I fear it is in jeopardy of becoming new form of dumb chain.
I have been toying with creating my own facebook app and an idea struck me just this evening.
How about the “get a life” app which politely advises friends stop sending you stupid crap and do soemthing worhtwhile
I found a great post on youtube which would be a great URL to autosend on block.
http://www.youtube.com/watch?v=cxJIQ60KiuA
damn funny
peace and thanks again
[...] DotsAlec’s DotsHomeNewsVideoMusicMoviesTechFunnyMore …PeopleAlec’s Dots More on facebookMind Mining Medium » Automatically Block Facebook Applicationsdotted by Alec google_hints = “apps,block,facebook”;google_ad_client = [...]
[...] facebook but unfortunately it is also getting more annoying with all the apps now available. How to make facebook look like it did before it started sucking. No myspace here, none of my real life friends use it, so there isn’t much point for me. [...]
Thank you SO much for this add-on. I…I love you…
[...] InFriends’ FavesEveryone’s FavesAlec’s FavesHomeTopicsPeopleAlec’s Faves More on facebookMind Mining Medium » Automatically Block Facebook ApplicationsFaved by Alec google_hints = “apps,block,facebook”;google_ad_client = [...]
[...] to join these prestigious ranks, but today I discovered a greasemonkey script which will automatically block any new application invitations (below). This ranks up there with the “auto-poker” script in the list of “ways to [...]
garden-grower, dragon-tamer, people-seller, lover-rater, cancer-hater, fish-giver, etc… In the past, I’ve rather politely “ignored” your invitations to join these prestigious ranks, but today I discovered a greasemonkey script which willautomatically block any new application invitations(below). This ranks up there with the “auto-poker” script in the list of “ways to be less annoyed on Facebook”. [IMG Snapshot 2007-11-08 12-04-17] Now, for those of you who are wondering why I haven
[...] recommend:http://tech.karbassi.com/2007/09/19/automatically-block-facebook-applications/You see see the spam first time round, and you can unblock later if you wish, but you’ll never have [...]
[...] to dropping Facebook too, until I stumbeled upon a way to ignore those loving application invites: http://tech.karbassi.com/2007/09/19…k-applications/ Edit to contribute: The best way to avoid getting hosed over by your Internet history is to DON’T [...]
I found this via a Google search, and I just want to thank you so much for providing a solution for the most annoying aspect of “new Facebook.” Finally!
[...] that aren’t "Just for fun" . His favourite discovery in the last few weeks is the Facebook application blocker script. Interests: Food and drink, specifically the beers of Timothy Taylor, offal in all its many and [...]
[...] και διάφορα “εργαλεία”, για να ελέγξεις ή να σταματήσεις τις διάφορες εφαρμογές, αλλά πάνω από όλα είναι η [...]
[...] ihan kkiseltn lytny, et mist, mut on se asetus siel. Tmmnen propelihattu viritelm lyty: http://tech.karbassi.com/2007/09/19/automatically-block-facebook-applications/ 27.11.2007 16:45, muokattu viimeksi 27.11.2007 16:46 Vastaa thn [...]
[...] were supposed to be next big thing, and everyone was gonna rush to get involved. And now many people find them annoying. What a surprise. But then, I never was the one to get into the hype. I admit I [...]
That is such a brilliant solution, thanks for that. I love facebook except for the application requests…nice work.
[...] them annoying as all hell pointless applications everyone seems to think you’ll be interested in. http://tech.karbassi.com/2007/09/19…k-applications/ Keeping facebook clean and simple. Auto-moron protection. __________________ MightyJustice - [...]
[...] too can enjoy a clean profile by going to the following address; Automatially block Facebook Application requests with Greasemoney, a Firefox plugin. Leave a [...]
AWESOME! I’m going to friend you just for this. Or not.
Anyways, I just keep facebook so that old friends can find me, since I share a name with a very famous film producer and am un-googleable unless you know my online nick-name.
I was considering closing my Facebook account before I found this!
That’s absolutely fabulous - thanks so much, I now have a very tidy facebook, just the way I like it! Best wishes, Andy.
I tried to install the code but I cant. Im using Internet explorer..
Brilliant! Now I don’t have to waste time going through the rigmarole of clicking on the reject button over and over again. Thanks a lot! :)
Man, this is just awesome
Good job, thanx!
Duke of Fleed
There’s nothing I can say to emphasize this any better: THANK YOU!
I love you in a way that only an expletive can describe as an adjective.
Thanks for this fantastic script!
I don’t want to block all apps, is that possible?
Thank you sooo much!!
you have saved my sanity!!
(just one question, if I log into FB from a computer that doesn’t run on Mazilla… will i get invites again??
: )
@Gail: You will get invites only if the application isn’t already blocked. I would suggest not clicking “Ignore” and letting the program block it next time you log in with your Firefox browser.
Words cannot express my gratitude for this.
Im so happy now that I can use FB and not be barraged with silly nonsense apps .
Your app gets a big THANKS from me
John Piercy
Hi Ali
Great script. Will you be updating it to accomodate the changes FB have made?
They now have BLOCK on the same page as the notification. It should simplify your extension?
CJ: I took a look at the updates and nothing new for me to do. They just did what I did, but moved it to a notification/request page. My script will still work and no real updates is needed.
We’ll see when they’ll have an option to actually not allow any requests for new apps.
YOU ARE MY HERO. Thank you. You took my pain away.