Last active
June 9, 2022 16:06
-
-
Save ali5alkaf5/588a43b7cc67f787bef4be53c48dc811 to your computer and use it in GitHub Desktop.
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
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