Closed wfaulk closed 10 years ago
This would be incredibly useful to me as well. Many websites have bad UX when it comes to locking down certain user agents.
Anyways, I ran into this exact same problem. Would be awesome to get this implemented.
@wfaulk and @tmeusburger — I've written some code which adds a javascript method to set a custom user agent. The code is at https://github.com/maccman/macgap/pull/93 — let me know if you have any problems merging it in and using it.
Thank you @jeff-h, when I get a chance i'll merge in your code and play around with macgap some more. I appreciate you putting the time in to resolve this.
This is now committed. Please reopen this issue if you have any problems or feedback.
Setting custom user agent doesn't seem to be working or I've made a mistake somewhere:
<script type="text/javascript" charset="utf-8">
macgap.app.setCustomUserAgent('Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2272.118 Safari/537.36');
macgap.growl.notify({title: 'MacGap', content: navigator.userAgent});
</script>
Also how do I go about debugging MacGap apps, finding it a bit hard to figure out. @jeff-h
Just confirming, you're using MacGap 1 for this?
Hey. I cloned the repo and it worked, the macgap gem is pretty old. I was trying to make a MacGap version of web.whatsapp.com but that didn't end up working.
I am trying to create a macgap application for the VMware vCenter Web Client. It checks User-Agent and shows a banner if it's not one of the supported clients. It might also change its feature set based on User-Agent.
It would be nice if macgap provided an API call to set the User-Agent to an arbitrary value.