如何更改firefox位置设置

Cha*_*ngh 5 browser firefox firefox-addon

我想将我们的浏览器位置更改为美国请帮助我更改firefox位置,即地理位置lcoation进行测试.

Rob*_*b W 8

nmaler提到的两个首选项是定点.此外,您不需要(本地)服务器,数据:-URI也可以正常工作.

例如,如果使用值设置首选项geo.wifi.uri(at about:config):

data:,{"location":{"lat":1.2,"lng":3.4},"accuracy":4000}
Run Code Online (Sandbox Code Playgroud)

然后通过从JS控制台运行以下代码进行测试:

navigator.geolocation.getCurrentPosition(pos => console.log(pos.coords));
Run Code Online (Sandbox Code Playgroud)

然后你会看到恶搞成功了:

Coordinates { latitude: 1.3, longitude: 11, altitude: 0, accuracy: 4000, ... }
Run Code Online (Sandbox Code Playgroud)

如果您需要生成有效数据:-URL with 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's pref to geoWifiUrl.
Run Code Online (Sandbox Code Playgroud)


nma*_*ier 7

最简单的方法是设置自己的地理定位模拟服务器并更改一些首选项:

  1. 创建(或更改)布尔值geo.provider.testing,将其设置为true.这将强制网络提供商(而不是OS级别的地理位置提供商,如果有的话).
  2. 更改geo.wifi.uri模拟服务器的URI,例如http://localhost:8888/
  3. 启动模拟服务器并重新启动Firefox.
  4. 测试那些东西是有效的,例如

您可以直接更改首选项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
Run Code Online (Sandbox Code Playgroud)

  • @Blagoh OP希望"将我们的浏览器位置更改为美国".什么比白宫更"美国"?WalMart或MacDownloads或CocaCola总部可能:p (2认同)

gre*_*uze 6

如果您想为HTML5 Geolocation API欺骗您的位置,您可以按照以下步骤操作:

  • 去about:config。
  • 输入geo.wifi.uri.
  • 将值更改为如下所示:

    数据:应用程序/json,{“位置”:{“纬度”:40.7590,“lng”:-73.9845},“准确度”:27000.0}
    

    (lat和lng值确定您所在位置的纬度和经度。)

  • 恭喜你,你现在在时代广场!(您可以在此处测试结果。)

请注意,如果您想阻止网站从您的 IP 地址获取位置,您不能在应用程序层执行此操作 - 唯一的方法是代理。

  • 我已经测试过了。有用!!感谢分享这个。 (2认同)