Sailfish 3.4 Browser User Agent

Before anyone asks, I have searched and I know this topic comes up fairly frequently. I believe I have gone above and beyond what most do trying to find a complete solution. I am hoping someone here has some further insight or advice and can help.

Issue:
Sailfish has issues with MMS messages for US users, that is well known. I have access to SMS/MMS via a website so I didn’t imagine this would be an issue for me. Sailfish-browser however gives a user agent that is rejected by the website.

What I have tried:

  • I have changed the User Agent string and, provided the user agent has Firefox 87.0, it works fine. Everything functions as it should or as much as I care to check. Upon closing the browser this user agent quickly reverts to the original.

  • There is a node.js and electron wrapper for the site and I can build it, but that is a ton of overhead for something that works quite well on the normal browser given the correct UA string.

  • I created a webview wrapper for the site that passes the correct user agent to the site and it works ok for viewing the site, but nothing can be downloaded as webview doesn’t support protobuf blobs. While the Sailfish-browser handles them just fine.

  • I have completely dug into Firefox documents, and it seems like sailfish-browser uses something very similar to Auto.cfg as any changes anywhere revert after browser close.

AutoConfig files can be used to set and lock preferences that are not covered by group policy on Windows or the policies.json for Mac and Linux. This method can be used to automatically change user preferences or prevent the end user from modifying specific preferences by locking them.

  • A subset of the above, I have tried modifying prefs.js located at /user/share/sailfish-browser/data/prefs.js and the prefs.js located at /home/defaultuser/.mozilla/mozembed/prefs.js

    • For that matter why are there two user_prefs (with a few similar strings) in the first place?
  • I have tracked down and modified ua-update.json.in which is an update package for the ua-update.json (or the site specific settings for user agents) and transferred into the ua-update.json via a script invoking sed. This failed as there is a verification check to ensure people don’t try what I did.

  • I tracked down and attempted to add the site and user agent string to the local ua-update.json located in /home/defaultuser/.mozilla/mozembed/ua-update.json which also didn’t work due to either file verification or the aforementioned Auto.cfg like function.

  • I forked the Sailfish-browser github, modified the ua-update.json and hosted, but you guessed it, due to either verification or the auto.cfg type function I couldn’t get the changed site in about:config (also BOTH prefs.js) to stick.

    • I did push to the master, but I don’t really use github so I am not sure if I did it correctly and all attention seems to be on 4.0, which I understand.

I am kind of at the end of my rope here and getting ready to fire up Sailfish SDK to create another different webapp that might be able to handle the site. But I feel like I am taking crazy pills, why can nothing be changed with the default browser? Why can’t I add my own site specific UA’s locally?Pushing sites into the ua-update.json that many other people wont use or care about seems like a waste (take a look at the ua-update.json there are a lot of sites I wager most have never heard of). A user-agent wouldn’t be a security risk I can’t imagine…Or even just leave the site specific user agent json unlocked for local edits.

I know the common advice in the forums is “just use a different browser,” but I don’t think that is either right or even a good answer, plus it is added overhead and clutter, and being linux there should be some way I can accomplish this.

I apologize if I sound a bit snippy, but I have spent weeks poring over documents, and files, and creating partial solutions and the whole thing seems to be easily avoided.

Unfortunately the browser in 4.0 would also be rejected unless the UA is changed…

I welcome thoughts and/or possible solutions I haven’t thought of.

1 Like

I finally have a solution, courtesy of someone I only know as xaos who dredged the depths of github.

via command line:

CUSTOM_UA=“Mozilla/5.0 (Linux; U; Sailfish 3.0; Mobile; rv:45.0) Gecko/45.0 Firefox/45.0 SailfishBrowser/1.0” sailfish-browser www.google.com

Replace the example with whatever user agent you want. I tested and it works. Now I just need to craft a .desktop file

6 Likes

While it’s completely overkill for just one site, and not exactly trivial to set up, privoxy can be used to set user agents per site.
And much more.

Your solution is good for that specific case though.

2 Likes