erosman / support

Support Location for all my extensions
Mozilla Public License 2.0
175 stars 12 forks source link

[FireMonkey][Question] Is FM able to use Stylus' styles? #105

Closed Geobert closed 4 years ago

Geobert commented 5 years ago

I'm asking because I can't make this style work: https://github.com/StylishThemes/GitHub-Dark

Either CSS format nor user Script format.

erosman commented 5 years ago

CSS format generally performs better than the JavaScript.

ref: https://github.com/StylishThemes/GitHub-Dark/blob/master/github-dark.css

Because it is using the Stylus style @-moz-document it needs to be converted to GreaseMonkey type include/match and each section into a separate CSS

For example

@-moz-document domain("launch-editor.github.com")
to:
@matches      *://launch-editor.github.com/*
@-moz-document domain("help.github.com")
@matches      *://help.github.com/*
@-moz-document domain("resources.github.com")
@matches      *://resources.github.com/*
@-moz-document regexp("^https:\\/\\/(github\\.com)\\/(features)\\/(security|actions).*$")
@matches      https://github.com/features/security*
@matches      https://github.com/features/actions*
@-moz-document regexp("^https:\/\/(github\.com)\/(features)\.*$")
@matches      https://github.com/features.*
@-moz-document regexp("^https://www\.zuora\.com.*github\.com.*$")
@matches      https://www.zuora.com/*github.com
@-moz-document regexp("^https?://((gist|guides|help|lab|launch-editor|raw|resources|status|developer)\\.)?github\\.com/((?!generated_pages/preview).)*$"), domain("githubusercontent.com"), domain("graphql-explorer.githubapp.com"), domain("www.githubstatus.com") 
@matches      https://*.github.com/*
@excludeMatches   https://*.github.com/generated_pages/preview*
@matches      https://githubusercontent.com/*
@matches      https://graphql-explorer.githubapp.com/*
@matches      https://www.githubstatus.com/*
Geobert commented 5 years ago

Thank you for your answer. So it needs some conversion to make it work.

Do you plan to automate this kind of conversion when installing from a web site?

erosman commented 5 years ago

You can import settings from Stylus. The import can handle all @-moz-document excpet @-moz-document regexp There is no way to convert @-moz-document regexp automatically.

Geobert commented 5 years ago

So I need to convert the regexp first then import?

Geobert commented 5 years ago

hm, I've removed the regexp and I'm left with

@-moz-document domain("githubusercontent.com"), domain("graphql-explorer.githubapp.com"), domain("www.githubstatus.com") {

and try to import it, but nothing happened :-/

EDIT: don't mind me, there's many more regexp in the file…

erosman commented 5 years ago

GreaseMonkey/FireMonkey has set target domains per file while you can have bits of CSS relating to different domains in Stylus.

Each section under @-moz-document must be saved as a new file. That means above file has to be divided into 7 separate files.

Geobert commented 5 years ago

ouch…

atomGit commented 5 years ago

ouch is right :)

as much as i'd like to use FM for JS and CSS, it isn't feasible to dump Stylus because of this

i'm guessing the API is the limiting factor here?

erosman commented 5 years ago

i'm guessing the API is the limiting factor here?

RegEx directly is not supported by modern browser APIs so eventually all will have to change and/or inject using non-standard methods.

I have converted all my CSS without any problems and I had 100s of them. I had been using Stylish and then Stylus for many many years before.

However, there were all my own CSS so converting them was easy enough.

Anyone familiar with GM and CSS can make styles for FireMonkey and/or convert existing Styles of Stylus to FireMonkey styles but that require some knowledge if the style was made with regex.

In fact the @-moz-document API has always been experimental since 2004 and may be removed in future.

FireMonkey can convert styles from Stylus backup if they dont use Regex. The ones with Regex have to be done manually.

erosman commented 4 years ago

v1.34 Partial compatibility with standard CSS syntax UserStyle ==UserStyle== ... ==/UserStyle== is also available (v1.34). Few basic regexp() are converted to match pattern but other sections with regexp() are ignored as browser API does not support Regular Expression.