(script, { all, allowedOnly, enabledOnly } = {})
| 89 | * @return {string[] | string} |
| 90 | */ |
| 91 | export function getScriptUpdateUrl(script, { all, allowedOnly, enabledOnly } = {}) { |
| 92 | if ((!allowedOnly || script.config.shouldUpdate) |
| 93 | && (!enabledOnly || script.config.enabled)) { |
| 94 | const { custom, meta } = script; |
| 95 | /* URL in meta may be set to an invalid value to enforce disabling of the automatic updates |
| 96 | * e.g. GreasyFork sets it to `none` when the user installs an old version. |
| 97 | * We'll show such script as non-updatable. */ |
| 98 | const downloadURL = tryUrl(custom.downloadURL || meta.downloadURL || custom.lastInstallURL); |
| 99 | const updateURL = tryUrl(custom.updateURL || meta.updateURL || downloadURL); |
| 100 | const url = downloadURL || updateURL; |
| 101 | if (url) return all ? [downloadURL, updateURL] : url; |
| 102 | } |
| 103 | } |
no test coverage detected