mirror of
https://github.com/anticensority/runet-censorship-bypass.git
synced 2024-11-30 21:33:43 +03:00
Add api to compare versions
This commit is contained in:
parent
56a0daf635
commit
b0f826dab6
|
@ -198,10 +198,20 @@
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const max = 2**16;
|
||||||
|
const versionToArray = (v) => [ ...v.split('.'), 0, 0, 0].slice(0,4);
|
||||||
|
const versionToInt = (v) => versionToArray(v)
|
||||||
|
.reverse()
|
||||||
|
.reduce((acc, vv, i) => acc + parseInt(vv)*(max**i), 0);
|
||||||
|
|
||||||
|
const compareVersions = (a, b) => versionToInt(a) - versionToInt(b);
|
||||||
|
|
||||||
window.apis = {
|
window.apis = {
|
||||||
version: {
|
version: {
|
||||||
ifMini: false,
|
ifMini: false,
|
||||||
build: chrome.runtime.getManifest().version.replace(/\d+\.\d+\./g, ''),
|
build: chrome.runtime.getManifest().version.replace(/\d+\.\d+\./g, ''),
|
||||||
|
|
||||||
|
isLeq: (a, b) => compareVersions(a, b) <= 0,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user