!function(){"use strict";function e(e,t){let n="jsonp_callback_"+Math.round(1e5*Math.random());window[n]=function(e){delete window[n],document.body.removeChild(o),t(e)};let o=document.createElement("script");o.src=e+(e.indexOf("?")>=0?"&":"?")+"callback="+n,document.body.appendChild(o)}window.browser=window.browser||window.chrome;let t=null,n=!1,o=!1,i="text";function c(e){window.parent.postMessage(e,"*")}function d(){let o=document.querySelector("article.text-mode"),i=document.querySelector("article.markdown-mode"),c=o.querySelector(".title"),d=o.querySelector(".content");n||(c.innerText=t.title,d.innerHTML=t.content,function(t){let n=t.querySelectorAll("twitter-widget");for(let t=0,o=n.length;t<o;t++){let o=n[t];e("https://api.twitter.com/1/statuses/oembed.json?omit_script=t&id="+o.getAttribute("data-tweet-id"),function(e){o.outerHTML=e.html})}}(d),n=!0),o.style.display="block",i.style.display="none";let r=document.querySelector("#sidebar li.icon-markdown");r.classList.remove("on"),r.classList.add("off")}function r(){let e=document.querySelector("article.text-mode"),n=document.querySelector("article.markdown-mode"),i=n.querySelector("pre code");o||(i.textContent=`# ${t.title}\n\n${t.md}`,hljs.highlightBlock(i),o=!0),e.style.display="none",n.style.display="block";let c=document.querySelector("#sidebar li.icon-markdown");c.classList.remove("off"),c.classList.add("on")}document.addEventListener("DOMContentLoaded",function(){document.querySelector("#sidebar li.icon-close").addEventListener("click",function(e){e.preventDefault(),c({name:"hideOverlay"})}),document.querySelector("#sidebar li.icon-clip").addEventListener("click",e=>{e.preventDefault(),c({name:"clipToQuiver",data:{type:i,title:t.title,content:"markdown"===i?t.md:t.content}})}),document.querySelector("#sidebar li.icon-print").addEventListener("click",function(e){e.preventDefault(),window.print()}),document.querySelector("#sidebar li.icon-markdown").addEventListener("click",function(e){e.preventDefault(),"markdown"===i?(d(),i="text"):(r(),i="markdown"),localStorage.setItem("mode",i)}),window.addEventListener("message",e=>(function(e){switch(e.name){case"loadArticle":t=e.data,n=!1,o=!1,"markdown"===(i=localStorage.getItem("mode")||"text")?r():d()}})(e.data)),c({name:"frameDidLoad"})})}();
