Skip to content

Commit

Permalink
feat: add Google hack for maps
Browse files Browse the repository at this point in the history
This allows anyone to run the live map without having to get an API  key from Google (wohoo, freedom)
  • Loading branch information
TGRHavoc committed May 17, 2019
1 parent c020a34 commit 35021ee
Showing 1 changed file with 30 additions and 3 deletions.
33 changes: 30 additions & 3 deletions index.php
Expand Up @@ -49,9 +49,10 @@
<script src="js/jquery-3.2.1.min.js"></script>

<!-- Change the key below -->
<script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?key=AIzaSyBbYDZMGkewhRTGRJS4wwSVuBipYlYf-SU"></script>
<script type="text/javascript" src="https://maps.google.com/maps/api/js"></script>

<script>

///////////////////////////////////////////////////////////////////////////
// CONFIGURATION STARTS HERE
///////////////////////////////////////////////////////////////////////////
Expand All @@ -75,11 +76,37 @@
var _MAP_UVInvMap = false;

// Set to the IP of the GTA server running "live_map" and change the port to the
// number that is in the "server.lua" file
// number that is set
var _SETTINGS_socketUrl = "ws://localhost:30121"

</script>
// Do not remove unless you know what you're doing (and you have a google api key)
// Hack from https://stackoverflow.com/questions/38148097/google-maps-api-without-key/38809129#38809129
// hack Google Maps to bypass API v3 key (needed since 22 June 2016 http://googlegeodevelopers.blogspot.com.es/2016/06/building-for-scale-updates-to-google.html)
var target = document.head;
var observer = new MutationObserver(function(mutations) {
for (var i = 0; mutations[i]; ++i) { // notify when script to hack is added in HTML head
if (mutations[i].addedNodes[0].nodeName == "SCRIPT" && mutations[i].addedNodes[0].src.match(/\/AuthenticationService.Authenticate?/g)) {
var str = mutations[i].addedNodes[0].src.match(/[?&]callback=.*[&$]/g);
if (str) {
if (str[0][str[0].length - 1] == '&') {
str = str[0].substring(10, str[0].length - 1);
} else {
str = str[0].substring(10);
}
var split = str.split(".");
var object = split[0];
var method = split[1];
window[object][method] = null; // remove censorship message function _xdc_._jmzdv6 (AJAX callback name "_jmzdv6" differs depending on URL)
//window[object] = {}; // when we removed the complete object _xdc_, Google Maps tiles did not load when we moved the map with the mouse (no problem with OpenStreetMap)
}
observer.disconnect();
}
}
});
var config = { attributes: true, childList: true, characterData: true }
observer.observe(target, config);

</script>

<?php
printFirstJs($debug);
Expand Down

0 comments on commit 35021ee

Please sign in to comment.