Add full Mullvad JSON URL to manifest, retool fetch request

This commit is contained in:
Maxx Crawford 2021-02-23 13:25:47 -06:00
parent fbb1a07f4e
commit f451bff6e7
2 changed files with 10 additions and 19 deletions

View file

@ -29,25 +29,16 @@ const backgroundLogic = {
}, },
async getMullvadInfo() { async getMullvadInfo() {
console.log("getMullvadInfo");
const amIMullvadPath = "https://am.i.mullvad.net/json"; const amIMullvadPath = "https://am.i.mullvad.net/json";
console.log(`fetching ${amIMullvadPath}`);
const response = await fetch("https://am.i.mullvad.net/json", { // TODO: Add some sort of error catching
"credentials": "omit", const mullvadFetchData = await fetch(amIMullvadPath)
"headers": { .then((response) => response.json())
"Accept": "application/json", .then(data => {
"Accept-Encoding": "gzip, deflate, br", return data;
"Accept-Language": "en-US,en;q=0.5", });
"Host": "am.i.mullvad.net",
}, return await mullvadFetchData;
"method": "GET",
"mode": "cors"
});
// const response = await fetch(amIMullvadPath);
console.log(`response: ${response}`);
const responseJson = await response.json();
console.log(`responseJson: ${responseJson}`);
return responseJson;
}, },
async getMullvadServers() { async getMullvadServers() {

View file

@ -30,7 +30,7 @@
"webRequest", "webRequest",
"proxy", "proxy",
"https://am.i.mullvad.net/*" "https://am.i.mullvad.net/json"
], ],
"optional_permissions": [ "optional_permissions": [
"bookmarks" "bookmarks"