Skip to content

Instantly share code, notes, and snippets.

@ticky
Last active April 6, 2018 05:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ticky/e3265e2bc35c3fcd7373e00e2b363eb7 to your computer and use it in GitHub Desktop.
Save ticky/e3265e2bc35c3fcd7373e00e2b363eb7 to your computer and use it in GitHub Desktop.
JavaScript injected at curcond.drac.at
/* metric 4 lyf mother heckers */
!function (original_parser) {
jQuery.ajaxSettings.converters['text json'] = function (json) {
return original_parser(
json.replace(
/([0-9]+)((?:\\u0026|&|)deg;|\s)([CF]|mph)/g,
function (match, value, separator, unit) {
value = parseInt(value);
switch (unit) {
case 'F':
value = (value - 32) * (5 / 9);
unit = 'C';
break;
case 'C':
value = (value * (9 / 5)) + 32;
unit = 'F';
break;
case 'mph':
value = value * 1.609344;
unit = 'km/h';
break;
}
return Math.round(value) + separator + unit;
}
)
);
};
}(jQuery.ajaxSettings.converters['text json'])
/* this app doesn't need especially specific coords, so keep the geolocation data inaccurate */
!function (getCurrentPosition) {
navigator.geolocation.getCurrentPosition = function (success, error, options) {
return getCurrentPosition.call(
navigator.geolocation,
function(location) {
success({
coords: Object.assign(
{},
location.coords,
{
accuracy: location.coords.accuracy * 100,
latitude: Math.round(location.coords.latitude * 20) / 20,
longitude: Math.round(location.coords.longitude * 20) / 20
}
),
timestamp: location.timestamp
});
},
error,
Object.assign(
{},
options,
{enableHighAccuracy: false}
)
);
};
}(navigator.geolocation.getCurrentPosition)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment