mirror of
https://github.com/Wonderfall/hugo-WonderMod.git
synced 2024-11-22 18:41:37 +01:00
18 lines
577 B
JavaScript
18 lines
577 B
JavaScript
// Highlight
|
|
hljs.initHighlightingOnLoad();
|
|
|
|
// SunriseSunset
|
|
const getSunrise = SunriseSunsetJS.getSunrise;
|
|
const getSunset = SunriseSunsetJS.getSunset;
|
|
navigator.geolocation.getCurrentPosition((position) => {
|
|
const latitude = position.coords.latitude;
|
|
const longitude = position.coords.longitude;
|
|
const sunrise = getSunrise(latitude, longitude).getTime();
|
|
const sunset = getSunset(latitude, longitude).getTime();
|
|
const now = Date.now();
|
|
if (now < sunrise || now < sunset) {
|
|
const body = document.querySelector('body');
|
|
body.classList.add('dark');
|
|
}
|
|
});
|