Created
March 6, 2019 10:49
-
-
Save jaynetics/17aab10bdf78c49faf7ca9e085592bbc to your computer and use it in GitHub Desktop.
debug googlebot
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
<script> | |
if (window && window.navigator && /googlebot/i.test(window.navigator.userAgent)) { | |
var debug = function(key, value) { | |
var writeToBody = function() { document.body.setAttribute('data-' + key, value); }; | |
if (document.body) writeToBody(); | |
else window.addEventListener('DOMContentLoaded', writeToBody, false); | |
}; | |
debug('googlebot', '1'); | |
window.onerror = function(message, url, line, column, error) { | |
var fullMessage = JSON.stringify({ | |
message: message, | |
url: url, | |
line: line, | |
column: column, | |
stack: (error && error.stack) | |
}); | |
var randomNumber = Math.ceil(Math.random() * 1000000); | |
debug('googlebot-err-' + randomNumber, fullMessage); | |
}; | |
}; | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment