Spyke
firefoxcss·[dormant] Firefox CSSbytubbadu

[help] How do I prevent userContent to be apply in private browsing mode?

Hello! I have changed a few websites appearance with the userContent.css, but I'd like this to only apply to normal browsing, and not to private browsing. the UserChrome instead I'd like to be applied for both normal and private browsing. Is this possible? searching the web didn't give me any useful result... thanks in advance!

View original on lemmy.world
tubbadureply
lemmy.world

my userContent.css file is a bunch of

@-moz-document domain("example.com"){
  body {
    color: red !important;
  }
}

for each website I customized. however, this applies both to normal and private browsing, and I'd like it to apply only to normal browsing

1
MrOtherGuyreply
lemmy.world

I don't think it's possible. It would require some privileged @media query or something similar. Or, potentially using media query to match a feature that isn't available on private-browsing mode. There could be something like that, but I don't know one.

2
tubbadureply
lemmy.world

thanks for the answer! I'd like to disable it because if sometimes some website interface fucks things up, I can check if it's my fault or not, so visiting the site in private mode without my css would quickly show me who's fault

1
MrOtherGuyreply
lemmy.world

Hmm. I don't have a good solution for that. It would be trivial using an extension like Stylus though, just don't allow it to run in PB mode.

I suppose you could do all your @-moz-document matching with regexp and then using a bookmarklet to add some "mark" to the document url. Then you wouldn't need to use PB-mode at all.

So, a bookmarklet like this, when clicked, adds/removes a#pbm suffix to the current tab and loads that address to a new tab:

javascript:void ((loc)=>window.open(loc.endsWith("#pbm")?loc.slice(0,-4):loc+"#pbm"))(document.location.href)

Then in you userContent.css you would write your document matching like this (example is for en.wikipedia.org):

@-moz-document regexp(".*en\.wikipedia\.org.*(?<!#pbm)$"){
  body{ color: red !important; }
}

That should work but honestly if you need this then I would rather just use extension like Stylus or open those links in separate profiles even.

1

@-moz-document regexp(".*en\.wikipedia\.org.*(?<!#pbm)$"){ body{ color: red !important; }

this is really cool! I wouldn't even need a bookmarklet, I can just manually add it whenever I wish to remove the css

it's not what I was looking for, but it's a great compromise. Thank you very much!

1

You reached the end