Skip to content

Instantly share code, notes, and snippets.

@dfreedm
Forked from 140bytes/LICENSE.txt
Created September 21, 2011 06:39
Show Gist options
  • Save dfreedm/1231411 to your computer and use it in GitHub Desktop.
Save dfreedm/1231411 to your computer and use it in GitHub Desktop.
Facebook Profile Finder in 139 bytes

140byt.es

A tweet-sized, fork-to-play, community-curated collection of JavaScript.

How to play

  1. Click the Fork button above to fork this gist.
  2. Modify all the files to according to the rules below.
  3. Save your entry and tweet it up!

Keep in mind that thanks to the awesome sensibilities of the GitHub team, gists are just repos. So feel free to clone yours and work locally for a more comfortable environment, and to allow commit messages.

Rules

All entries must exist in an index.js file, whose contents are

  1. an assignable, valid Javascript expression that
  2. contains no more than 140 bytes, and
  3. does not leak to the global scope.

All entries must also be licensed under the WTFPL or equally permissive license.

For more information

See the 140byt.es site for a showcase of entries (built itself using 140-byte entries!), and follow @140bytes on Twitter.

To learn about byte-saving hacks for your own code, or to contribute what you've learned, head to the wiki.

140byt.es is brought to you by Jed Schmidt, with help from Alex Kloss. It was inspired by work from Thomas Fuchs and Dustin Diaz.

(function(f){
// check that the url is for a facebook photo
if (/fbcdn/.test(f)) {
// split the path into an array
f = f.split("/")
// grab the file name
.pop()
// FBCDN photos are underscore separated
.split("_");
// set the path to the facebook profile page
return "http://fb.com/profile.php?id=" +
// Older facebook photos use n{profile_id} as the first field, slice off the "n" with a regex match
(/n(\d+)/.exec(f[0]) ||
// newer photos have the profile id by itself as the third field
{1:f[2]}
// fallback: regex match of the older form will have the profile in index 1
// newer style uses a property bag with index 1 to keep the access the same and reduce size
)[1]}
})
javascript:(function(f){f=""+location;if(/fbcdn/.test(f)){f=f.split("/").pop().split("_");location="http://fb.com/profile.php?id="+((/n(\d+)/.exec(f[0])||{1:f[2]})[1])}})()
function(f){if(/fbcdn/.test(f)){f=f.split("/").pop().split("_");return"http://fb.com/profile.php?id="+(/n(\d+)/.exec(f[0])||{1:f[2]})[1]}}
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2011 YOUR_NAME_HERE <YOUR_URL_HERE>
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. You just DO WHAT THE FUCK YOU WANT TO.
{
"name": "FacebookProfileFinder",
"description": "Using a Facebook photo url, gives a link to uploader's facebook profile. Do not use for stalking.",
"keywords": [
"facebook",
"profile",
"photos",
"stalking"
]
}
<!DOCTYPE html>
<title>Facebook stalking made easy</title>
Facebook Photo: <img id="myUglyMug" src="https://s-hphotos-sjc1.fbcdn.net/254696_10150329994979884_594804883_9664487_6157251_n.jpg"/><br/>
Facebook Profile URL: <a id="output"></a>
<script>
var myFunction = function(f){if(/fbcdn/.test(f)){f=f.split("/").pop().split("_");return"http://fb.com/profile.php?id="+(/n(\d+)/.exec(f[0])||{1:f[2]})[1]}};
var output = document.getElementById("output");
output.innerText = output.href = myFunction(document.getElementById("myUglyMug").src);
</script>
@dfreedm
Copy link
Author

dfreedm commented Sep 25, 2011

fbcdn is usually in the location, but I've seen it at the beginning as well, followed by some random crap.

@tsaniel
Copy link

tsaniel commented Sep 25, 2011

So...could you give some examples?

@tsaniel
Copy link

tsaniel commented Sep 25, 2011

I've tried

function(a){return'//fb.com/profile.php?id='+/fbcdn.*\/(n|(?:\d+_){2})(\d+)/.exec(a)[2]}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment