MacGapProject / MacGap1

Desktop WebKit wrapper for HTML/CSS/JS applications.
Other
3.55k stars 208 forks source link

API call to set User-Agent #88

Closed wfaulk closed 10 years ago

wfaulk commented 10 years ago

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.

tmeusburger commented 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.

jeff-h commented 10 years ago

@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.

tmeusburger commented 10 years ago

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.

jeff-h commented 10 years ago

This is now committed. Please reopen this issue if you have any problems or feedback.

fluke commented 9 years ago

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

jeff-h commented 9 years ago

Just confirming, you're using MacGap 1 for this?

fluke commented 9 years ago

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.