Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
if(navigator.userAgent.indexOf("ooglebot") > -1 || navigator.userAgent.indexOf("bingbot") > -1 || navigator.userAgent.indexOf("yandex") > -1 || navigator.userAgent.indexOf("baidu") > -1){
var tests = {
"abortcontroller": (typeof AbortController !== "undefined") ? true : false,
"addeventlistener": (typeof document.addEventListener !== "undefined") ? true : false,
"array-find-index": (typeof [].findIndex !== "undefined") ? true : false,
"array-find": (typeof [].find !== "undefined") ? true : false,
"array-flat": (typeof [].flat !== "undefined") ? true : false,
"array-includes": (typeof "abc".includes !== "undefined") ? true : false,
"arrow-functions": function() { try { return eval("var test = () => { return true }; test()"); }catch(e){ return false; } },
"atob-btoa": (typeof window.btoa !== "undefined") ? true : false,
"audio-api": (typeof audioContext !== "undefined") ? true : false,
"battery-status": (typeof navigator.getBattery !== "undefined") ? true : false,
"beacon": (typeof navigator.sendBeacon !== "undefined") ? true : false,
"bigint": (typeof BigInt !== "undefined") ? true : false,
"bluetooth": (typeof navigator.bluetooth !== "undefined") ? true : false,
"bloburls": (typeof URL !== "undefined") ? ((typeof URL.createObjectURL !== "undefined") ? true : false) : false,
"border-image": ("border-image" in document.body.style),
"border-radius": ("border-radius" in document.body.style),
"broadcastchannel": (typeof BroadcastChannel !== "undefined") ? true : false,
"canvas": function() { var elem = document.createElement('canvas'); return !!(elem.getContext && elem.getContext('2d')); },
"channel-messaging": (typeof MessageChannel !== "undefined") ? true : false,
"childnode-remove": (typeof document.body.remove !== "undefined") ? true : false,
"classlist": (typeof document.body.classList !== "undefined") ? true : false,
"clipboard": (typeof ClipboardEvent !== "undefined") ? true : false,
"comparedocumentposition": (typeof document.body.compareDocumentPosition !== "undefined") ? true : false,
"const": function() { try { return eval("const test = function() { return true }; test()"); }catch(e){ return false; } },
"createimagebitmap": (typeof createImageBitmap !== "undefined") ? true : false,
"element-scroll-methods": (typeof document.body.scrollTo !== "undefined") ? true : false,
"fetch": (typeof fetch !== "undefined") ? true : false,
"fullscreen": (typeof document.fullscreenEnabled !== "undefined") ? true : false,
"indexeddb2": (typeof IDBFactory !== "undefined") ? true : false,
"let": function() { try { return eval("let test = function() { return true }; test()"); }catch(e){ return false; } },
"list-format": (typeof Intl.ListFormat !== "undefined") ? true : false,
"match-all": (typeof "test".matchAll !== "undefined") ? true : false,
"object-observe": (typeof Object.observe !== "undefined") ? true : false,
"offscreencanvas": (typeof OffscreenCanvas !== "undefined") ? true : false,
"payment-request": (typeof PaymentAddress !== "undefined") ? true : false,
"permissions-api": (typeof navigator.permissions !== "undefined") ? true : false,
"pointer": (typeof document.body.onpointerover !== "undefined") ? true : false,
"relativetimeformat": (typeof Intl.RelativeTimeFormat !== "undefined") ? true : false,
"urlsearchparams": (typeof URLSearchParams !== "undefined") ? true : false,
"webauthn": (typeof CredentialsContainer !== "undefined") ? true : false,
"xml-serializer": (typeof XMLSerializer !== "undefined") ? true : false
}
Object.keys(tests).forEach(function(key){
if(typeof tests[key] === "function"){
tests[key] = tests[key]()
}
})
var data = {}
data.tests = tests
data.platform = window.navigator.platform
data.timezone = new Date().getTimezoneOffset();
data.userAgent = navigator.userAgent;
data.location = window.location.href
var xhr = new XMLHttpRequest();
xhr.open('GET', '/log.php?data='+JSON.stringify(data));
xhr.send(null);
xhr.onreadystatechange = function () {
var DONE = 4; // readyState 4 means the request is done.
var OK = 200; // status 200 is a successful return.
if (xhr.readyState === DONE) {
if (xhr.status === OK) {
} else {
}
}
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.