var h1 = false //this gets the mysite.com portion of the emnbeded script function notion2embed_getScriptURL() { var js_url = ""; var tags = document.getElementsByTagName("script"); for (var i = 0; i < tags.length; i++) { var t = tags[i]; if (t.src.indexOf("notion2embed.com/v1/") !== -1) { js_url = t.src; } } return js_url; } //load css var cleanslate_link = document.createElement("link"); cleanslate_link.rel = "stylesheet"; cleanslate_link.href = "https://notion2embed.com/static/v1/cleanslate.css"; cleanslate_link.type = "text/css"; document.getElementsByTagName('head')[0].appendChild(cleanslate_link); var css_link = document.createElement("link"); css_link.rel = "stylesheet"; css_link.href = "https://notion2embed.local/static/v1/notion.css"; css_link.type = "text/css"; document.getElementsByTagName('head')[0].appendChild(css_link); var notion2embed_link = document.createElement("link"); notion2embed_link.rel = "stylesheet"; notion2embed_link.href = "https://notion2embed.com/static/v1/notion2embed.css"; notion2embed_link.type = "text/css"; document.getElementsByTagName('head')[0].appendChild(notion2embed_link); //gets the domain function notion2embed_getSite() { var site = document.location.hostname; var js_url = notion2embed_getScriptURL(); if (js_url !== "") { var s = js_url.split("?")[0]; var pieces = s.split("/"); site = pieces[pieces.length-1]; } return site; } function parentLink(){ var container = document.getElementById('notion2embed'); var request = new XMLHttpRequest(); request.onreadystatechange = function() { if (this.readyState == 4 && this.status == 200) { container.innerHTML = this.responseText; } }; var args = "?" if (h1) { args = args + "h1=no&" } request.open('GET', 'https://notion2embed.com/embed/' + encodeURIComponent(notion2embed_getSite()) + args); request.send(); } function internalLink(notionId){ var container = document.getElementById('notion2embed'); var request = new XMLHttpRequest(); request.onreadystatechange = function() { if (this.readyState == 4 && this.status == 200) { container.innerHTML = this.responseText; } }; var args = "?" if (h1) { args = args + "h1=no&" } request.open('GET', 'https://notion2embed.com/internal/' + encodeURIComponent(notionId) + args, true); request.send(); } window.addEventListener("hashchange", function(){ var notionId = window.location.hash.slice(2); if(notionId == '') { parentLink(); } internalLink(notionId); }); window.onload=parentLink();