Hi,
the new web-extension API does not allow add-ons to edit about:config references. We can change the user.js file on our desktop operating systems. But how we can edit user.js on mobile Android Firefox? We can change them manually from about:config but these takes long time. Also I always reset my settings/or I reset the mobile phone completely. It is difficult to set all these settings from mobile.
It would be great if you have an idea for Android Firefox.
Thank you
The entire Mozilla profile is not visible to the non-rooted Android user.
http://codeverge.com/mozilla.support.firefox/why-would-mozilla-developers-disallow/2044673
Nothing much you can do except root the phone - its an Android permissions thing, only the owner app can access its stash, so unless Mozilla build that in, and I doubt it, it'll have to be manually via about:config
FF accounts can sync some stuff, FWIW (not much, search for services.sync.prefs in about:config)
@Thorin-Oakenpants but many users use non-rooted phone. %99 of user.js preferences are about privacy and you are telling me to use sync (the cloud thing) ? :)
There should be tricks to change the preferences. The only way is not to use user.js file. For example:
1- we can try to write user-script for Greasemonkey or violentmonkey which executes a script on about:config page ?
2- remote debugging about:config page from destkop firefox ?
3- execute a javascript from url-bar (like bookmarklet) ?
Or any other tricks/ideas?
Thank you
1- With the removal of XUL, you cannot change about:config entries via extensions (some are available thru APIs, but very little).
3- pretty sure you can't run JS from the urlbar (or its a pref we set for security reasons)
2- remote debugging?
Well, we can reset prefs via Scratchpad using scripts - see https://github.com/ghacksuserjs/ghacks-user.js/wiki/3.1-Resetting-Inactive-Prefs-%5BScripts%5D#small_orange_diamond-how-to-run-a-scratchpad-script . Is scratchpad available on mobile, and can the scratchpad write values?
2 - Android has strict permissions and a single user by default.
Can't find any way to bring up a Scratchpad or other tools in FF on Android. - Menu>Settings>Advanced>Remote Debugging via USB> toggle on/off .. now what.
https://www.howtogeek.com/125769/how-to-install-and-use-abd-the-android-debug-bridge-utility/
All this is about as much work as rooting your phone .. 99% of people aren't gonna do it .. and that's IF its still even possible to run a script to change prefs
I try remote debugging from my desktop Firefox. I did not installed any extension or ADB on my operating system. It is very easy to debug remote android.
I write a simple javascript to execute on about:config page. I tested it. I write it here. maybe someone will need it.
var user_pref = function(pref, val){
try{
if(typeof val == "string"){
Services.prefs.setStringPref(pref, val);
}
else if(typeof val == "number"){
Services.prefs.setIntPref(pref, val);
}
else if(typeof val == "boolean"){
Services.prefs.setBoolPref(pref, val);
}
} catch(e){
console.log("pref:" + pref + " val:" + val + " e:" + e);
}
}
//paste your user.js file content here
So this works then? You can apply all your changes in a single script? Do the prefs pasted underneath only take the active ones? I take it you were running 57+? I've never connected via remote debugging, we'll need proper documentation on steps, which we should write up as a wiki page
@Thorin-Oakenpants yes it works. I tested it.
First you start remote debugging from desktop Firefox (without any extension or Android-SDK). Desktop Firefox has build-in WebIDE module. After you connect to android firefox app, you go to about:config page. You can also inject a script to a web page that opened from Android. Copy my script, also copy your userjs file below it, and execute whole script to android firefox.
I am using:
"only take the active ones?" --> I don't know if I understand your question exactly. But I see this: If I will call my user_pref method with any parameter it works. I mean If I have "media.navigator.this.pref.is.not.exist" it works. But does it matters ? Who cares if I have a pref which is not using by anyone?...
I think this topic should be clearly documented. Mobile privacy is more terrible status than Desktop.
"only take the active ones?" --> I don't know if I understand your question exactly.
your code
//paste your user.js file content here
// user_pref("one", "this is an inactive pref as it is commented out")
user_pref("one", "this is an active pref as it is not commented out")
Stupid question (forgot to screw my head on), because the inactive prefs are comment lines and won't be executed. Just want to check that FF reads all the syntax OK and doesn't try to parse something silly
I think this topic should be clearly documented
Agree
But does it matters ?
Nah, it's just a pref entry that will do nothing and never be called
Do I have to do everything? /s
Should we create a wiki page 1.6 Android [non-rooted]
:+1: Android [Generic]
I don't quiet like the name, but generic doesn't mean anything. The page can also have the basic info to stop FF, force unload it, and where to put the user.js, so basically a sentence or two about rooted, but the whole thing is mainly about non-rooted. I'd probably just call the page Android
...but my question wasn't about the name, it was should we do the page
I didn't mean that as title, but as an idea that a wiki page for non-rooted devices only seems limited IMHO
I managed to set some Firefox preferences on my non-root Android using TerkiKerel's javascript. It is straight forward, but not entirely obvious at first. Here are some notes which might help towards an Android wiki page.
Using remote debugging to inject user.js preferences to Android Firefox
mozilla - Debugging_Firefox_for_Android_over_Wifi
Troubleshooting, if the device is not seen (note any settings changes for reversal later):
(Visit the troubleshooting link on the Mozilla page for more details.)
mozilla - Debugging_Firefox_for_Android_with_WebIDE
Troubleshooting, if the device is not seen (note any settings changes for reversal later):
(Click the troubleshooting link on the Mozilla page for more details.)
var user_pref = function(pref, val){
try{
if(typeof val == "string"){
Services.prefs.setStringPref(pref, val);
}
else if(typeof val == "number"){
Services.prefs.setIntPref(pref, val);
}
else if(typeof val == "boolean"){
Services.prefs.setBoolPref(pref, val);
}
} catch(e){
console.log("pref:" + pref + " val:" + val + " e:" + e);
}
}
//paste your user.js file content here
@icpantsparti sweeeeet, that's awesome :kiss: thanks for that. I'll get around to this sometime after FF58alpha user.js is released
May be also worth a mention on a Android wiki page. You can view the prefs you have set on about:support, but if you want to get the contents of prefs.js on non-root Android.
Enter into the firefox url address bar: file:///data/data/org.mozilla.firefox (if using beta append _beta). Navigate your way through to the file inside your profile directory, such as: file:///data/data/org.mozilla.firefox/files/mozilla/????????.default/prefs.js
Tap on the prefs.js file and it displays, long press, select all, copy and paste into a text editor type app (such as QuickEdit, etc) for saving. (Note that firefox updates the prefs.js file on app exit so settings made during the current session would not be visible yet.)
That's handy. Can't be arsed firing up FF on my phone, but you can also get a nice list via about:support > Important Modified Preferences
https://github.com/ghacksuserjs/ghacks-user.js/wiki/1.6-Firefox-Android - first draft
ToDo:
PS: Many thanks to @icpantsparti and @TerkiKerel - there's only so much of me, so you'll have to share :kiss: :kiss:
If anyone wants to provide some pics, proofread the wiki entry, or write up the tiny rooted section, then feel free
I am rooted but FF wouldn't pick up user.js for some reason. This method worked perfectly. THANK YOU.
Suggesting this for rooted:
All steps are performed on your Android.
*Bring up the list of running apps by tapping the usually square button and stop Firefox by swiping it away.
*Start your file manager that supports root, such as https://f-droid.org/packages/com.ghostsq.commander/.
*Copy your user.js file to your profile folder at data/data/org.mozilla.firefox/files/mozilla/[random_string].default.
*Set permissions on the file to match other files in the directory.
*Start Firefox, go to about:config and confirm user.js was recognized. Be sure to check the last line as well, in case processing was stopped in the middle due to some error.
*If you delete user.js from your profile directory, the applied settings will remain until you or the application changes them. If you don't delete the file, all settings in the file will be reapplied on each Firefox start.
*If no settings from user.js are applied, follow the Non-Rooted method below.
@jghq Thanks for the feedback. I'll reopen this to remind me to write up the rooted section
bump!
reminder to add the text re rooted devices and close this
Done
Most helpful comment
I managed to set some Firefox preferences on my non-root Android using TerkiKerel's javascript. It is straight forward, but not entirely obvious at first. Here are some notes which might help towards an Android wiki page.
Using remote debugging to inject user.js preferences to Android Firefox
1) Choose a) Wi-Fi (easier) or b) USB connection
1a) Connecting Firefox on your Desktop Computer and Android Device via Wi-Fi
mozilla - Debugging_Firefox_for_Android_over_Wifi
Troubleshooting, if the device is not seen (note any settings changes for reversal later):
(Visit the troubleshooting link on the Mozilla page for more details.)
1b) Connecting Firefox on your Desktop Computer and Android Device with a USB cable
mozilla - Debugging_Firefox_for_Android_with_WebIDE
Note: to unhide "Developer options" tap "Build number" 7 times (Settings app|About Device)
Troubleshooting, if the device is not seen (note any settings changes for reversal later):
(Click the troubleshooting link on the Mozilla page for more details.)
2) Remote access
3) Inject the preferences
4) Finish