Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for variables in @-moz-document #767

Closed
Mottie opened this issue Aug 27, 2019 · 14 comments
Closed

Support for variables in @-moz-document #767

Mottie opened this issue Aug 27, 2019 · 14 comments

Comments

@Mottie
Copy link
Member

Mottie commented Aug 27, 2019

This issue was opened to discuss the potential of supporting this feature.

When a variable is added inside a @-moz-document rule, it initially works, e.g.:

/* ==UserStyle==
@name           _github test
@namespace      test
@version        1.0.0
@description    test of variables in domain
@advanced       text site "Subdomain" "help."
@author         Me
==/UserStyle== */

@-moz-document domain("/*[[site]]*/github.com") {
  body * {
    color: red !important;
  }
}

The above style does apply to help.github.com; but, changing the "Subdomain" value in the settings is not applied until the UserCSS is altered, reverted (so it remains unchanged) and re-saved. Merely changing the variable value does in fact update the UserCSS internally, but (I haven't dug into the code, or remember) the style doesn't apply to the new subdomain until re-saved.

So, my question is, should we fix this and would it be useful?

@eight04
Copy link
Collaborator

eight04 commented Aug 27, 2019

I can't reproduce. The style applies to gist.github.com immediately when I change the setting from help. to gist..

@Mottie
Copy link
Member Author

Mottie commented Aug 27, 2019

Hmm, I'm using Chrome.

@Mottie
Copy link
Member Author

Mottie commented Aug 27, 2019

Weird, now it's working ¯\(ツ)

@xt0rted
Copy link

xt0rted commented Aug 27, 2019

When I was testing this out for the GitHub Dark style it seemed like you had to close the browser for the value in the document selector to get picked up, and then from there updating the value from the settings window was an instant change.

@LunaticoCR
Copy link

It does work for a domain() element but it does not work for a regex() element in the @-moz-document section. We've been discussing that possibility on a PR for GitHub-Dark.

@Mottie
Copy link
Member Author

Mottie commented Aug 27, 2019

How are you using the regex? Make sure to double escape special characters, e.g. \\..

@eight04
Copy link
Collaborator

eight04 commented Aug 27, 2019

the value in the document selector

What is this?

It does work for a domain() element but it does not work for a regex() element in the @-moz-document section.

I still can't reproduce.

According to @Mottie 's comment, I think it might be a live preview issue which is unrelated to @-moz-document rules. I believe I had mentioned this problem in a thread but now I can't find it. Here is the STR:

  1. Prepare a usercss having settings e.g. Github Dark.
  2. Open a Github tab.
  3. Open the popup -> edit Github Dark.
  4. Change the code e.g. insert a space to trigger live preview.
  5. Switch to Github tab.
  6. Open the popup -> configure Github Dark
  7. Nothing changes.
  8. Close the editor.
  9. The change in (6) is applied.

@LunaticoCR
Copy link

How are you using the regex? Make sure to double escape special characters

A variable is referenced with /*[[var1]]*/ right? So double escaped it will look like: \\/\\*\\[\\[var1\\]\\]\\*\\/? But when I try to use that inside the regex it won't work.

The regex in question is ^https:[\/]{2}\\/\\*\\[\\[ghe-domain\\]\\]\\*\\/[\/](?!pages).*$, where ghe-domain represents a:

@advanced text ghe-domain "GitHub Enterprise Domain" "github.com"

And in my case the value in this variable is something like: abc-github.company.com

@Mottie
Copy link
Member Author

Mottie commented Aug 27, 2019

No, don't escape the placeholder. I meant escape the period that separates the subdomain. Try this:

/* ==UserStyle==
@name           _github test
@namespace      test
@version        1.0.0
@description    test of variables in domain
@advanced       text site "Subdomain" "help"
@author         Me
==/UserStyle== */

@-moz-document regexp("^https?:///*[[site]]*/\\.github\\.com/.*$") {
  body * {
    color: red !important;
  }
}

@eight04
Copy link
Collaborator

eight04 commented Nov 1, 2019

I think this can be closed? We may want to track the live preview issue in a new thread.

@Mottie Mottie closed this as completed Nov 1, 2019
@silverwind
Copy link
Contributor

What's the verdict here? Does it work for domain or regexp or both?

@eight04
Copy link
Collaborator

eight04 commented Sep 10, 2020

If you are asking about using variables in domain/regexp function, then yes, they work.

If you are asking about the live preview issue, then I guess it hasn't been fixed yet.

@eight04
Copy link
Collaborator

eight04 commented Sep 10, 2020

#807

@silverwind
Copy link
Contributor

Thanks, I was asking about USO vars in domain(), will try that.

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

No branches or pull requests

5 participants