Skip to content

Instantly share code, notes, and snippets.

@ayosec
Created April 7, 2018 15:08
Show Gist options
  • Save ayosec/dff04e3f772706cfe09e49cde1d55163 to your computer and use it in GitHub Desktop.
Save ayosec/dff04e3f772706cfe09e49cde1d55163 to your computer and use it in GitHub Desktop.
Fix medium iframes
// Replace iframes to load their real content
// Intended to be used in Scratchpad (Firefox)
(function() {
let sf = $(".js-stickyFooter");
if(sf !== null) { sf.remove(); }
document.querySelectorAll("figure iframe").forEach(iframe => {
let src = iframe.dataset["src"];
let newIframe = document.createElement("iframe");
newIframe.style = "width: 100%; border: 1px solid #ccc";
newIframe.src = src;
newIframe.onload = () => {
newIframe.height = newIframe.contentWindow.document.body.scrollHeight + "px";
}
let container = iframe.closest("figure");
container.parentNode.insertBefore(newIframe, container);
container.parentNode.removeChild(container);
});
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment