-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathshowQobuzReleaseAvailability.js
42 lines (38 loc) · 1.03 KB
/
showQobuzReleaseAvailability.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
/**
* - Shows all countries in which the currently visited Qobuz release is available.
*/
/**
* All countries in which Qobuz is currently available:
* https://help.qobuz.com/hc/en-us/articles/360010260660-Where-is-Qobuz-available-
*/
const allCountryCodes = [
"AT",
"AU",
"BE",
"CH",
"DE",
"DK",
"ES",
"FI",
"FR",
"GB",
"IE",
"IT",
"LU",
"NL",
"NO",
"NZ",
"SE",
"US",
];
function getAvailableCountriesOfCurrentPage() {
// obtain alternate pages for different languages and countries
const languageCodes = Array.from(document.querySelectorAll('head > link[rel=alternate]'))
.map((/** @type {HTMLLinkElement} */ link) => link.hreflang);
// extract the country and drop duplicates (some countries have multiple languages)
return languageCodes
.map((code) => code.split('-')[1])
.filter((country, index, countries) => country && countries.indexOf(country) === index);
}
const countryCodes = getAvailableCountriesOfCurrentPage();
alert(`Available in ${countryCodes.length} countries\n${countryCodes.sort().join(', ')}`);