Anyone who knows and can edit JSON code? (Mac, Waterfox related)

rado84

Well-Known Member
Joined
Feb 25, 2019
Messages
1,083
Reaction score
921
Credits
8,303
Since I had to move to Waterfox browser (more stable and faster than Firefox without stripping options) I noticed that one of my favorite extensions no longer works. So I edited the Linux.py file and made it work. Then I did the same with the Windows.py file and that works too. And I started a new repo on github, so that others may benefit from my modifications:


But I'm having trouble with the Mac.py file because it's not pure python inside, there's a lot of JSON which is basically one giant endless line which wouldn't fit even on a 16K screen, so that you can read it properly. And that's the problem for me: I tried a few editors, sublime included, but I can't make this particular line become more readable and formatted. Unfortunately, it seems that exactly in these one or two endless lines is the places where 'waterfox' should be added as an allowed app, so that the extension can work with Waterfox. So, the only possibility left: to ask here for someone who has the editors and the experience to modify JSON code. I'll attach the file here, so you can download and modify it.

Here are... "directions" on how to modify it - the same I modified the python files for Linux and Windows: use Ctrl+F to find where it reads 'firefox' (altough IDK if it will use the same type of quotes in JSON code), copy the entire line and paste it under the line with 'firefox'. Then edit the second 'firefox' to be 'waterfox' and pretty much anywhere it reads 'firefox' there should be added a line with 'waterfox'. You can download either the Windows or Linux.py files from the repo, so you can compare with the linux file how I did it. Simply use Ctrl+F on the Linux file to find "waterfox" (there should be 5 uses of that word). In a similar way another "line" with 'waterfox' should be added to that JSON code in the mac file.

Picture_created_01-07-2025_21-48-24.png

If you wish, your forum username will be credited in the readme.md as a contributor for the mac.py version or if you wish to remain anonymous - your wish will be respected either way. I might even add you as a maintaner of the mac version (again - only if you want) because it seems highly unlikely that even in the future I'll learn how to read 100,000 characters in a single endless line.
 

Attachments



It's probably not really all one single line. It just seems that way.


There is a shell script in that thread, I wrote to fix the single line thing.
But that's only half the problem.


This might fix the other half, after you get the line returns fixed.
 
Actually, it IS one single line - all text editors, sublime included, show it a single line. This is what it looks like in gedit and that's just about 20% of the whole thing.

Picture_created_02-07-2025_01-31-41.png
And I know how to replace words but I don't wanna replace, I wanna add some code for waterfox, so that the extension keeps working with all the browsers it's installed in. Replacing the word is the easiest thing but that's not really a fix, is it?
 
Just a thought, have you considered getting in touch with Alex Kontos?

Waterfox was created by Alex Kontos. He initially launched the 64-bit browser for Windows in March 2011. While System1 acquired Waterfox in 2019, Alex Kontos announced the browser's return to independent status in July 2023.

I have been using Waterfox for maybe 10 years, but I have not ever dug into the code.
 
Actually, it IS one single line - all text editors, sublime included, show it a single line. This is what it looks like in gedit and that's just about 20% of the whole thing.

We can test that theory. Make a copy of your json file and run this script on it.

Code:
#!/bin/bash

# Input file
input_file="macOS.json"
# Output file
output_file="output.json"

# Replace carriage return characters with newline and save to output file
tr '\r' '\n' < "$input_file" > "$output_file"

echo "Replacement complete. Check the output file: $output_file"
 
For easier use I named the file input.json and gave it the same name in the script. And yet:

Code:
[rado@arch]: /B/123>$ ./replace.sh
./replace.sh: line 9: lt: command not found
./replace.sh: line 9: input.json: command not found
./replace.sh: line 9: gt: command not found
./replace.sh: line 9: output.json: command not found
 
lt and gt are bash commands, not python commands. Not json either.
I've also noticed some of your key value pairs don't have double quotes.
This is valid for libraries, but it isn't valid for json.
 
Can't find the thread where this was solved, but basically there is mac2unix command to convert line endings.
There is also unix2mac to reverse it once you're done editing.

@dos2unix helped me solve the problem, maybe he knows that thread.

Also btw. to format json file I use VSCode -> right click -> format file, you'll need json extension capable of formatting.
 


Follow Linux.org

Members online


Top