Created
January 25, 2014 16:42
-
-
Save jutememo/8619199 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function () { | |
var fbPage = function () { | |
var that = {}, | |
_paths = location.pathname.split('/'); | |
var hasUserName = function () { | |
return _paths.length == 2; | |
}; | |
var getId = function () { | |
if (hasUserName()) { | |
var req = new XMLHttpRequest(); | |
req.onload = function () { | |
prompt("このページの ID を表示します。", | |
JSON.parse(this.responseText).id); | |
}; | |
req.open("GET", "https://graph.facebook.com" + location.pathname); | |
req.send(); | |
} else { | |
prompt("このページの ID を表示します。", | |
_paths[3]); | |
} | |
}; | |
that.getId = getId; | |
return that; | |
}; | |
var fb = fbPage().getId(); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment