Skip to content

Instantly share code, notes, and snippets.

@oliverdoetsch
Created June 10, 2014 07:57
Show Gist options
  • Save oliverdoetsch/d1003d7b5218f764356e to your computer and use it in GitHub Desktop.
Save oliverdoetsch/d1003d7b5218f764356e to your computer and use it in GitHub Desktop.
<script type='text/javascript'>
//<![CDATA[
document.addEventListener("DOMContentLoaded",function(){var h=/\/s\B\d{2,4}/,g=document.getElementsByClassName("post-body")[0].offsetWidth,a=document.querySelectorAll(".post-body table");if("undefined"!=typeof a&&null!==a)for(var b=a.length;b--;){var d=a[b],c=document.createElement("div");c.setAttribute("class","separator");var e=document.createElement("div");e.style.textAlign="center";var f=a[b].querySelector("a").cloneNode(!0);c.appendChild(f);d.parentNode.replaceChild(c,d);a[b].querySelector(".tr-caption")&&
(d=a[b].querySelector(".tr-caption").innerText||a[b].querySelector(".tr-caption").textContent,e.innerHTML=d,c.appendChild(e))}a=document.querySelectorAll(".post-body img");for(b=a.length;b--;)c=a[b].height,e=a[b].width,d=Math.round(g/(e/c)),f="",f=e>=c?g:d,c=a[b].getAttribute("src").replace(h,"/s"+f),a[b].removeAttribute("width"),a[b].removeAttribute("height"),a[b].parentNode.removeAttribute("style"),a[b].style.marginLeft="0",a[b].style.padding="0",a[b].style.boxSizing="border-box",a[b].style.boxShadow=
"0 0 0 rgba(0, 0, 0, 0)",a[b].setAttribute("width",g),a[b].setAttribute("src",c)});
//]]>
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment