Created
August 5, 2020 02:07
-
-
Save vicapow/73de243f988846012dd63d7bbeb963de to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(async function() { | |
async function fetchData(date) { | |
var date_split = date.split('-'), | |
year = date_split[0], | |
month = date_split[1], | |
day = date_split[2]; | |
if (parseInt(day) < 10){ | |
day = parseInt(day); | |
} | |
month = parseInt(month) - 1; | |
var url = "https://www.google.com/maps/timeline/kml?authuser=0&pb=!1m8!1m3!1i"+year+"!2i"+month+"!3i"+day+"!2m3!1i"+year+"!2i"+month+"!3i"+day; | |
const data = await fetch(url); | |
const xml = await data.text(); | |
return xml; | |
} | |
function download(filename, text) { | |
var element = document.createElement('a'); | |
element.setAttribute('href', 'data:text/plain;charset=utf-8,' + encodeURIComponent(text)); | |
element.setAttribute('download', filename); | |
element.style.display = 'none'; | |
document.body.appendChild(element); | |
element.click(); | |
document.body.removeChild(element); | |
} | |
const dates = [ | |
await fetchData('2020-08-03'), | |
await fetchData('2020-08-02') | |
]; | |
download('google-location-history.json', JSON.stringify({ dates }, null, 2)); | |
}()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment