thebnich / desktop-by-default

Enables desktop mode by default on Firefox for Android.
Mozilla Public License 2.0
0 stars 1 forks source link

WebExtensions support #1

Open thebnich opened 7 years ago

thebnich commented 7 years ago

This add-on needs to be rewritten to use WebExtensions in order to be compatible with Firefox 57+.

I've been looking at the WebExtensions APIs, and there is an onBeforeSendHeaders hook that would allow the browser to change the UA sent to web pages. There's even an MDN example for a UA switcher WebExtension, but that example is probably not compatible with Firefox for Android since it uses the browserAction API (which is unsupported according to this).

This is only part of the puzzle, though: there's also the JS navigator.userAgent property that certain sites use instead of the HTTP header. On first glance, I don't see any way to change this property using WebExtensions.

Also, I can't find any hooks for the actual browser UI, so I don't think there's any way to keep the Request Desktop Site checkbox synced like the add-on does now. That means we'd need a separate UI managed by the add-on to allow users to turn RDS off. Browser actions aren't supported, but page actions might work (though apparently setIcon isn't supported, so I don't know how you could tell different page actions apart from each other!)

PyvesB commented 5 years ago

In my opinion, it would make more sense to integrate such a widely-requested feature into Firefox directly. Add-ons, especially on the Android version of Firefox, are used by a tiny fraction of users. The relevant bug is here for reference.