Created
April 7, 2018 15:08
-
-
Save ayosec/dff04e3f772706cfe09e49cde1d55163 to your computer and use it in GitHub Desktop.
Fix medium iframes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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