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
Importing styles from Stylish add-on for Firefox #77
Comments
Okay, since we need to have an SDK add-on anyway to generate the JSON, let's do the parsing inside this SDK add-on. Here is the first draft: When it is ready we can ask users to install it as a temporary add-on and generate the JSON. |
Guess we should summon more people here from FF-related threads to test your export addon: @r-a-y, @TayliaM, @ivysrono, @Keith94, @BangDroid, @strel, @silverwind, @Mottie |
This was frustrating the heck out of me until I remembered I was using a FF Stylish fork now for everything but nightly. Works like a charm with Stylish. What a timesaver! Edit to clarify: I very seldom use nightly. My nightly FF hadn't been updated recently and today after it did update I can no longer access the manage page for Stylus, and other extensions are borked as well. The export did work well on release WF and release FF from another laptop. |
It's reported as incompatible with Nightly 55.0a1 :( |
@Keith94 you need to load the extension in the debugging mode (about:debugging). It is not signed. |
There is no UI for now. If things go fine, you will get a desktop notification and a JSON file located in your Desktop directory. |
Well those steps are for installation, which I didn't need. I only see a rather uninformative error on the console "20:34:23.267 TypeError: start is undefined 1 parse.js:45:11" |
@mzso, thanks for the error message. It seems some of your styles have nested |
Okay, so there's only the linked script? (I only see an empty java file) |
@mzso please give the new version a try; https://github.com/schomery/firefox-stylish-export/blob/master/stylish-export.xpi?raw=true |
@tophf can you investigate this @-moz-document domain(google.com) {
/** comment 2 **/
/** comment 2 **/
/** comment 2 **/
/** comment 3 **/
body {
border-color: #000;
}
} This cannot be imported using import button |
@schomery commented on 2017. jún. 10. 08:48 CEST:
There seem to be issues. First I tried on latest nightly but the manage tab doesn't appear in stylus. (On export I got a single error for one stlye, which I don't actually use, have lying around disabled: |
This is related to #78
Thanks! I added a notification to warn users if Stylish add-on is not accessible.
Can you share your |
I used the Firefox export style addon and then exported the same style from Stylus and after normalizing the two exported json files, I found these differences (using Windows 10):
Here are the actual files: https://gist.github.com/Mottie/b1e0f12aeb265163504e36235a2251a2 I originally had them saved as a revision, but you still had to look at the diff using git, so I ended up separating them to make copy/pasting easier. |
@schomery commented on 2017. jún. 10. 10:37 CEST:
Okay, but it's filled with a bunch of disabled non-functioning/obsolete/tinkerware crap. I'll add the exported json too. |
@Mottie
This is fixed. Please give the new version a try.
@tophf Stylus generates unescaped regexps, is this correct? |
@mzso please try the latest version of the exporter add-on and let me know if the JSON file is working as expected or not. I tested it and it successfully exported 36 styles. |
Our backup file is a JSON and regexps are strings so they get the standard JSON escaping, in particular |
The actual string should be |
The actual string is what the user typed. A valid expression would be |
this is what we have in the actual CSS @-moz-document regexp("^https?://((gist|guides|help|raw|status|developer)\.)?github\.com((?!generated_pages\/preview).)*$"), domain("githubusercontent.com")
{
...
} so why we get |
Because the original expression is INVALID: Quoting the specification:
|
right! |
I just thought it's highly probable that many styles have invalid regexp escaping. I guess we could violate the spec and import them by checking whether the regexp string has single |
@schomery, Stylus editor "import" button already handles incorrectly-escaped regexps just fine. I haven't tested the export addon, though, nor intend to :-) |
@schomery commented on 2017. jún. 11. 08:43 CEST:
Exporting wasn't the issue last time. I could and can export fine. (As far as I can tell, and I attached the exported json too in my previous post, for you to check if needed) I get the infinite spinner still and this in the console:
|
Hehe I understand, what I meant was that regxr.com forces you to escape forward slashes. Anyway, I'm not trying to argue. I haven't had a chance to test the Firefox Stylish exporter after the update. I'll do it when I get some free time later today. |
I gave this another go on FF55 beta, with the latest version of Stylus. But I still couldn't import the styles, and got the infinite spinner. I even tried it in safe mode, with loading stylus as a temporary extension. Didn't work then either. |
Was making another attempt at using Stylus, and needing to deal with importing. Finding a way to export from Stylish was annoying, but I finally found that the In the end, very simple. (It also has an XML export, but that looks like it double-escapes HTML entities, which makes it annoying.) So now I'm trying to import into Stylus, and it seems the only method available is to import a
No json file was created. I'd just like to know if there's a reason the import process can't handle straight css files? The editor itself has options to 'import' Mozilla-style code, but all that means is that it brings up a window that you can paste stuff into. Clearly the addon has the means to handle that format, so it would be nice to just point it at a bunch of files and let it do the job. I'll probably have to end up doing a manual copy-paste, but it would have been nice to have simple expectations 'just work'. |
Meta info will be lost (update URL, customized advanced style settings on userscripts.org site). And the only means of detecting whether a style existed would be its name which is not reliable enough to update a style on such import, hence it would be added as a duplicate or skipped if its contents is identical. I'm not convinced this scenario is useful except for the mentioned edge case. |
@Kinematics give "Stylish export to JSON" add-on another try. The issue with the latest Nightly is fixed. |
So will it only be possible to import into a fresh Firefox profile? It makes migration a lot more of a chore. |
Tried it, and it worked fine. Thanks.
Doesn't matter so much now that the export is working again, but I suppose mine could be an edge case, given that I have no styles from userscripts.org; all of mine are written by hand. Duplicates are irrelevant when just trying to get Stylus working on a first migration, and names are guaranteed to be unique simply due to file system naming requirements. |
It seems like the exporter addon is broken on nightly. No file is written to my desktop and in my browser console, I get:
If I poke around the object that's logged in those middle two log lines, I see the
|
@Fyren |
Though that's not totally unexpected, it seems like the highest demand for an export tool is now that Stylish has also broken and people will look to move to Stylus. |
@Fyren commented on 2017. aug. 7. 10:36 CEST:
You should migrate before it breaks, not after. v56 is the last version you can expect to do so. Since (I'm certain) the export tool depends on deeper stuff that the WE API won't ever provide. Such as reading the "stylish.sqlite" file. I would have migrated a while ago, but I'm hindered by stylus' inability to import what stylish-export has exported. |
1 similar comment
@Fyren commented on 2017. aug. 7. 10:36 CEST:
You should migrate before it breaks, not after. v56 is the last version you can expect to do so. Since (I'm certain) the export tool depends on deeper stuff that the WE API won't ever provide. Such as reading the "stylish.sqlite" file. I would have migrated a while ago, but I'm hindered by stylus' inability to import what stylish-export has exported. |
@Fyren as @mzso mentioned for the exporter add-on to work, you need to have a working Stylish add-on. Since both Stylish and the exporter is not working in FF57, use an older version of Firefox to create your JSON backup. Also, note that Firefox is changing their profile manager as of FF55; https://www.ghacks.net/2017/08/02/you-cannot-downgrade-firefox-55-profiles/ |
You can use sql.js to extract from a stylish.sqlite file in the browser. I have an example here: https://www.jeffersonscher.com/res/stylishextract.html (loads 2MB script file) That just makes an archival html document with the user styles' titles and code. If there is a particular format that would be good to generate perhaps I could add that to my page, or you could just take the current code and run with it on your site. NOTE: sql.js takes up some 3.6MB under [your-profile]/storage/temporary/https+++www.jeffersonscher.com/asmjs You can delete it once you're done, either using your file browser or using the "Settings" button in the "Site Data" section of the Options/Preferences page to clear all data from www.jeffersonscher.com (select that domain in the list, click Remove Selected, click Save Changes). |
Nice @jscher2000! I don't know where that file is stored on a Mac, but in Windows you'll find it at:
If you are using a dev edition of Firefox, the profile folder will be |
It's also visible in |
Hi! Okay, so all of my attempts at migrating to stylus failed. Since importing only ever works on a new profile I imported the styles in such. Tried creating a style, thinking maybe a different place for the settings might be used. BUT that failed also. So it seems it not just importing fails but stylus is broken in it's totality. Can't create or import any styles, can't do anything. These errors showed up on the console when trying to save:
|
This error indicates your FF is broken. |
@tophf commented on 2017. aug. 23. 10:17 CEST:
I don't think it's broken in general all other addons work. However it looks like styles that mod the GUI are not applied. Are they not supposed to work? EDIT: |
IndexedDB is one of the core browser API and the error indicates there's something wrong in the FF's internal code so I consider it's broken. Stylus simply may be the only extension that uses IndexedDB in your browser. Other developers think it's too complicated and opt for the simpler storage. Also, Stylus is a WebExtension and thus it can't apply userstyles to the browser UI, see #92 for more info and workarounds. IIRC there's also a Private mode in FF which also breaks some core API that we use. |
This is quite late for the last messages to this issue, but I tested the export addon and it worked fine, except that one style I'd written was pegged as not mine... and somehow linked to a style on userstyles.org that isn't even the userstyles.org copy of it. 0_o I suspect but can't conclusively prove that this is on Stylish's end rather than this one, so I'm posting here just in the less likely case that it's on this end. |
I guess this issue is solved or is it a placeholder for ambitions to automatic stylish -> stylus import function? Imho the user style extractor makes the export addon obsolete (you can use it only up to FF 56!), but I'd keep it in the wiki as alternative and to honor all the effort. |
Hi! So this method/addon should still work, right? (I see no indication that it shouldn't) I lagged around on the 56 branch until now. (Technically Waterfox Classic, but it makes for little difference) But I'm thinking of letting go because due to lack of webcomponents sites are breaking left and right. Which would allow me to import styles from Stylish (technically Stylem, but also makes for little difference). |
You might need to create your own separate files, but I suspect you need to start mostly from scratch. Firefox's UI structure has changed radically since Firefox 56. You may have better luck identifying what you want to change and then searching on the following subreddit for updated solutions: |
Update: please test the export addon for Stylish-Firefox: instruction below
in Stylish add-on for Firefox, the actual code is being stored instead of sections.
We can get all the stored styles by running the following code in the browser console (Ctrl + Shift + J)
I think it makes more sense to check if the imported JSON has a
code
key in its objects and if so convert them into sections before storing the imported styles. If I want to convert codes into sections in this script, it gets pretty messy.@tophf any thoughts?
The text was updated successfully, but these errors were encountered: