AutoPageColor
Moderators: Lootyhoof, FranklinDM
Forum rules
Please do not create new topics here unless you are an extension author in need of a dedicated releases&support thread!
Please do not create new topics here unless you are an extension author in need of a dedicated releases&support thread!
-
- Knows the dark side
- Posts: 5517
- Joined: 2015-12-09, 15:45
AutoPageColor
This is a new extension that changes the webpage color scheme from light to dark based on sunrise/sunset times for your location.
"One hosts to look them up, one DNS to find them and in the darkness BIND them."

KDE Neon on a Slimbook Excalibur (Ryzen 7 8845HS, 64 GB RAM)
AutoPageColor|PermissionsPlus|PMPlayer|Pure URL|RecordRewind|TextFX

KDE Neon on a Slimbook Excalibur (Ryzen 7 8845HS, 64 GB RAM)
AutoPageColor|PermissionsPlus|PMPlayer|Pure URL|RecordRewind|TextFX
-
- Pale Moon guru
- Posts: 37352
- Joined: 2011-08-28, 17:27
- Location: Motala, SE
Re: AutoPageColor
Flipping the prefers-color-scheme pref? 

"The world will not be destroyed by those who do evil, but by those who watch them without doing anything." - Albert Einstein
"Seek wisdom, not knowledge. Knowledge is of the past; wisdom is of the future." -- Native American proverb
"Linux makes everything difficult." -- Lyceus Anubite
"Seek wisdom, not knowledge. Knowledge is of the past; wisdom is of the future." -- Native American proverb
"Linux makes everything difficult." -- Lyceus Anubite
-
- Knows the dark side
- Posts: 5517
- Joined: 2015-12-09, 15:45
Re: AutoPageColor
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.
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.
"One hosts to look them up, one DNS to find them and in the darkness BIND them."

KDE Neon on a Slimbook Excalibur (Ryzen 7 8845HS, 64 GB RAM)
AutoPageColor|PermissionsPlus|PMPlayer|Pure URL|RecordRewind|TextFX

KDE Neon on a Slimbook Excalibur (Ryzen 7 8845HS, 64 GB RAM)
AutoPageColor|PermissionsPlus|PMPlayer|Pure URL|RecordRewind|TextFX
-
- Pale Moon guru
- Posts: 37352
- Joined: 2011-08-28, 17:27
- Location: Motala, SE
Re: AutoPageColor
It's a media query. This is pure CSS in most cases.
"The world will not be destroyed by those who do evil, but by those who watch them without doing anything." - Albert Einstein
"Seek wisdom, not knowledge. Knowledge is of the past; wisdom is of the future." -- Native American proverb
"Linux makes everything difficult." -- Lyceus Anubite
"Seek wisdom, not knowledge. Knowledge is of the past; wisdom is of the future." -- Native American proverb
"Linux makes everything difficult." -- Lyceus Anubite
-
- Knows the dark side
- Posts: 5517
- Joined: 2015-12-09, 15:45
Re: AutoPageColor
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.
"One hosts to look them up, one DNS to find them and in the darkness BIND them."

KDE Neon on a Slimbook Excalibur (Ryzen 7 8845HS, 64 GB RAM)
AutoPageColor|PermissionsPlus|PMPlayer|Pure URL|RecordRewind|TextFX

KDE Neon on a Slimbook Excalibur (Ryzen 7 8845HS, 64 GB RAM)
AutoPageColor|PermissionsPlus|PMPlayer|Pure URL|RecordRewind|TextFX
-
- Themeist
- Posts: 1579
- Joined: 2012-02-09, 23:35
- Location: United Kingdom
Re: AutoPageColor
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. 

-
- Knows the dark side
- Posts: 5517
- Joined: 2015-12-09, 15:45
Re: AutoPageColor
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?
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?
"One hosts to look them up, one DNS to find them and in the darkness BIND them."

KDE Neon on a Slimbook Excalibur (Ryzen 7 8845HS, 64 GB RAM)
AutoPageColor|PermissionsPlus|PMPlayer|Pure URL|RecordRewind|TextFX

KDE Neon on a Slimbook Excalibur (Ryzen 7 8845HS, 64 GB RAM)
AutoPageColor|PermissionsPlus|PMPlayer|Pure URL|RecordRewind|TextFX
-
- Pale Moon guru
- Posts: 37352
- Joined: 2011-08-28, 17:27
- Location: Motala, SE
Re: AutoPageColor
https://udn.realityripple.com/docs/Web/API/Geolocation_API/Using_the_Geolocation_API
Or for direct interface access:
https://udn.realityripple.com/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIDOMGeoGeolocation
Or for direct interface access:
https://udn.realityripple.com/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIDOMGeoGeolocation
"The world will not be destroyed by those who do evil, but by those who watch them without doing anything." - Albert Einstein
"Seek wisdom, not knowledge. Knowledge is of the past; wisdom is of the future." -- Native American proverb
"Linux makes everything difficult." -- Lyceus Anubite
"Seek wisdom, not knowledge. Knowledge is of the past; wisdom is of the future." -- Native American proverb
"Linux makes everything difficult." -- Lyceus Anubite
-
- Knows the dark side
- Posts: 5396
- Joined: 2011-10-03, 10:19
- Location: Piney Woods of Southeast Texas, USA
Re: AutoPageColor
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.
Linux Mint 22.1 (Xia) Xfce w/Pale Moon, Waterfox, Firefox
MX Linux 23.6 (Libretto) Xfce w/Pale Moon, Waterfox, Firefox
Linux Debian 12.10 (Bookworm) Xfce w/Pale Moon, Waterfox, Firefox
MX Linux 23.6 (Libretto) Xfce w/Pale Moon, Waterfox, Firefox
Linux Debian 12.10 (Bookworm) Xfce w/Pale Moon, Waterfox, Firefox
-
- Themeist
- Posts: 1579
- Joined: 2012-02-09, 23:35
- Location: United Kingdom
Re: AutoPageColor
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.
-
- Knows the dark side
- Posts: 5517
- Joined: 2015-12-09, 15:45
Re: AutoPageColor
Will this be affected by the location sharing preferences or are those only applicable to websites?

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

