Last active
April 7, 2022 10:30
-
-
Save yuiAs/28824b47cb0e0d9bb0483f7f101113fd to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| const modifier = async () => { | |
| const sleep = msec => new Promise(resolve => { | |
| if (document.readyState === 'complete') { | |
| setTimeout(resolve, msec); | |
| } else { | |
| document.addEventListener('readystatechange', () => { | |
| if (document.readyState === 'complete') { | |
| setTimeout(resolve, msec); | |
| } | |
| }, { capture: false, passive: true }); | |
| } | |
| }); | |
| await sleep(100); | |
| document.querySelectorAll('iframe[id^="twitter-widget-"]').forEach(elem => { | |
| elem.addEventListener('load', () => { | |
| elem.style.removeProperty('height'); | |
| }, { once: true, passive: true }); | |
| elem.style.removeProperty('height'); | |
| }); | |
| }; | |
| if (document.readyState === 'loading') { | |
| document.addEventListener('DOMContentLoaded', () => { | |
| modifier(); | |
| }, { passive: true }); | |
| } else { | |
| console.log(`already dispatched DOMContentLoaded`); | |
| modifier(); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment