How to change the location setting of Firefox

I want to change the location of our browser to the USA. Please help me change the location of Firefox, i.e. the location of the geolocation for testing.

+5
source share
3 answers

The two preferences mentioned by nmaler are in place. In addition, you do not need a (local) server, data: -URI also works fine.

For example, if you set geo.wifi.uri(at about:config) to:

data:,{"location":{"lat":1.2,"lng":3.4},"accuracy":4000}

and then test by running the following from the JS console:

navigator.geolocation.getCurrentPosition(pos => console.log(pos.coords));

then you will see that the parody succeeded:

Coordinates { latitude: 1.3, longitude: 11, altitude: 0, accuracy: 4000, ... }

: -URL JavaScript (, ), . , encodeURIComponent , pos - , % # ( , , ):

var pos = {
    location: {
        lat: 1.2,
        lng: 3.4,
    },
    accuracy: 4000,
};
var geoWifiUrl = `data:,${encodeURIComponent(JSON.stringify(pos))}`;
// TODO: Set geo.wifi.url pref to geoWifiUrl.
+8

- :

  • ( ) geo.provider.testing, true. ( OS, ).
  • geo.wifi.uri URI , . http://localhost:8888/
  • Firefox.
  • , ,

about:config prefs.js . - about:support.

python2 ( ):

import json
import BaseHTTPServer
import SocketServer

PORT = 8888
LAT, LNG = 38.894967, -77.034917


class GeoHandler(BaseHTTPServer.BaseHTTPRequestHandler):
    def do_GET(self):
        self.send_response(200)
        self.send_header("Content-type", "application/json")
        self.end_headers()
        self.wfile.write(json.dumps({
            "location": {
                "lat": LAT,
                "lng": LNG
            },
            "accuracy": 4000
            }))

    def do_POST(self):
        return self.do_GET()

httpd = SocketServer.TCPServer(("", PORT), GeoHandler)
print "serving at port
+7

API HTML5, :

  • about:config.
  • geo.wifi.uri.
  • - :

    data:application/json,{"location": {"lat": 40.7590, "lng": -73.9845}, "accuracy": 27000.0}
    

    ( lat lng .)

  • Congratulations, you are now in Times Square! (You can check the result here .)

Please note that if you want to prevent sites from determining the location by your IP address, you cannot do this at the application level - the only way is to use a proxy.

0
source

All Articles