Skip to content

Add dynamic theme fixes for *.rtp.pt websites - #15818

Open
arturstat wants to merge 3 commits into
darkreader:mainfrom
arturstat:patch-625566
Open

Add dynamic theme fixes for *.rtp.pt websites#15818
arturstat wants to merge 3 commits into
darkreader:mainfrom
arturstat:patch-625566

Conversation

@arturstat

Copy link
Copy Markdown
Contributor

@arturstat
arturstat marked this pull request as draft August 5, 2026 05:13
@arturstat arturstat changed the title Add dynamic theme fixes for *.rtp.pt Add dynamic theme fixes for *.rtp.pt websites Aug 5, 2026
*.rtp.pt

INVERT
img[src$="/rtppalco-dark_2026.svg"]

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


INVERT
img[src$="/rtppalco-dark_2026.svg"]
.navbar-toggler-icon

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hamburguer icon on the top right:
https://www.rtp.pt/play/

INVERT
img[src$="/rtppalco-dark_2026.svg"]
.navbar-toggler-icon
.uninav-menu-toggle-line

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lines from 1078 to 1080 are the hamburguer icon in the mobile version of:
https://www.rtp.pt/

.uninav-menu-toggle-line
.uninav-menu-toggle::before
.uninav-menu-toggle::after
.uninav-search.is-open .uninav-search-toggle::before

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lines 1081 and 1082 are the close icon that is visible after clicking the search button at:
https://www.rtp.pt/

.uninav-menu-toggle::after
.uninav-search.is-open .uninav-search-toggle::before
.uninav-search.is-open .uninav-search-toggle::after
.epg-channel-inner-header::before

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lines 1083 and 1084 are the plus and minus icons in the mobile version:
https://www.rtp.pt/tv/

.uninav-search.is-open .uninav-search-toggle::after
.epg-channel-inner-header::before
.epg-channel-inner-header::after
.navbar-container .navbar-brand:has(> .ensina-logo)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Top left logo at:
https://ensina.rtp.pt/

.epg-channel-inner-header::before
.epg-channel-inner-header::after
.navbar-container .navbar-brand:has(> .ensina-logo)
.footer-menu .left-section:has(> a[href="https://ensina.rtp.pt/"])

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bottom left logo at:
https://ensina.rtp.pt/

.epg-channel-inner-header::after
.navbar-container .navbar-brand:has(> .ensina-logo)
.footer-menu .left-section:has(> a[href="https://ensina.rtp.pt/"])
.worldnav-menu-toggle-line

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lines from 1087 to 1089 are the Plus and X icons in the mobile version of:
https://ensina.rtp.pt/

body

MATCH
.bg-black

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Native dark theme was only found at the following urls:
https://www.rtp.pt/noticias/videos
https://www.rtp.pt/noticias/audios

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same popup if you enter this site first time and do not have cookies accepted.

Image

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When I use .didomi-popup-open and when I use :not(.didomi-popup-open) a dark theme is detected in both cases. So perhaps there is an issue with Dark Reader on how it handles the :not() differently. In fact .didomi-popup-open is not available immediately, it becomes available one or two seconds later.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After more testing I identified the cause. When I use :not(.didomi-popup-open) the class is not available immediately when the page is refreshed or opens for the first time, so dark reader detects a dark theme, and stops looking for class changes. The class .didomi-popup-open becomes available some miliseconds later, but because dark reader is no longer checking if the class is available or not, it does not work as we want. Changes in dark reader itself would be required, but I lack the knowledge to fix it any time soon.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In /src/inject/detector.ts it is doing exactly as observed:

function checkMatch(target: Element) {
    if (target.matches?.(matchSelector)) {
        stopDetectingUsingHint();
        success();
        return true;
    }
    return false;
}

function stopDetectingUsingHint() {
    hintTargetObserver?.disconnect();
    hintMatchObserver?.disconnect();
}

As soon as the MATCH is found it stops looking.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I found that too... not sure if making detection somehow delayed would be good. I am not that good in the code Alexander was writing but any changes here can crerate new issues for NO DARK THEME and SYSTEM THEME tags. (Maybe not but I prefer to have worst options in mind).

My proposal will be added (again) in PR comments.

@arturstat
arturstat marked this pull request as ready for review August 5, 2026 05:39

@Myshor Myshor left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CSS changes checked and approved.

I can merge this if there won't be any dark-sites.config and detector-hints.config changes included in PR.

kwejk.pl
kyleggiero.me
kyun.host
lab.rtp.pt

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Welcome screen when I check it's dark status.

Image

mstdn.social
mtv.com
musedash.moe
museu.rtp.pt

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as lab.rtp.pt

Image

body

MATCH
.theme--night

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Theme can be broken because of the same popup with white background...
Will need MATCH change to
MATCH
.theme--night:not(.didomi-popup-open)

After refresh it opens white didomi popup with light background.
Seems all of this sites can not be added here too.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The problem is that .didomi-popup-open is not available when you refresh or open the page, it becomes available later. I think that is the reason why it is not working as desired.

body

MATCH
.bg-black

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same popup if you enter this site first time and do not have cookies accepted.

Image

@Myshor

Myshor commented Aug 6, 2026

Copy link
Copy Markdown
Collaborator

My proposal is still open. Remove all detector and dark-sites changes from this PR so CSS fixes can be merged. 😉

Additional conclusions:
As we already found, dark-sites cannot be used here as a new user landing on the page will get a white flash straight in the eyes.

The detector will not work properly when the didomi-popup opens up, because that popup loads dynamically and is added after detector-hint is checked.

Even if we added a delay for that didomi-popup scenario, it could create more issues related to that delay.

You can create a Feature Request for a delay while the detector check is done and tag alexanderby in it.
Still, I am not sure making the detector with :not() will be a good idea in the end. Because when we close that popup, detection will work only if we already have dark theme selected and the didomi popup won't open again.

See my worst scenario:
Someone changed the theme to dark on the site. Something broke with cookies and the didomi popup appears.
With our fixes and :not() included in matches, we land on the page and dark theme is not detected. This is nice.

Then we close that popup. And Dark Theme is still not detected. Because detection is not checking anything anymore.

Same as detecting dark theme after changing it manually with the switch on the page—it won't work until the page is refreshed and dark theme is already selected.

Summarizing: IMHO we should have these rtp.pt pages excluded from dark-sites and detector-hints totally.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants