Difference between revisions of "WebKit UserAgent Override"
(misc cleanup, added some clarification) |
|||
Line 10: | Line 10: | ||
Under the "[General]" section, you will need to add the "UserAgentOverride" key. An example is below: | Under the "[General]" section, you will need to add the "UserAgentOverride" key. An example is below: | ||
− | <pre | + | <pre> |
[General] | [General] | ||
... | ... | ||
UserAgentOverride=Mozilla/5.0 (Windows NT 6.1; WOW64; rv:15.0) Gecko/20120427 Firefox/15.0a1 | UserAgentOverride=Mozilla/5.0 (Windows NT 6.1; WOW64; rv:15.0) Gecko/20120427 Firefox/15.0a1 | ||
... | ... | ||
− | + | </pre> | |
== Ok, great, but this overrides LunaSysMgr, right? == | == Ok, great, but this overrides LunaSysMgr, right? == | ||
Line 22: | Line 22: | ||
= webOS 2.2.4 and earlier = | = webOS 2.2.4 and earlier = | ||
== What It Is and What It Does == | == What It Is and What It Does == | ||
− | Earlier versions of webOS do not have a wholesale override feature. It | + | Earlier versions of webOS do '''not''' have a wholesale override feature. It does, however, have a "tokens" feature, which can '''add''' to your user-agent. |
− | The WebKit implementation reads the contents of each file in the tokens directory, strips the spaces from it, and then appends this to the user-agent string after a semi-colon | + | The WebKit implementation reads the contents of each file in the tokens directory, strips the spaces from it, and then appends this to the user-agent string after a semi-colon. Some websites may only read "iphone" or "iOS" from the user-agent and think that you have an iPhone. |
== How to add tokens to the User-Agent == | == How to add tokens to the User-Agent == | ||
# Create a directory somewhere. Either in /etc/palm/ or somewhere in /media/internal/. I created /etc/palm/uatokens/ so that I can create different subdirectories for different types of user agents. | # Create a directory somewhere. Either in /etc/palm/ or somewhere in /media/internal/. I created /etc/palm/uatokens/ so that I can create different subdirectories for different types of user agents. | ||
− | # | + | # Create a subdirectory for the user-agent you want to try to mimic. For example, create iphone. You should have /etc/palm/uatokens/iphone/. |
− | # | + | # For each "token" you want to add, create a file. For example, to have "<tt>iPhone; Safari/7534.48.3; AppleWebKit/534.46; Version/5.1; Mobile/9A334; CPUiPhoneOS5_0likeMacOSX</tt>" in your user-agent, create the following: |
− | #* /etc/palm/uatokens/iphone/cpu:<pre | + | #* /etc/palm/uatokens/iphone/cpu:<pre>CPU iPhone OS 5_0 like Mac OS X</pre> |
− | #* /etc/palm/uatokens/iphone/iphone:<pre | + | #* /etc/palm/uatokens/iphone/iphone:<pre>iPhone</pre> |
− | #* /etc/palm/uatokens/iphone/mobile:<pre | + | #* /etc/palm/uatokens/iphone/mobile:<pre>Mobile/9A334</pre> |
− | #* /etc/palm/uatokens/iphone/safari:<pre | + | #* /etc/palm/uatokens/iphone/safari:<pre>Safari/7534.48.3</pre> |
− | #* /etc/palm/uatokens/iphone/version:<pre | + | #* /etc/palm/uatokens/iphone/version:<pre>Version/5.1</pre> |
− | #* /etc/palm/uatokens/iphone/webkit:<pre | + | #* /etc/palm/uatokens/iphone/webkit:<pre>AppleWebKit/534.46</pre> |
− | # | + | # Edit /etc/palm/browser-app.conf as below (the trailing '/' on the path is MANDATORY): |
− | <pre | + | <pre>[General] |
... | ... | ||
UserAgentTokensPath=/etc/palm/uatokens/iphone/ | UserAgentTokensPath=/etc/palm/uatokens/iphone/ | ||
... | ... | ||
− | + | </pre> | |
Latest revision as of 01:40, 21 July 2013
webOS 3.0.0 and greater
What It Is and What It Does
The user-agent override is a feature that allows one to do a wholesale replacement of the user-agent.
How to Override the User-Agent
The BrowserServer loads an instance of WebKit that uses the /etc/palm/browser-app.conf configuration file.
To change the User-Agent, you need to edit this (/etc/palm/browser-app.conf) file, with the proper token.
Under the "[General]" section, you will need to add the "UserAgentOverride" key. An example is below:
[General] ... UserAgentOverride=Mozilla/5.0 (Windows NT 6.1; WOW64; rv:15.0) Gecko/20120427 Firefox/15.0a1 ...
Ok, great, but this overrides LunaSysMgr, right?
Nope! LunaSysMgr uses a separate instance of WebKit with different preferences.
webOS 2.2.4 and earlier
What It Is and What It Does
Earlier versions of webOS do not have a wholesale override feature. It does, however, have a "tokens" feature, which can add to your user-agent.
The WebKit implementation reads the contents of each file in the tokens directory, strips the spaces from it, and then appends this to the user-agent string after a semi-colon. Some websites may only read "iphone" or "iOS" from the user-agent and think that you have an iPhone.
How to add tokens to the User-Agent
- Create a directory somewhere. Either in /etc/palm/ or somewhere in /media/internal/. I created /etc/palm/uatokens/ so that I can create different subdirectories for different types of user agents.
- Create a subdirectory for the user-agent you want to try to mimic. For example, create iphone. You should have /etc/palm/uatokens/iphone/.
- For each "token" you want to add, create a file. For example, to have "iPhone; Safari/7534.48.3; AppleWebKit/534.46; Version/5.1; Mobile/9A334; CPUiPhoneOS5_0likeMacOSX" in your user-agent, create the following:
- /etc/palm/uatokens/iphone/cpu:
CPU iPhone OS 5_0 like Mac OS X
- /etc/palm/uatokens/iphone/iphone:
iPhone
- /etc/palm/uatokens/iphone/mobile:
Mobile/9A334
- /etc/palm/uatokens/iphone/safari:
Safari/7534.48.3
- /etc/palm/uatokens/iphone/version:
Version/5.1
- /etc/palm/uatokens/iphone/webkit:
AppleWebKit/534.46
- /etc/palm/uatokens/iphone/cpu:
- Edit /etc/palm/browser-app.conf as below (the trailing '/' on the path is MANDATORY):
[General] ... UserAgentTokensPath=/etc/palm/uatokens/iphone/ ...
Your User-Agent will now look like this (Pre3, with tokens to make it look like an iPhone running iOS 5.1):
Mozilla/5.0 (Linux; webOS/2.2.4; U; en-US) AppleWebKit/534.6 (KHTML like Gecko) webOSBrowser/221.56 Safari/534.6 Pre/3.0; iPhone; Safari/7534.48.3; AppleWebKit/534.46; Version/5.1; Mobile/9A334; CPUiPhoneOS5_0likeMacOSX
Ok, great, but this overrides LunaSysMgr, right?
Nope! LunaSysMgr uses a separate instance of WebKit with different preferences.
Platform Independent Notes
LunaSysMgr loads an instance of WebKit, and then reads WebKit settings from /etc/palm/browser.conf. BrowserServer loads another instance of WebKit, and then reads WebKit settings from /etc/palm/browser-app.conf. This is why you can change the User-Agent in one, and not affect the other.