Skip to content

Instantly share code, notes, and snippets.

@jpcercal
Created July 6, 2025 18:23
Show Gist options
  • Select an option

  • Save jpcercal/24e12985db90afb4798229bfe05af17a to your computer and use it in GitHub Desktop.

Select an option

Save jpcercal/24e12985db90afb4798229bfe05af17a to your computer and use it in GitHub Desktop.
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