Make a stylesheet apply to EVERY domain extension

I am trying to figure out what syntax to use to make every possible extension of a domain be effected by the same stylesheet but I can't seem to find that information anywhere which I just can't believe.
I KNOW there MUST be a way to do this it's such a basic thing you would want to do. I think.

For example thepiratebay.se and thepiratebay.vg both being effected by the same style rules

I'm thinking it's something as simple as

@-moz-document domain("thepiratebay.*")

but this doesn't work so I know the syntax is wrong but I can't for the life of me find how to do this.

Comments

  • edited June 2015 Firefox
    This should give you what you want (I even plan to add/use this for my own TPB style)
    @-moz-document regexp('https?://(www\\.)?thepiratebay\\.[A-z]{2,3}/.*')
    it will match:
    http:// thepiratebay.se/
    https:// www. thepiratebay.se/
    http:// www. thepiratebay.org/index.html
    https:// thepiratebay.net/browse/
    and so on

    ( edit: killed live links )
  • @Kurim, I'm curious what the [A-z] does differently than the ways I've seen it more commonly explained in tutorials, like:

    [a-z] Any character in the range a-z
    [a-zA-Z] Any character in the range a-z or A-Z (any alphabetical character)

    Is it a shorter way to write [a-zA-Z]\? (I escaped the question-mark therefore it is an actual question mark)

    I also thought you had to use " " instead of ' ' in @-moz-document, but I guess it doesn't matter?
  • edited June 2015 Firefox

    I'm curious what the [A-z] does differently than the ways I've seen it more commonly explained in tutorials
    ..
    Is it a shorter way to write [a-zA-Z]\? (I escaped the question-mark therefore it is an actual question mark)

    It's mostly me being lazy and somewhat frustrated with mozillas version of 'regexp'.
    Remember it's \\? here :p

    The 'proper way' of matching only upper and lower case letters is by is doing the [A-Za-z] as the [A-z] will match all characters _between_ upper case A to lowercase z, this could result in positive matches for some special characters as well ( [\]^_` ).

    Also it has to be upper to lower case (A-z) as shown in the ansi&/ascii character map, doing the opposite will prevent you from saving the style.

    I also thought you had to use " " instead of ' ' in @-moz-document, but I guess it doesn't matter?

    Doesn't seem to matter, when I write regexp I tend to prefer the ' to make myself aware that I'm actually writing a script, jason also seem to use it for his @-moz documentation, regexp or not.
  • Kurim said:

    Remember it's \\? here

    In Chrome it's just the one backslash or it's broken.

    Thanks for the explanation. I understood almost all of it.
  • Thanks for the explanation. I understood almost all of it.

    Story of my life :)

    No problem!
  • smile. Thanks VERY MUCH Kurim that worked perfectly.
  • … matching only upper and lower case letters …

    You forgot that domain name only use lower case, so a-z is enough.

  • edited June 2015 Firefox
    LouCypher said:

    You forgot that domain name only use lower case, so a-z is enough.

    Forgetting and being on the safe side are two different things :)

    edit; in short, if a certain browser or browser version treats upper and lower case different / accepts it (i remember something with safari on MacOS being weird on .COM and the other most common TLDs) then I still want to support it, if a site treats upper and lower case different or "forces it" (like how jQuery allows some crazy manipulations) then I still want to support it.

    edit: i guess i should have done the same for the rest of the url-string but the regexp would end up being almost twice as long while the TLD detect is just setting the A to uppercase- did i mention I was lazy?
    @-moz-document regexp('[Hh][Tt][Tt][Pp][Ss]?://([Ww][Ww][Ww]\\.)?[Tt][Hh][Ee][Pp][Ii][Rr][Aa][Tt][Ee][Bb][Aa][Yy]\\.[A-Za-z]{2,3}/.*')
    ^ note these (this and my previous one) does not include the co.uk or .asia etc TLDs (you guessed it, lazyness)
    @-moz-document regexp('[Hh][Tt][Tt][Pp][Ss]?://([Ww][Ww][Ww]\\.)?[Tt][Hh][Ee][Pp][Ii][Rr][Aa][Tt][Ee][Bb][Aa][Yy]\\.([A-Za-z]{2}\\.[A-Za-z]{2}|[A-Za-z]{2,4})/.*')
    ^ there you got those too.
  • @Kurim, it seems like you may be overthinking this one. Is there some browser that I'm unaware of which capitalizes any of these things?
  • @Kurim, it seems like you may be overthinking this one. Is there some browser that I'm unaware of which capitalizes any of these things?

    That's not what I mean, I mean with 'accepts it' i mean if the USER types in the URL in caps then it's up to the browser how it will deal with it.

    iOS has things like premade ".COM" buttons and if the browser or site doesnt change it to lowercase then it will be read as ".COM" no ?

    There's also the case Where Some People Like To Type Stuff Weird Like This.

    when you use the "@-moz-document domain" it doesn't care if it's in lower or upper-case it accepts all variations. regexp does not unless you tell it to.
  • I would expect that all browsers would "fix" this, but I don't even use iOS, so I wouldn't have a clue. At least I understand your reasoning now.
  • edited June 2015 Firefox
    I should have guessed the biggest part of this had to do with the DNS setup:
    http://serverfault.com/questions/475105
    https://www.ietf.org/rfc/rfc4343.txt
    http://english.stackexchange.com/questions/41695

    (why was I stuck on jQuery? was it because you can use it to manipulate urls to for instance mask flash-files as .jpg and scare the shit out of your friends? maybe..)

    @David I worked with the regexp a bit more, this is prob the one i'll end up using
    (looks like meh but it's guaranteed to match *every variation of the tpb url:
    @-moz-document regexp('[Hh][Tt][Tt][Pp][Ss]?://([Ww][Ww][Ww]\\.)?[Tt][Hh][Ee][Pp][Ii][Rr][Aa][Tt][Ee][Bb][Aa][Yy]\\.([A-Za-z][A-Za-z][A-Za-z]?[A-Za-z]?|[A-Za-z][A-Za-z]\\.[A-Za-z][A-Za-z])/.*')
    *: will actually not match names such as 'thepotatoandsteakbay'
  • no need for any overly complex and hungry regexp use this line instead
    @-moz-document url-prefix("https://thepiratebay.")
Sign In or Register to comment.