Skip to content
This repository has been archived by the owner on Oct 25, 2019. It is now read-only.

Commit

Permalink
fix theme injecting
Browse files Browse the repository at this point in the history
  • Loading branch information
elv1n committed Jul 19, 2019
1 parent f1a3adc commit 5a202ee
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions static/applyTheme.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
document.addEventListener('DOMContentLoaded', function () {
fetch('https://dark-theme.netlify.com', {cache: 'no-cache'})
.then(response => response.text())
.then(text => {
const el = document.createElement('style');
el.innerHTML = text;
document.head.appendChild(el);
fetch('https://dark-theme.netlify.com').then(function(response) {
if (response.headers.get('Content-Type') === 'application/json') {
return response.json();
}
return response.text();
}).then(css => {
const prevEl = document.querySelector('#theme-master')
if (prevEl) {
prevEl.parentNode.removeChild(prevEl);
}
const el = document.createElement('style');
el.id = 'theme-master';
el.innerHTML = css;
document.head.appendChild(el);
});
});

0 comments on commit 5a202ee

Please sign in to comment.