获取Firefox频道

时间:2017-11-05 20:40:39

标签: javascript firefox firefox-addon version firefox-webextensions

任何人都有一个功能,可以在确定Firefox频道(ESR / Stable / Beta / Dev / Nightly)的扩展中工作,没有任何获取请求和没有估计?

我们当然可以根据我们对发布周期的了解进行估算,但这并不准确:

function getChannelFromVersion(version) {
    const nightlySeedDate = new Date(2018, 10, 27);
    const nightlySeedVersion = 66;

    const cycleWeeks = 9;
    const cycleTime = cycleWeeks * 7 * 24 * 60 * 60 * 1000; // ms

    const weeksBetweenSeed = (Date.now() - nightlySeedDate.getTime()) / 1000 / 60 / 60 / 24 / 7;
    let versionBetweenSeed = weeksBetweenSeed / cycleWeeks;
    versionBetweenSeed = versionBetweenSeed < 0 ? Math.floor(versionBetweenSeed) : Math.ceil(versionBetweenSeed);

    const currentNightlyVersion = nightlySeedVersion + versionBetweenSeed;

    // console.log('weeksBetweenSeed:', weeksBetweenSeed, 'versionBetweenSeed:', versionBetweenSeed, 'currentNightlyVersion:', currentNightlyVersion);

    const diffVersion = currentNightlyVersion - version;
    if (diffVersion < 0) return 'unreleased';
    else if (diffVersion === 0 ) return 'nightly';
    else if (diffVersion === 1 ) return 'dev';
    else if (diffVersion === 2 ) return 'beta';
    else if (diffVersion === 3 ) return 'stable';
    else return 'outdated';

}

// getChannelFromVersion(59) === "nightly"

1 个答案:

答案 0 :(得分:0)

没有API直接执行此操作,但已提出一个: https://bugzilla.mozilla.org/show_bug.cgi?id=1386076