如何更改Firefox位置设置 [英] How to change firefox Location setting

查看:567
本文介绍了如何更改Firefox位置设置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I want to Change our Browser location to usa Please help me changing firefox location i.e geolocation location for testing.

推荐答案


nmaler提到的两个偏好是不容置疑的。另外,您不需要(本地)服务器,也可以使用data:-URI。

The two preferences mentioned by nmaler are spot-on. Additionally, you don't need a (local) server, a data:-URI works fine too.

例如,如果您将首选项设置为 geo.wifi.uri (位于 about:config ),值:

For example, if you set the preference geo.wifi.uri (at about:config) with value:

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

,然后从JS控制台运行以下命令进行测试:

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 spoof succeeded:

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

如果需要生成有效的数据:-带有JavaScript的URL(例如,附加代码中的URL),请使用以下内容。请注意,我使用 encodeURIComponent 以防万一 pos 对象包含某种特殊字符,例如(这不太可能,但是比后悔更安全):

If you need to generate a valid data:-URL with JavaScript (e.g. in add-on code), use the following. Note that I use encodeURIComponent just in case the pos object somehow contains special characters such as % or # (this is unlikely, but better safe than sorry):

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.

这篇关于如何更改Firefox位置设置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