如何在JavaScript中检测Firefox和Firefox ESR之间的差异? [英] How to detect difference between Firefox and Firefox ESR in JavaScript?

查看:203
本文介绍了如何在JavaScript中检测Firefox和Firefox ESR之间的差异?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在javascript中检测firefox是否已更新ESR.

I need to detect if firefox is ESR updated or not in javascript.

下面的图片是没有ESR的Firefox:

Below image is of Firefox without ESR:

此图像是具有ESR支持的Firefox的图像

This image is of Firefox with ESR support

没有明确的方法找出两者之间的区别.

There's no clear way to spot out the difference between the two.

推荐答案

我不知道是否存在区分ESR和非ESR的通用方法,但是浏览器确实公开了一些信息,可以使区别:内部版本ID,可作为window.navigator.buildID.

I don't know if there's a generic way to distinguish between ESR and non-ESR, however, the browser does expose a bit of information that allows making this distinction: the build ID, which is available as window.navigator.buildID.

例如:

  • 适用于Windows x64的Firefox 52.0(非ESR)具有buildID:"20170302120751"
  • 用于Windows x64的Firefox 52.9.0 ESR具有buildID:"20180621064021"

使用内部版本ID,我们可以找出内部版本是否为ESR.

Using the build ID, we can find out whether the build is ESR or not.

Mozilla在名为 Buildhub 的公共服务上提供有关所有构建的数据. 网络API .我们可以使用以下脚本查询所有Firefox ESR版本的版本ID:

Mozilla provides the data on all builds on a public service called Buildhub, which has a web API. We can query the build IDs for all Firefox ESR releases using the following script:

echo '{
    "aggs": {
        "buildid": {
            "terms": {
                "field": "build.id",
                "size": 1000
            }
        }
    },
    "query": {
        "bool": {
            "filter": [
                {
                    "term": {
                        "source.product": "firefox"
                    }
                }, {
                    "term": {
                        "target.channel": "esr"
                    }
                }
            ]
        }
    },
    "size": 0
}' | \
        curl https://buildhub.prod.mozaws.net/v1/buckets/build-hub/collections/releases/search --data @- | \
        jq -r '.aggregations.buildid.buckets[].key' | \
        sort -u

从今天开始,它将输出以下构建ID:

As of today, this outputs the following build IDs:

20160725105554 20160905130425 20161031153904 20161129180326 20161209150850 20170118123525
20170227085837 20170227131422 20170301181722 20170303022339 20170316213902 20170323110425
20170410145022 20170411115307 20170412142208 20170417065206 20170504112025 20170517122419
20170607123825 20170627155318 20170801170322 20170802111520 20170917103825 20170921064520
20171005074949 20171106172903 20171107091003 20171128121223 20171206101620 20171226003912
20180116134019 20180118122319 20180307131617 20180313134936 20180315163333 20180322140748
20180426000307 20180427183532 20180427222832 20180430140610 20180503092946 20180503164101
20180516032417 20180605153619 20180605174236 20180605201706 20180619102821 20180619173714
20180621064021 20180621121604 20180830204350 20180903060751 20180920175354 20181001135620
20181017185317

实际上,上面的ESR内部版本ID在此列表中,但非ESR不在.

Indeed, the ESR build ID from above is in this list, but the non-ESR isn't.

这篇关于如何在JavaScript中检测Firefox和Firefox ESR之间的差异?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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