var loadSocialLogin = function() { for(var r = 0; r < document.forms.length;r++){ var action = document.forms[r].getAttribute('action'); if ( action!== null ) { if ( action.indexOf('login.php') > -1 ) { document.forms[r].insertAdjacentHTML('beforeend','
'); } } } var button_selectors = document.querySelectorAll("[class='sp-social-login_buttons']"); for(var i = 0; i < button_selectors.length; i++) { button_selectors[i].innerHTML='
'; } } var load = false; function waitForElementToDisplay(selector, time) { if(document.querySelector(selector)!=null) { if (!load) { //console.log("Social Login Loaded"); document.querySelector(selector).insertAdjacentHTML('beforeend','
'); load = true; } return; } else { setTimeout(function() { waitForElementToDisplay(selector, time); }, time); } } waitForElementToDisplay('#checkout-customer-login',5); waitForElementToDisplay('#checkout-customer-returning',5); if (document.readyState === "complete") { loadSocialLogin(); } else { if (window.addEventListener) { window.addEventListener("load", loadSocialLogin, false); } else { if (window.attachEvent) { window.attachEvent('on' + "load", loadSocialLogin); } } } function eventer (e) { e.preventDefault ? e.preventDefault() : e.returnValue = false; if (e.origin+'/'=="https://bc.hexgator.com/") { var data = JSON.parse(e.data); var event = data.event; var channel = data.data.channel; var key = data.data.key; if (event=='doSocialLogin') { top.window.location.assign(key); } } } if (window.addEventListener) { window.addEventListener("message", eventer, false); } else { window.attachEvent("onmessage", eventer); }