Created
July 6, 2025 18:23
-
-
Save jpcercal/24e12985db90afb4798229bfe05af17a 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
| document.whenPageIsReady = function (callback) { | |
| if ( | |
| document.readyState === 'complete' || | |
| document.readyState === 'interactive' | |
| ) { | |
| callback(); | |
| } else { | |
| document.addEventListener('DOMContentLoaded', callback, { once: true }); | |
| } | |
| }; | |
| document.whenPageIsReady(async () => { | |
| const jsUrl = | |
| 'https://raw.githubusercontent.com/jpcercal/continente/main/dist/app.js'; | |
| const cssUrl = | |
| 'https://raw.githubusercontent.com/jpcercal/continente/main/dist/app.css'; | |
| const [jsCode, cssCode] = await Promise.all([ | |
| fetch(jsUrl).then((res) => res.text()), | |
| fetch(cssUrl).then((res) => res.text()), | |
| ]); | |
| console.log('[jpcercal/continente] injecting the JS and the CSS code'); | |
| console.log(jsCode); | |
| console.log(cssCode); | |
| document.body.appendChild( | |
| Object.assign(document.createElement('script'), { | |
| type: 'text/javascript', | |
| textContent: jsCode, | |
| }), | |
| ); | |
| document.body.appendChild( | |
| Object.assign(document.createElement('style'), { | |
| textContent: cssCode, | |
| }), | |
| ); | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment