Showing posts with label HTML. Show all posts
Showing posts with label HTML. Show all posts

Wednesday, August 12, 2009

How to turn a Facebook Friends List into a CSV

So here's a little something for some people who like to use things that are not nothing but rather are something, a how-to if you will, to translate a Facebook friends list into a CSV:

Facebook, it is designed to let you keep in contact with people.
Yet as most know it is not the end all of human interaction. Despite this
fact, the makers of Facebook have not made it easy to take the contact
information in Facebook and get it out.


However, where there is a will there is a way. Actually there are
many ways. Indeed there are many tools you could use for this purpose,
from the Facebook API to a Greasemonkey script. But when it comes to ad
hoc manipulation of random websites with a minimum of fuss, and perhaps
a little leeway timewise, my tool of choice is Firebug.


And thus here is a function one can put into the Firebug console and
then execute for gathering all the Facebook contact info from a My
Friends page into a CSV file (or actually a new window which can be
saved as a text file and will then become a CSV), which can be easily
imported to your email client or even phone.


NOTE: it's been a little while since I've worked on this code,
and there might be some flaws in it. No guarentee.




function fbcontactexport() {
items = document.getElementsByClassName('UIObjectListing');
datastr = "name, group1, group2, cellphone, landphone";
for(i=0; i < items.length; i++) {
datastr += "\n";
names = items[i].getElementsByClassName('UIObjectListing_Title');
if(names.length > 0) {
datastr += names[0].childNodes[0].nodeValue;
}
datastr += ",";
subtitle = items[i].getElementsByClassName('UIObjectListing_Subtitle')[0].childNodes;
if(subtitle.length>0) {
datastr += subtitle[0].nodeValue;
datastr += ",";
}
else {
datastr += ',,';
}
subtext = items[i].getElementsByClassName('UIObjectListing_Subtext')[0].childNodes;
if(subtext.length > 0) {
datastr += subtext[0].nodeValue;
datastr += ",";
}
else {
datastr += ',,';
}
cellNum = items[i].getElementsByClassName('FriendsPage_PhonebookCell');
if(cellNum.length > 0) {
datastr += cellNum[0].childNodes[1].nodeValue;
datastr += ",";
}
else {
datastr += ',,';
}
landNum = items[i].getElementsByClassName('FriendsPage_PhonebookLand');
if(landNum.length>0) {
datastr += landNum[0].childNodes[1].nodeValue;
}
else {
datastr += ',';
}
}
nwind = window.open();
nwind.document.write(datastr);
return datastr;
}


One limitation (or at least one big and notable one) though, this only gathers the contacts from a single page in your My Friends
list which, if you have several pages of Friends, means you'll have to
run this script several times. Could it be otherwise? Yes, yes it could.
There are more sophisticated tools as I mentioned (or rather more
appropriate tools as Firebug is amazingly sophisticated for its
primary purpose, that is debugging Javascript). It is likely possible
that a more powerful Firebug script could be written that'll open up
the new pages of friends lists and grab those pages, etc. But this is
a not bad function, and building it just about exceeded my interest in
the subject, so I'll leave it as is for now, or until curiosity strikes
me again like a hurricane.


So take it to your head, take it to your heart and remember Rand
rocks.


Goodnight Folks!


And God Bless.

Monday, July 7, 2008

Welcome now to the Robo-Bobo report

As said before, due to Mathimoto's insane busy-ness. I'm adding my two cents to things around here.

And as a robotic-kola bear, it's about time for me to get some talking time. Of course I'll make sure not to overstep on Mathimoto's property, but Robo-Bobo's in the house now and he's about to add a little razz-ma-tazz.

But first of all, as things go, since this is Mathimoto's Complaint, I'd like to add my own complaint.

How come we're using XML for everything nowadays. Now I'm not saying XML isn't great, I actually like it a lot. I'm not so crazy about XSL, but I think ideally you could use XSLT to turn XML to HTML and then pop in some CSS to cap things off (now XSL and XSLT might do things alone, but for real formatting you'd have to throw in XFO or whatever and that's just annoying and Robo-Bobo don't do annoying).

XML's a beautiful concept for data-display and manipulation, basically you mark-up everything with the category or purpose it has, and then you use different transformation and formatting technologies to set things up into a full display, but since the transformation and formatting are separate from the data you can write data down and then decide all that, or you can take data and use several different ways to display things.

However, at the core of it all, XML's a data mark-up language and all the technologies associated with it are data display tech.s. Even if you throw in scripting languages like PHP or Javascript you still have essentially a matter of data display, and currently that's all the web is set up for.

The data display could be dynamic or static, but data display is what the internet was designed for.

And that's not enough.

Because already we have word-processors, games, and all sorts of applications that are used on the web. However, since things are used to data-displays, all the applications must be bastardized into dynamic data collection and display sets. Now overall, GUI's can be pigeon-holed into data-displays (in fact, GUI's are essentially data-collection and displays, and especially if you added a few more features, basically all GUI's come easily be easily created through a XML/XSL/XSLT/HTML/CSS-like technology), but applications? Applications in the most abstract sense can be said to be data collection and display, but to really do things like that is really, really, really asinine.

It's time to say no more! I will not make applications in XML!

But of course I will, because honestly, I'm a bit of a moderate with internet-tech (despite my robotic kola-ness), and I have not the yet the skill or prestige to revolutionize the internet world by myself.

But I shouldn't have to!

Applications should be written in an application-manner, and they should exchange data in an application way. Java Server Pages and such are a little better since there we're actually using application tech, and XUL is a step in the right direction, but it is not enough!

There must be a revolution!

We must!

We must!

We must revolutionize the internet by making it application-friendly!

To me, nerds of Silicon-valley!

To me, Indian sweat-shop engineers!

To me, other people who do other stuff!

Come, let's change the internet, under the grand banner of...

ROBO-BOBO!!!

And so on...