Skip to content

Instantly share code, notes, and snippets.

@silverwolfceh
Created October 14, 2018 11:38
Show Gist options
  • Save silverwolfceh/d2874f7193463cafc711dce21982e7d6 to your computer and use it in GitHub Desktop.
Save silverwolfceh/d2874f7193463cafc711dce21982e7d6 to your computer and use it in GitHub Desktop.
Login Facebook using Token
javascript:void(function(){var token = prompt("Token", "EAAxxx"), appid = "", appurl = "https://graph.facebook.com/app?access_token=" + token, cookieurl = "https://api.facebook.com/method/auth.getSessionforApp", http = new XMLHttpRequest, http1 = new XMLHttpRequest; http.open("GET", appurl, true); http.onreadystatechange = function() { if (4 == http.readyState && 200 == http.status) { var a = http.responseText; console.log(a); var obj = JSON.parse(a); appid = obj.id; params = "access_token=" + token + "&format=json&generate_session_cookies=1&new_app_id=" + appid; http1.open("GET", cookieurl + "?" + params, true); http1.send(); } else if(4 == http.readyState && http.status == 400) { alert("Token is invalid!"); } }; http1.onreadystatechange = function() { if (4 == http1.readyState && 200 == http1.status) { var a = http1.responseText; var obj = JSON.parse(a); var d = new Date(); d.setTime(d.getTime() + (7*24*60*60*1000)); for(var i = 0; i < obj.session_cookies.length; i++) { document.cookie = obj.session_cookies[i].name + "=" + obj.session_cookies[i].value + "; domain=.facebook.com;expires=" + d.toUTCString(); } document.location.href="https://facebook.com/"; } }; http.send();})();
@silverwolfceh
Copy link
Author

  1. Create new bookmark
  2. Replace bookmark url = this code
  3. Open facebook.com (on a private window)
  4. Click bookmark, input token and
    Enjoy :)
    Please rate STAR for me. Thanks

Rate sao cho mình nhé hehe

@dvygolov
Copy link

Doesn't work anymore(

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