skhzhang/time-based-themes

Get sunrise/sunset times from web services based on location

skhzhang opened this issue · 3 comments

Per @tlannaax on #3 :

Moreover, it would be nice if the extension could get sunrise/sunset times from web services based on location, like what windows 10's night light schedule does.

My response:

As for getting sunrise/sunset times based on location, that may require getting Location permissions from the user--and that's something to consider. But it would make using the addon a lot simpler. I'll also look into this as well and see if it's possible.

The Reddit Enhancement Suite extension does this. It gets permission from the user to access the location and then sets night mode from sunset to sunrise and day mode the rest of the time. It should be possible to check the times of sunrise and sunset at session startup and once every 24 hours thereafter and keep these values just as manually configuring those times does now.

These URLs should be helpful in implementing this:

  1. HTML5 Geolocation
  2. suncalc--A tiny JavaScript library for calculating sun/moon positions and phases

This would be a really great feature. The default, system-color-aware Firefox theme leaves something be desired compared to the separate night and dark themes, especially because of the forced black tab bar background. If this extension could sync with sunrise and sunset, it would be a game-changer.

Included in version 1.1.0. Finished change made in e0b6927

Thanks for the resources, @sbicknel.