-
Notifications
You must be signed in to change notification settings - Fork 32
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
Request Mobile Site preference #42
Conversation
Hey this is great! Thanks a bunch. Sorry it took so long for me to check it out. I've tested it on your branch and it seems to work, but for some reason I'm having issues like these: – Preference can carry to new windows So, generally, it does what you'd think after a couple tries, but the behavior isn't consistent. Not sure how to approach this—did you run into any of these issues before? |
Here's an alternative scenario: That way you can just smash the shortcut to get a mobile redirect on a site you just loaded—maybe more forgiving? |
Hey! Thanks for giving it a look. I could see this being an array of sites in your user preferences
To summarize, the primary bug of requiring a new window to take effect can likely be resolved within |
Gotcha—my issue with “Navigating to a different website still loads desktop” was related to the original window bug, I think. Just got weirded out by the behavior of the thing.
|
I think that this is a nice first implimentation. Perhaps if there is a roadmap for additional functionality we could append that second note! |
…on the app's first window
…pp-wide parameters without adding weight to the code.
…g it will reload all windows, and new windows will take the parameter from the app's menu. the preference still works as expected. 2) the toggle is disabled on windows first load, to avoid an error when setting the UA before the webview session is ready.
About those commits earlier: I couldn't find a way to enforce the UA on a window basis (once it's set on one webview, all other ones follow), so I made the changes to make it an app-wide parameter. You can test it the following way: Disabling The key in @jondashkyle Will let you have a look at it, and if that looks okay I'll merge into /dev. |
This looks great! Clicked around a bit and was able to replicate everything you mentioned above. Seems good to me! |
Is this already available in the I added |
Afraid you'd have to build from source on |
Thanks for replying, no problem! Could you point me out how to do it? Never built up an electron app from source. |
I've added some instructions there: https://github.com/thmsbfft/oryoki/blob/dev/README.md#build-from-source If you follow that from the |
Working well! I'd suggest to add to the instructions for building the app from source, to add
after you did Thanks! |
Added that, thanks for the suggestion—and glad packaging worked out! |
That was pretty easy. This creates the ability to set the useragent (UA) to load mobile sites. It does so by updating the
webview
’suseragent
. For a good example navigate to Twitter, The New York Times, Google or Github.A few things to note:
Preferences
Updated the preferences with a new one called
request_mobile_site
, which defaults tofalse
. There is also a menu item toggle under Tools called Request Mobile Site. The shortcut isCmdOrCtrl+Alt+U
, asM
was taken.U
for useragent? Not the clearest… Toggling this option updates the UA and reloads the site to reflect the change.UA Storage
We must store the mobile/desktop useragents. I couldn’t quickly find a way of requesting the default Electron UA. The webview must be mounted to the DOM before you can request it’s current UA. To get around this, I define the UA through
setAttribute
, as suggested here to avoid first load without the correct UA defined, effectively overwriting any requests for the current UA as a way of storing the default/desktop.Default (desktop) is what my current machine reads:
Mobile is an iPhone running iOS 11 in Safari:
This is probably fine for OSX releases, but we’ll want to find a better way of doing this if building for another OS.