forked from nobuf/facebook-connect-for-chrome-extension
-
Notifications
You must be signed in to change notification settings - Fork 0
/
background.js
18 lines (18 loc) · 885 Bytes
/
background.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
var successURL = 'https://www.facebook.com/connect/login_success.html';
function onFacebookLogin() {
if (!localStorage.accessToken) {
chrome.tabs.getAllInWindow(null, function(tabs) {
for (var i = 0; i < tabs.length; i++) {
if (tabs[i].url.indexOf(successURL) == 0) {
var params = tabs[i].url.split('#')[1];
access = params.split('&')[0]
console.log(access);
localStorage.accessToken = access;
chrome.tabs.onUpdated.removeListener(onFacebookLogin);
return;
}
}
});
}
}
chrome.tabs.onUpdated.addListener(onFacebookLogin);