Difference between revisions of "WebKit UserAgent Override"
Line 1: | Line 1: | ||
− | + | = webOS 3.0.0 and greater = | |
== What It Is and What It Does == | == 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. | The user-agent override is a feature that allows one to do a wholesale replacement of the user-agent. | ||
Line 16: | Line 16: | ||
... | ... | ||
</nowiki></pre> | </nowiki></pre> | ||
+ | |||
+ | == 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 only uses a "token" feature, as described below. | ||
+ | |||
+ | 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. I will describe below how to add these tokens. 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. | ||
+ | # Then create a subdirectory for the user-agent you want to try to mimic. For this example, create iphone. You should have /etc/palm/uatokens/iphone/. | ||
+ | # Then, create the following files, with the following content: | ||
+ | #* /etc/palm/uatokens/iphone/cpu:<pre><nowiki>CPU iPhone OS 5_0 like Mac OS X</nowiki></pre> | ||
+ | #* /etc/palm/uatokens/iphone/iphone:<pre><nowiki>iPhone</nowiki></pre> | ||
+ | #* /etc/palm/uatokens/iphone/mobile:<pre><nowiki>Mobile/9A334</nowiki></pre> | ||
+ | #* /etc/palm/uatokens/iphone/safari:<pre><nowiki>Safari/7534.48.3</nowiki></pre> | ||
+ | #* /etc/palm/uatokens/iphone/version:<pre><nowiki>Version/5.1</nowiki></pre> | ||
+ | #* /etc/palm/uatokens/iphone/webkit:<pre><nowiki>AppleWebKit/534.46</nowiki></pre> | ||
+ | |||
+ | Your User-Agent will now look like this (Pre3, with tokens to make it look like an iPhone running iOS 5.1): | ||
+ | <pre><nowiki>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</nowiki></pre> | ||
== Ok, great, but this overrides LunaSysMgr, right? == | == Ok, great, but this overrides LunaSysMgr, right? == | ||
Nope! LunaSysMgr uses a separate instance of WebKit with different preferences. | Nope! LunaSysMgr uses a separate instance of WebKit with different preferences. |
Revision as of 05:33, 26 August 2012
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.conf configuration file.
To change the User-Agent, you need to edit this (/etc/palm/browser.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 only uses a "token" feature, as described below.
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. I will describe below how to add these tokens. 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.
- Then create a subdirectory for the user-agent you want to try to mimic. For this example, create iphone. You should have /etc/palm/uatokens/iphone/.
- Then, create the following files, with the following content:
- /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:
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.