Page 1 of 2

AutoPageColor

Posted: 2021-05-06, 06:19
by moonbat
This is a new extension that changes the webpage color scheme from light to dark based on sunrise/sunset times for your location.

Re: AutoPageColor

Posted: 2021-05-06, 08:53
by Moonchild
Flipping the prefers-color-scheme pref? :)

Re: AutoPageColor

Posted: 2021-05-06, 09:20
by moonbat
Yep!
I also was thinking of having per site settings for it added to PermissionsPlus, but is this set via a CSS property or javascript? Could find a way to override the javascript query but I have no idea about CSS manipulation.

Re: AutoPageColor

Posted: 2021-05-06, 09:34
by Moonchild
It's a media query. This is pure CSS in most cases.

Re: AutoPageColor

Posted: 2021-05-06, 09:38
by moonbat
Non trivial to figure out then. UI wise I like this and PermissionsPlus the most - they perfectly integrate with the browser UI and show the power of XUL, this is something impossible with other browsers now.

Re: AutoPageColor

Posted: 2021-05-06, 10:02
by Lootyhoof
Very interesting add-on. Maybe if I ever get round to adding dark modes to my themes based on the prefers-color-scheme pref it will make even the whole browser change based on time of day. ;)

Re: AutoPageColor

Posted: 2021-05-06, 10:16
by moonbat
You should definitely try that! Even the lightweight theme addons like ThemeTool could benefit from this, specify different images for different times of day.

The only thing I'm not happy about is the dependency on external servers to calculate the IP address and for geolocation. These were the only ones I could find that don't force you to use an API key with limited usage.

@Moonchild - is there a way to use the browser's built in location services to avoid this dependency? I see an interface called nsIDOMGeoPositionCoords, but how does one use it?

Re: AutoPageColor

Posted: 2021-05-06, 10:24
by Moonchild

Re: AutoPageColor

Posted: 2021-05-06, 10:41
by Night Wing
Changing the color scheme from light to dark based on sunrise/sunset times for your location is already baked in by default in linux Mint. It's named "Redshift" and I use it all the time during the evening and night. One has to turn it on, but there is a setting (Autostart) where it will automatically start when Mint is booted.

Re: AutoPageColor

Posted: 2021-05-06, 10:45
by Lootyhoof
Redshift changes the colour temperature of the screen, not the GTK (system) theme. Though even then, that's not passed through to web pages in Pale Moon due to privacy concerns.

Re: AutoPageColor

Posted: 2021-05-06, 10:47
by moonbat
Will this be affected by the location sharing preferences or are those only applicable to websites?
Lootyhoof wrote:
2021-05-06, 10:45
Though even then, that's not passed through to web pages in Pale Moon due to privacy concerns.
Pale Moon's approach of directly letting you control it instead of depending on the system is best. With my extension you could spoof coordinates and set the color scheme to the opposite of your timezone if you're really paranoid ;)

Re: AutoPageColor

Posted: 2021-05-06, 12:48
by moonbat
Changelog for 1.1
  • Added desktop alerts :mrgreen:
  • Added configuration options for desktop alerts, and console logging.

Re: AutoPageColor

Posted: 2021-05-06, 16:56
by back2themoon
Quite smart, thanks moonbat!

Re: AutoPageColor

Posted: 2021-05-27, 15:32
by moonbat
Changelog for 1.2
  • Preview alert when toggling it on/off.

Re: AutoPageColor

Posted: 2021-09-23, 10:49
by Drugwash
moonbat wrote:
2021-05-06, 10:47
With my extension you could spoof coordinates and set the color scheme to the opposite of your timezone if you're really paranoid
That may even come out unintentionally while using the ip-api.com service. :roll: Out of curiosity I just tested my location with them and they missed longitude by 2 degrees. This could indicate errors in their geolocation database.

In my Linux Mint Cinnamon applet I use a combination of different services (kwelo.com and sunrise-sunset.org) which appears to be more accurate but requires the IP address beforehand and two subsequent sync calls.

Re: AutoPageColor

Posted: 2021-09-23, 12:59
by Moonchild
ip-api can only do so much based on IP. It's what happens when ISPs are not subdividing their IP space very fine-grained. You can also offer suggestions for correction to them

The other option would be google which is more accurate BUT wants a full map of your local wifis to get that accurate, which is... well let's just say it's not very privacy-friendly.
Geopositioning is supposed to be a rough guide, anyway.

Re: AutoPageColor

Posted: 2021-09-23, 13:39
by Drugwash
In my case it's an USB HSDPA modem which is assigned a limited IP range. The service mentioned above (kwelo.com, to which I am not affiliated in any way) returns the accurate coordinates based on the very same IP. Maybe their method is different, or maybe they update their database more frequently. Or it's simply a random data error. After reconnecting minutes ago - and getting a different IP in the same range - the result is now correct from ip-api.com.

I noticed there are other similar sites that sometimes return inaccurate results. While a slight deviation shouldn't harm, a larger one could produce unwanted results.
Unfortunately there are not many such services that do not require an API key, to choose from. And personally I stay as far away from anything google as possible.

Anyway it was just a heads up. Hopefully such errors are rare and of minor consequence.

Re: AutoPageColor

Posted: 2021-09-23, 19:05
by Moonchild
Bottom line: geopositioning based on IP is at all times "best effort". It is not GPS geolocation.

Re: AutoPageColor

Posted: 2021-09-23, 20:40
by Drugwash
Thankfully. 8-)

Re: AutoPageColor

Posted: 2022-11-14, 13:28
by moonbat
Changelog for 2.0
Big update!
  • Added toolbar button.
    The button cycles between setting color preference to light, dark and none, and has quick access to toggling automation and the extension options.
  • Fixed time calculation issues.
  • Now will show alerts (if enabled) whenever prefers_color_scheme changes, even if you do it yourself from the colors dialog.
  • Prompt to clean up user modified preferences on uninstall (usually they get left behind, cluttering up about:config)