From 8eed835aa25d392cc2c2a221375b48672b634ac0 Mon Sep 17 00:00:00 2001 From: Sebastian Hugentobler Date: Wed, 16 Jun 2021 12:02:26 +0200 Subject: [PATCH] version 0.3 --- README.md | 1 - background.js | 13 +++++++------ manifest.json | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) 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"