Skip to content

Instantly share code, notes, and snippets.

@ali5alkaf5
Last active June 9, 2022 16:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ali5alkaf5/588a43b7cc67f787bef4be53c48dc811 to your computer and use it in GitHub Desktop.
Save ali5alkaf5/588a43b7cc67f787bef4be53c48dc811 to your computer and use it in GitHub Desktop.
window.addEventListener('DOMContentLoaded', function(){
document.querySelectorAll('iframe[data-id^="twitframe"]').forEach(el => {
el.onload = function(){
el.contentWindow.postMessage({ element: this.dataset['id'], query: "height" }, "https://twitframe.com");
}
})
})
window.addEventListener('message', function(e){
var oe = e;
if (oe.origin == "https://twitframe.com"){
if (oe.data.height && oe.data.element.match(/^tweet_/))
document.querySelectorAll("[data-id='" + oe.data.element + "']").style.height = parseInt(oe.data.height);
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment