title: Spoofing UserAgent in Opera
body: <p>I'm trying to spoof Opera (under Linux) to be another browser, in this case iPad for some testing purposes.
  Now I know sites can check which browser is accessing it using, for example, in PHP <code>$useragent = $_SERVER['HTTP_USER_AGENT'];</code> and in JavaScript <code>navigator.userAgent</code> (or <code>navigator.platform</code>).</p>
  
  <p>In Firefox you can use an addon to easily switch your user agent and other relevant information, but in Opera it seems it bit hard to do.</p>
  
  <p>First in <code>opera.ini</code> you can do:</p>
  
  <pre><code>[User Agent]
  Spoof UserAgent ID=1
  </code></pre>
  
  <p>But this is limited to a predefined list of UserAgents. No room for custom ones.</p>
  
  <p>Also in <code>opera.ini</code></p>
  
  <pre><code>[ISP]
  Id=iPad
  </code></pre>
  
  <p>This will add iPad to the User Agent of Opera. It's a start and works most of the time on the sites.</p>
  
  <p>In <code>opera.ini</code> you can set a 'User JavaScript file' to load a custom JavaScript file before loading a website:</p>
  
  <pre><code>[User Prefs]
  User JavaScript File=/opera_dir/userjs/load.js
  </code></pre>
  
  <p>In <code>load.js</code> you can do:</p>
  
  <pre><code>navigator.userAgent = "Mozilla/5.0 (iPad; U; CPU OS 3_2 like Mac OS X; en-us) AppleWebKit/531.21.10 (KHTML, like Gecko) Version/4.0.4 Mobile/7B334b Safari/531.21.10"
  </code></pre>
  
  <p>Because this file gets executed before loading the website I can modify the UserAgent, but this won't work when a site is checking the UserAgent via PHP, but it works for sites checking with JavaScript.</p>
  
  <p>Is there another way of spoofing a complete custom UserAgent?</p>