如何在Firefox 42+中检测用户是否正在使用跟踪保护 [英] How to detect if a user is using tracking protection in Firefox 42+

查看:72
本文介绍了如何在Firefox 42+中检测用户是否正在使用跟踪保护的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Firefox已在v42.0中启动了名为跟踪保护的功能.它阻止了一些跟踪脚本,例如Google Analytics(分析),Marketo,LinkedIn等.

Firefox has launched a feature called Tracking protection in v42.0. It blocks several tracking scripts such as Google Analytics, Marketo, LinkedIn, etc.

我试图通过navigator.DoNotTrack检测到它,但是在两种情况下(在常规模式下浏览和在私有模式下使用Mac 4上的Firefox 42.0),它都会返回unspecified.

I was trying to detect it through navigator.DoNotTrack, but it returns unspecified in both cases – browsing in regular mode, and browsing in private mode – using Firefox 42.0 on Mac.

由于navigator.DoNotTrack失败,我如何在JavaScript中检测用户是否正在浏览具有跟踪保护功能的网站?

How can I detect in JavaScript whether a user is viewing the website with the Tracking protection on, since navigator.DoNotTrack fails?

推荐答案

">不跟踪" 首选项.它不会告诉跟踪保护是否是另一种功能,已启用.在私人浏览模式下会自动启用跟踪保护,但是用户可以更改about:config 中的设置以使其全时启用.

navigator.donottrack only shows the setting of the "Do not track" preference. It does not tell if tracking protection, which is a different feature, is enabled. Tracking protection is enabled automatically when in private browsing mode, but users can change a setting in about:config to have it enabled full time.

虽然您无法直接判断是否启用了该功能,但可以通过以下方式检查其效果:

While you can't tell directly if the feature is enabled, you can check for its effects with something like this:

var canreach = false;
$(function() {
    $('<img/>')
        .attr("src", "//apps.facebook.com/favicon.ico")
        .load(function(){canreach = true;})
        .css("display", "none")
        .appendTo(document.body);
});

Firefox使用

Firefox uses a list obtained from Disconnect for its tracking protection; just use a domain that you know is on that list, and an image that you know will exist.

当然,这可能会标记出导致图片无法加载的多种原因,包括网络连接问题,广告拦截软件,过滤代理等.

Of course, this could flag any number of causes for the image not to load, including network connectivity problems, ad blocking software, filtering proxies, etc.

这篇关于如何在Firefox 42+中检测用户是否正在使用跟踪保护的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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