Created
March 21, 2018 11:45
-
-
Save pentagonal/1dcd6e7ad95070e07318edebfbc9240e to your computer and use it in GitHub Desktop.
Resolve Google Map v3 without API Key
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
/* | |
* Resolve Google Map v3 without API Key | |
* since june 22 2016 | |
* Put on body and load before map render | |
*/ | |
(function (window) { | |
if (!window.document) { | |
return; | |
} | |
(new MutationObserver(function (mutations) { | |
if (typeof mutations !== 'object') { | |
return; | |
} | |
try { | |
for (var i = 0; mutations[i]; ++i) { | |
if (typeof mutations[i].addedNodes === 'undefined' || typeof mutations[i].addedNodes[0] === 'undefined') { | |
continue; | |
} | |
var node = mutations[i].addedNodes[0]; | |
if (typeof node !== 'object' || typeof node.nodeName !== 'string' || typeof node.src !== 'string') { | |
continue; | |
} | |
// notify when script to hack is added in HTML head | |
if (node.nodeName.toUpperCase() === "SCRIPT" | |
&& node.src.match(/\/AuthenticationService.Authenticate?/g) | |
) { | |
var str = mutations[i].addedNodes[0].src.match(/[?&]callback=.*[&$]/g); | |
if (str) { | |
str = (str[0][str[0].length - 1] === '&') | |
? str[0].substring(10, str[0].length - 1) | |
: str[0].substring(10); | |
var split = str.split("."); | |
window[split[0]][split[1]] = null; | |
} | |
this.disconnect(); | |
} | |
} | |
} catch (e) { | |
// pass error | |
} | |
})).observe(window.document.head, { | |
attributes: true, | |
childList: true, | |
characterData: true | |
}); | |
})(window); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment