Skip to content

Instantly share code, notes, and snippets.

Created December 14, 2012 08:06
Show Gist options
  • Save anonymous/4283552 to your computer and use it in GitHub Desktop.
Save anonymous/4283552 to your computer and use it in GitHub Desktop.
Facebook settings with separate files keep html to be html less javascript in html
(function($) {
console.log("facebook loading...");
var j;
// check facebook available
if($('#fb-root').length === 0) {
// not found fb-root prepend element to body
$('body').prepend("<div id='fb-root'></div>");
// and load javascript for facebook
j = document.createElement('script');
j.type = 'text/javascript';
j.src = '//connect.facebook.net/en_US/all.js';
$('#fb-root').append(j);
}
$(document).ready(function() {
window.fbAsyncInit = function() {
FB.init({
appId : 'YOUR APP ID', // App ID
status : true, // check login status
cookie : true, // enable cookies to allow the server to access the session
xfbml : true, // parse XFBML
frictionlessRequests: true // Allow frictionless request
});
window.fbAsyncInitCalled = true;
};
});
})(window.jQuery);
<script type="text/javascript" src="js/facebook.js"></script>
<script type="text/javascript" src="js/script.js"></script>
var fbAsyncInitCallback = setInterval(function() {
if(window.fbAsyncInitCalled) {
console.log('FB already loaded');
// test
FB.api('/me', function(resp) {
console.log(resp);
})
// subscribe to event
FB.getLoginStatus(function(response) {
if (response.status === 'connected') {
// the user is logged in and has authenticated your
// app, and response.authResponse supplies
// the user's ID, a valid access token, a signed
// request, and the time the access token
// and signed request each expire
// var uid = response.authResponse.userID;
// var accessToken = response.authResponse.accessToken;
console.log(">> facebook connect >> here is xss fb");
}
else if (response.status === 'not_authorized') {
// the user is logged in to Facebook,
// but has not authenticated your app
console.log("the user is logged in to Facebook, but has not authenticated your app");
}
else {
// the user isn't logged in to Facebook.
console.log("the user isn't logged in to Facebook.");
}
});
// Comment detect
FB.Event.subscribe('comment.create', function(response) {
console.log(response);
});
// Like Detect
FB.Event.subscribe('edge.create', function(response) {
console.log(response);
});
clearInterval(fbAsyncInitCallback);
}
else {
console.log('+');
}
}, 2000);
@fake-or-dead
Copy link

how to delete this anonymous gist that accident create ?

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