blob: 39cf1967b6c21b38e4b0dbf78a57f961b254f11e [file] [log] [blame]
Adrià Vilanova Martínez0335b512022-01-21 13:34:59 +01001// Returns whether the extension is a production version (released stable or
2// beta version).
3export function isProdVersion() {
4 // #!if production && !canary
5 return true;
6 // #!else
7 return false;
8 // #!endif
Adrià Vilanova Martínez3465e772021-07-11 19:18:41 +02009}
Adrià Vilanova Martíneze32adc42021-08-30 17:16:49 +020010
11// Returns the extension version
12export function getExtVersion() {
13 var manifest = chrome.runtime.getManifest();
14 return manifest?.version;
15}
Adrià Vilanova Martínez5a8055b2022-09-29 13:05:19 +020016
17// Get a URL to a document which is part of the extension documentation (using
18// |ref| as the Git ref).
19export function getDocURLWithRef(doc, ref) {
20 return 'https://gerrit.avm99963.com/plugins/gitiles/infinitegforums/+/' +
21 ref + '/docs/' + doc;
22}
23
24// Get a URL to a document which is part of the extension documentation
25// (autodetect the appropriate Git ref)
26export function getDocURL(doc) {
27 if (!isProdVersion()) return getDocURLWithRef(doc, 'HEAD');
28
29 var version = getExtVersion();
30 return getDocURLWithRef(doc, 'refs/tags/v' + version);
31}