Comments (5)
Oh, that sounds hard. π€
from website-dark-mode-switcher.
If anyone has an example website/snippet that would already help.
from website-dark-mode-switcher.
<picture>
<source media="(prefers-color-scheme: dark)" type="image/svg+xml" srcset="dark.svg" />
<source media="not all and (prefers-color-scheme: dark)" type="image/svg+xml" srcset="light.svg" />
<img src="default.png" height="32" width="180" />
</picture>
from website-dark-mode-switcher.
Okay thanks, I briefly looked into this and I can only say it is more complicated.
I created this fiddle: https://jsfiddle.net/uef8gdcy/4/
As I parse the document.styleSheets
, which is the core of this add-on, and yeah there is a media
, where this is exposed:
AFAIK, the current behaviour is actually buggy. The <style>
tag media queries are ignored and all evaluated by this add-on. It cannot/does not differentiate between the media types.
So I've tried document.styleSheets[3].media.deleteMedium("(prefers-color-scheme: dark)")
and it works. So yeah, we could modify that apparently. However, we would need to save the state somewhere there, as we currently extract and inject CSS manually. However now we would need to remember the previous state in order to be able to restore it when the toggle is triggered. π
So anyway, PRs are of course always appreciated.
That said, even this does not fix the image/picture element, which is yet another issueβ¦
from website-dark-mode-switcher.
Hi, I have great news for you! According to my testing, the latest v2.0 release fixes this issue due to the way it now uses a completely new API to do "dark-mode-changing" "properly". For more information, please see the release notes. If the issue should not be fixed, please let me know.
from website-dark-mode-switcher.
Related Issues (20)
- Doesn't work with stylesheets imported with @import HOT 2
- Simplify dramatically now that mediaText is read-write HOT 4
- Automatic theme change not working in Open Fixture Library HOT 2
- Corss-origin stylesheets without crossorigin="anonymous" attribute not supported (e.g. Hardware.info) HOT 6
- Inconsistent Application on New Tabs HOT 12
- Support forcing light mode HOT 2
- Project is not needed anymore - What are the next steps? HOT 5
- https://ar.al/ Vimeo Embed Inverted HOT 2
- Bootstrap 5 Dark Mode has incorrect gradient/fades applied HOT 1
- implement optional syncing! HOT 1
- Adjust permissions doc
- Implement context menu for quickly switching to other styles
- Implement "clever"/context-based/"simple" button mode HOT 1
- Updated translations for 'da': Danish (dansk) HOT 1
- force dark theme through resistFingerprinting HOT 3
- Missing renaming
- Solution for Dark Mode Website Switcher not working with arkenfox's user.js HOT 2
- Show a warning in case privacy.resistFingerprinting is enabled
- Cannot download from Firefox Addon Store HOT 1
- Support setting light/dark mode on a per site/URL basis. HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from website-dark-mode-switcher.