-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathfbauth.js
1 lines (1 loc) · 1.09 KB
/
fbauth.js
1
function loadFacebookSdk(){!function(e,o,t){var n,c=e.getElementsByTagName(o)[0];e.getElementById(t)||(n=e.createElement(o),n.id=t,n.src="https://connect.facebook.net/en_US/sdk.js#xfbml=1&version=v3.0&appId=178576098876236",c.parentNode.insertBefore(n,c))}(document,"script","facebook-jssdk")}function showSuccessMessage(){chrome.tabs.query({},function(e){for(var o=0;o<e.length;o+=1)chrome.tabs.sendMessage(e[o].id,{type:"fbauth",recipient:"extension"})}),document.querySelector("#success").style.display="block"}function redirectToFacebookAuth(){var e=new window.URLSearchParams(window.location.search),o=window.atob(e.get("facebook_url"));window.location.href=o,setTimeout(function(){window.location.href!==o&&(window.location.href=o)},500)}function translate(){document.title=chrome.i18n.getMessage("facebookAuthTitle"),document.querySelectorAll("[data-i18n]").forEach(function(e){var o=e.getAttribute("data-i18n");e.innerHTML=chrome.i18n.getMessage(o)})}window.addEventListener("load",function(){loadFacebookSdk(),translate(),window.location.href.match(/finished/)?showSuccessMessage():redirectToFacebookAuth()});