diff --git a/javascripts/Google Maps to SunCalc.org.js b/javascripts/Google Maps to SunCalc.org.js new file mode 100644 index 0000000..0219cf0 --- /dev/null +++ b/javascripts/Google Maps to SunCalc.org.js @@ -0,0 +1,15 @@ +"use strict"; +var coordinates; +var pieces = location.href.split('/'); +for (let i = 0; i < pieces.length; i++) { + if (pieces[i].startsWith('@')) { + coordinates = pieces[i].substring(1); + break; + } +} +if (typeof coordinates === 'undefined') { + window.alert('Current Google Maps URL does not contain coordinates.'); +} else { + const now = new Date(); + location.href = 'https://www.suncalc.org/#/' + coordinates + '/' + now.getFullYear() + '.' + (now.getMonth() + 1) + '.' + now.getDate() + '/' + now.getHours() ':' + now.getMinutes() + '/1/3'; +}