"One hosts to look them up, one DNS to find them and in the darkness BIND them."

KDE Neon on a Slimbook Excalibur (Ryzen 7 8845HS, 64 GB RAM)
AutoPageColor|PermissionsPlus|PMPlayer|Pure URL|RecordRewind|TextFX

KDE Neon on a Slimbook Excalibur (Ryzen 7 8845HS, 64 GB RAM)
AutoPageColor|PermissionsPlus|PMPlayer|Pure URL|RecordRewind|TextFX
-
- Knows the dark side
- Posts: 5517
- Joined: 2015-12-09, 15:45
Re: AutoPageColor
Changelog for 1.1
- Added desktop alerts
- Added configuration options for desktop alerts, and console logging.
"One hosts to look them up, one DNS to find them and in the darkness BIND them."

KDE Neon on a Slimbook Excalibur (Ryzen 7 8845HS, 64 GB RAM)
AutoPageColor|PermissionsPlus|PMPlayer|Pure URL|RecordRewind|TextFX

KDE Neon on a Slimbook Excalibur (Ryzen 7 8845HS, 64 GB RAM)
AutoPageColor|PermissionsPlus|PMPlayer|Pure URL|RecordRewind|TextFX
-
- Moon Magic practitioner
- Posts: 2801
- Joined: 2012-08-19, 20:32
Re: AutoPageColor
Quite smart, thanks moonbat!
-
- Knows the dark side
- Posts: 5517
- Joined: 2015-12-09, 15:45
Re: AutoPageColor
Changelog for 1.2
- Preview alert when toggling it on/off.
"One hosts to look them up, one DNS to find them and in the darkness BIND them."

KDE Neon on a Slimbook Excalibur (Ryzen 7 8845HS, 64 GB RAM)
AutoPageColor|PermissionsPlus|PMPlayer|Pure URL|RecordRewind|TextFX

KDE Neon on a Slimbook Excalibur (Ryzen 7 8845HS, 64 GB RAM)
AutoPageColor|PermissionsPlus|PMPlayer|Pure URL|RecordRewind|TextFX
-
- Lunatic
- Posts: 271
- Joined: 2016-01-28, 12:08
- Location: Ploieşti, Romania
Re: AutoPageColor
That may even come out unintentionally while using the ip-api.com service.

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.
-
- Pale Moon guru
- Posts: 37352
- Joined: 2011-08-28, 17:27
- Location: Motala, SE
Re: AutoPageColor
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.
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.
"The world will not be destroyed by those who do evil, but by those who watch them without doing anything." - Albert Einstein
"Seek wisdom, not knowledge. Knowledge is of the past; wisdom is of the future." -- Native American proverb
"Linux makes everything difficult." -- Lyceus Anubite
"Seek wisdom, not knowledge. Knowledge is of the past; wisdom is of the future." -- Native American proverb
"Linux makes everything difficult." -- Lyceus Anubite
-
- Lunatic
- Posts: 271
- Joined: 2016-01-28, 12:08
- Location: Ploieşti, Romania
Re: AutoPageColor
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.
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.
-
- Pale Moon guru
- Posts: 37352
- Joined: 2011-08-28, 17:27
- Location: Motala, SE
Re: AutoPageColor
Bottom line: geopositioning based on IP is at all times "best effort". It is not GPS geolocation.
"The world will not be destroyed by those who do evil, but by those who watch them without doing anything." - Albert Einstein
"Seek wisdom, not knowledge. Knowledge is of the past; wisdom is of the future." -- Native American proverb
"Linux makes everything difficult." -- Lyceus Anubite
"Seek wisdom, not knowledge. Knowledge is of the past; wisdom is of the future." -- Native American proverb
"Linux makes everything difficult." -- Lyceus Anubite
-
- Lunatic
- Posts: 271
- Joined: 2016-01-28, 12:08
- Location: Ploieşti, Romania
-
- Knows the dark side
- Posts: 5517
- Joined: 2015-12-09, 15:45
Re: AutoPageColor
Changelog for 2.0
Big update!
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)
"One hosts to look them up, one DNS to find them and in the darkness BIND them."

KDE Neon on a Slimbook Excalibur (Ryzen 7 8845HS, 64 GB RAM)
AutoPageColor|PermissionsPlus|PMPlayer|Pure URL|RecordRewind|TextFX

KDE Neon on a Slimbook Excalibur (Ryzen 7 8845HS, 64 GB RAM)
AutoPageColor|PermissionsPlus|PMPlayer|Pure URL|RecordRewind|TextFX