//console.log('booker.js'); var thisScriptName = 'booker.js'; var scripts = document.getElementsByTagName('script'); var currentScript; for (var i = 0; i < scripts.length; i++) { if (scripts[i].src.indexOf(thisScriptName) != -1) { currentScript = scripts[i]; break; } } var scriptURL = currentScript.src; //console.log(scriptURL); var ts_root_url = extractHostname(scriptURL); document.write(''); function extractHostname(url) { var hostname; var protocol = 'https:'; if (url.indexOf("//") > -1) { hostname = url.split('/')[2]; protocol = url.split('//')[0]; } else hostname = url.split('/')[0]; hostname = hostname.split(':')[0]; hostname = hostname.split('?')[0]; return protocol + '//' + hostname; }