As of version 10.50 and 10.51 there is still no Geolocation API support built into Opera – the short intermezzo in some development snapshots left aside.
Thus I wrote a UserJS to address this issue. It returns a hard coded geographic position via a standard Geolocation API if requested by the browser and if permitted (on a case-by-case basis) by the user. So it's mostly useful for peoples hardly-moving desktop machines. 😉
It supports the geolocation methods getCurrentPosition(…), watchPosition(…) and clearWatch(…) as well as the interfaces Position and Coordinates for the returned objects up to the point it's reasonable for a static, ie non-moving, geographic location. Thus it virtually emulates the W3C Geolocation API Specification (Editor's Draft 10 February 2010). …
Open the file in a text editor and change the lines between the ”// [user configuration]“, ”// [/user configuration]“ markers, respectively, to reflect your preferred alleged location (in decimals of degrees) and accuracy (in meters).
I took measures to protect the script from being exploited by websites it's run on. I think, it's save – but don't rely on me for that one. You're the judge. 😉
You may test the new functionality on many pages, eg on HTML5Demos.com. Respect the license. Feedback appreciated. Have Fun! :D
Version 1.12 [2010-04-29]
- Stackcheck removed, as it does not work that way in Opera 10.5x. It doesn't contribute to security, anyways, as the sensitive data and the user confirmation code reside in the same function since v1.10.
Version 1.11 [2010-04-23]
- Stackcheck fix.
Version 1.10 [2010-04-23]
- New security concept. Stacktrace checked to ensure website embedded scripts don't ”steal“ the data.
Version 1.05 [2010-04-22]
- Enhance security by restoring .call on each native function ever used.
Version 1.04 [2010-03-25]
- Don't be too strict on highest version of Opera presumed to be supported; now checks for opera.version() < 11.
Version 1.03 [2010-03-19]
- watchPosition(…) fires callback once, then simulates an ”update“ of position every 5 minutes (– just to indicate we're still there and alive. ;P )
Version 1.02 [2010-03]
- Caching core methods for security reasons