Created
January 16, 2018 17:43
-
-
Save user890104/0953178e77ff854c420c194c5d64d9c5 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
// run in console | |
// enable popups for website first | |
if (!('lastLat' in window)) { | |
window.lastLat = 0; | |
} | |
if (!('lastLon' in window)) { | |
window.lastLon = 0; | |
} | |
setInterval(function() { | |
$.getJSON(location.href.replace('/tracking', '/status')).then(function(data){ | |
if (!data.courier){ | |
console.log('no courier'); | |
return; | |
} | |
console.log(lastLat,data.courier.latitude,lastLon,data.courier.longitude); | |
if (lastLat != data.courier.latitude || lastLon != data.courier.longitude) { | |
console.log('location changed'); | |
window.open('https://maps.google.com/?q=loc:' + data.courier.latitude + ',' + data.courier.longitude, 'gMapsWin'); | |
} | |
else { | |
console.log('location unchanged'); | |
} | |
window.lastLat = data.courier.latitude; | |
window.lastLon = data.courier.longitude; | |
}); | |
}, 10000); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment