diff --git a/README.md b/README.md index 8659703..537ddfa 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,4 @@ # SAC Route Portal GPX Downloader - The [Swiss Alpine Club](https://www.sac-cas.ch/en/) has a great [route portal](https://www.sac-cas.ch/en/huts-and-tours/sac-route-portal/) for finding interesting hiking routes. diff --git a/background.js b/background.js index 7d624fd..6c7dc24 100644 --- a/background.js +++ b/background.js @@ -129,11 +129,14 @@ function listener(details) { let buffer = await blob.arrayBuffer(); let str = decoder.decode(buffer); - gpxTrack = JSON.parse(str); updateActiveTab(browser.tabs); filter.write(encoder.encode(str)); filter.close(); + + let geoJson = JSON.parse(str); + const routeTitle = trackTitle(geoJson); + gpxTrack = {title: routeTitle, data: toGpx(geoJson)}; }; return {}; @@ -162,14 +165,12 @@ function handleClick(tab) { return; } - let blob = new Blob([toGpx(gpxTrack)], {type: "application/gpx+xml"}); + let blob = new Blob([gpxTrack.data], {type: "application/gpx+xml"}); let objectURL = URL.createObjectURL(blob); - const routeTitle = trackTitle(gpxTrack); - let downloading = browser.downloads.download({ url : objectURL, - filename : `track-${routeTitle}.gpx`, + filename : `track-${gpxTrack.title}.gpx`, saveAs: true, conflictAction : 'uniquify' }); @@ -209,7 +210,7 @@ function updateIcon(tab) { tabId: tab.id }); browser.browserAction.setTitle({ - title: hasTrack ? `Download track ${trackTitle(gpxTrack)}` : 'No track selected', + title: hasTrack ? `Download track ${gpxTrack.title}` : 'No track selected', tabId: tab.id }); } diff --git a/manifest.json b/manifest.json index ec55f79..c63b54c 100644 --- a/manifest.json +++ b/manifest.json @@ -2,7 +2,7 @@ "manifest_version": 2, "name": "SAC Route Portal GPX Downloader", - "version": "0.2", + "version": "0.3", "developer": { "name": "Sebastian Hugentobler", "url": "https://code.vanwa.ch/sebastian/sac-route-portal-gpx-fx"