任何人都有一个功能,可以在确定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"