Adrià Vilanova Martínez | 0335b51 | 2022-01-21 13:34:59 +0100 | [diff] [blame] | 1 | // Returns whether the extension is a production version (released stable or |
| 2 | // beta version). |
| 3 | export function isProdVersion() { |
| 4 | // #!if production && !canary |
| 5 | return true; |
| 6 | // #!else |
| 7 | return false; |
| 8 | // #!endif |
Adrià Vilanova Martínez | 3465e77 | 2021-07-11 19:18:41 +0200 | [diff] [blame] | 9 | } |
Adrià Vilanova Martínez | e32adc4 | 2021-08-30 17:16:49 +0200 | [diff] [blame] | 10 | |
| 11 | // Returns the extension version |
| 12 | export function getExtVersion() { |
| 13 | var manifest = chrome.runtime.getManifest(); |
| 14 | return manifest?.version; |
| 15 | } |
Adrià Vilanova Martínez | 5a8055b | 2022-09-29 13:05:19 +0200 | [diff] [blame] | 16 | |
| 17 | // Get a URL to a document which is part of the extension documentation (using |
| 18 | // |ref| as the Git ref). |
| 19 | export 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) |
| 26 | export function getDocURL(doc) { |
| 27 | if (!isProdVersion()) return getDocURLWithRef(doc, 'HEAD'); |
| 28 | |
| 29 | var version = getExtVersion(); |
| 30 | return getDocURLWithRef(doc, 'refs/tags/v' + version); |
| 31 | } |