[Feature Request] Proper treatment of `about:blank` pages
See original GitHub issueFeature Request
Is your feature request related to a problem? Please describe
When a window is created in JS with no URL it gets a window.location
of about:blank
:
win = window.open("", "_blank");
win.location.href // => "about:blank"
These windows are currently mistreated by darkreader in that there is no way that I see to turn it on/off for such a specific page. Even more than that, the darkreader dropdown on these pages look like something went bad somewhere: there is the top on/auto/off at the top, but clicking the buttons does nothing, and there is nothing else below them (none of the regular UI).
It makes semi-sense to just ignore such pages, since they seem to come from nowhere and it’s still good to avoid the jarring sea of bright whiteness if you happen to run into one of them, however there are valid uses of such windows, but there’s no way currently to disable darkreader for them other than turning it off globally. (See below for further context.)
Describe the solution you’d like
For such about:blank
windows, it makes sense to use their window.origin
to decide how to treat them. This way a blank window that was opened from https://foo.bar/
would be treated as that, so if I disable darkreader for foo.bar
, it would also be disabled on about:blank
windows it spawns.
Additional context
What I ran into is an issue with my home-cooked music player, which can use such windows for visualizations. (Why? Because having multiple monitors all showing changing colors in sync is a very nice thing…) My code does something like:
win = window.open("", "_blank");
win.document.body.style.background = "#fcc";
but that doesn’t work since darkreader gets in its way, and there is no way to turn it off locally. But if you look at win.origin
you’ll see where it originated.
Issue Analytics
- State:
- Created 2 years ago
- Comments:11 (6 by maintainers)
Top GitHub Comments
Correct, and we can see that when we get a “notifcation” when a new content script has been injected into a tab.
However if we query the tab from the background-script, such information isn’t available and thus we cannot correctly handle the tab if we say “oh this tab belongs to origin x so we say in the pop-up it’s site x”, well in the background-script we cannot see such information anymore after any period of time.
IFrames are special, such information can be recalled from querying tabs, from such that we can make sense from it. Also IFrames are in the site itself and not on a new tab and will be treated with care.
Regards, Gusted
It’s not really random – like I said,
window.origin
has the site that started it, and this would only be something to use if the url is empty, which means that a new tab or an iframe would behave the same as it is now, and it’s only an empty one that would behave according to the url of whoever made it (and yes, if there’s an iframe with no url, then it makes sense to treat it according to its origin too).