window.WIMB = {
    detect: {
        javascript: {
            enabled: function(){
                return true;
            }
        },
        cookies: {
            enabled: function(){
                return !!navigator.cookieEnabled;
            }
        },
        computer: {
            screen: {
                width: function(){
                    return window.screen.width || null;
                },
                height: function(){
                    return window.screen.height || null;
                },
                color_depth: function(){
                    return window.screen.colorDepth || null;
                },
                device_pixel_ratio: function(){
                    return typeof window.devicePixelRatio !== "undefined" ? window.devicePixelRatio : 1;
                }
            },
            platform: function(){
                var userAgent = navigator.userAgent.toLowerCase();
                if(userAgent.indexOf("windows nt") !== -1) return "Windows";
                if(userAgent.indexOf("macintosh") !== -1) return "MacOS";
                if(userAgent.indexOf("linux") !== -1 || userAgent.indexOf("x11") !== -1) return "Linux";
                if(userAgent.indexOf("android") !== -1) return "Android";
                if(userAgent.indexOf("iphone") !== -1 || userAgent.indexOf("ipad") !== -1 || userAgent.indexOf("ipod") !== -1) return "iOS";
                return null;
            }
        },
        window_size: {
            width: function(){
                return window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth || null;
            },
            height: function(){
                return window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight || null;
            },
            orientation: function(){
                return (screen.orientation || {}).type || screen.mozOrientation || screen.msOrientation || null;
            }
        },
        navigator: {
            user_agent: {
                value: function(){
                    return navigator.userAgent || null;
                }
            },
            browser: {
                name_and_version: function(){
                    var userAgent = navigator.userAgent, tem, match =
                        userAgent.match(/(opera|chrome|safari|firefox|msie|trident(?=\/))\/?\s*(\d+)/i) || [];
                    if(/trident/i.test(match[1])){
                        tem = /\brv[ :]+(\d+)/g.exec(userAgent) || [];
                        return 'IE ' + (tem[1] || '');
                    }
                    if(match[1] === 'Chrome'){
                        tem = userAgent.match(/\b(OPR|Edge)\/(\d+)/);
                        if(tem != null) return tem.slice(1).join(' ').replace('OPR', 'Opera');
                    }
                    match = match[2] ? [match[1], match[2]] : [navigator.appName, navigator.appVersion, '-?'];
                    if((tem = userAgent.match(/version\/(\d+)/i)) != null) match.splice(1, 1, tem[1]);
                    return match.join(' ');
                }
            },
            language: {
                value: function(){
                    return navigator.language || null;
                }
            },
            oscpu: {
                value: function(){
                    return navigator.oscpu || null;
                }
            },
            vendor: {
                value: function(){
                    return navigator.vendor || null;
                }
            },
            hardware_concurrency: {
                value: function(){
                    return navigator.hardwareConcurrency || null;
                }
            },
            navigator_ram: {
                gigabytes: function(){
                    return navigator.deviceMemory || null;
                }
            },
            preferred_languages: {
                value: function(){
                    return navigator.languages && navigator.languages.length > 0 ? navigator.languages : [navigator.language] || [null];
                }
            }
        },
        timezone: {
            value: function(){
                return Intl.DateTimeFormat().resolvedOptions().timeZone || null;
            }
        },
        webgl: {
            canvasDivId: "wimb_library_canvas",
            init: function(){
                if(document.getElementById(this.canvasDivId) === null){
                    var canvas = document.createElement("canvas");
                    canvas.id = this.canvasDivId;
                    canvas.style.display = "none";
                    document.body.appendChild(canvas);
                    this.canvasWebgl = canvas.getContext("webgl");
                }
            },
            vendor: function(){
                this.init();
				if(this.canvasWebgl === null){return null;}
                var extension = this.canvasWebgl.getExtension("WEBGL_debug_renderer_info");
                return this.canvasWebgl.getParameter(extension.UNMASKED_VENDOR_WEBGL);
            },
            renderer: function(){
                this.init();
				if(this.canvasWebgl === null){return null;}
                var extension = this.canvasWebgl.getExtension("WEBGL_debug_renderer_info");
                return this.canvasWebgl.getParameter(extension.UNMASKED_RENDERER_WEBGL);
            }
        },
        addons: {
			adblock: {
				adDivId: function(){
					return 'ads' + Math.random().toString(36).substr(2, 9);
				},
				baitClass: "adunit",
				baitId: "adunit",
				baitStyles: function(){
					return 'width:' + (Math.floor(Math.random() * 10) + 1) + 'px;height:' + (Math.floor(Math.random() * 10) + 1) + 'px;position:absolute;left:-9999px;';
				},
				init: function(){
					if(document.getElementById(this.adDivId()) === null) {
						var div = document.createElement("div");
						div.id = this.adDivId();
						div.className = "adsbygoogle";
						div.style.display = "none";
						document.body.appendChild(div);
					}
				},
				detect: function(){
					this.init();
					var bait = document.createElement("div");
					bait.id = this.baitId;
					bait.className = this.baitClass;
					bait.style.cssText = this.baitStyles();
					document.body.appendChild(bait);

					var adBlockDetected = window.getComputedStyle(bait).display === "none";
					document.body.removeChild(bait);

					return adBlockDetected;
				}
			}
		},
		selenium: {
            webdriver: function(){
                return !!window.navigator.webdriver;
            },
			documentElementAttribute: function(){
                return window.document.documentElement.getAttribute('webdriver') !== null;
            },
            headless: function(){
				const isFirefox = navigator.userAgent.toLowerCase().includes("firefox");
				const isMobile = /(mobile|android|iphone|ipad|ipod|windows phone|opera mini|blackberry|bb10|iemobile|webos|chrome|safari)/.test(navigator.userAgent.toLowerCase());
				
				const outerWidth = window.outerWidth;
				const outerHeight = window.outerHeight;
				const innerWidth = window.innerWidth;
				const innerHeight = window.innerHeight;

				const isHeadlessWidth = (outerWidth - innerWidth) < 100;
				const isHeadlessHeight = (outerHeight - innerHeight) < 100;
				
				if(isFirefox){
					return false;
				}

				if(isMobile){
					return !(isHeadlessWidth || isHeadlessHeight);
				}

				return isHeadlessWidth && isHeadlessHeight;
			}
        }
    }
};

function checkConnect(){
    var conn = {};
    conn["\uC790\uBC14\uC2A4\uD06C\uB9BD\uD2B8"] = WIMB.detect.javascript.enabled();
    conn["\uBE0C\uB77C\uC6B0\uC800\u0020\uCFE0\uD0A4"] = WIMB.detect.cookies.enabled();
    conn["\uD574\uC0C1\uB3C4\u0020\uBE44\uC728"] = WIMB.detect.computer.screen.device_pixel_ratio();
	conn["\uBE0C\uB77C\uC6B0\uC800\u0020CPU"] = WIMB.detect.navigator.oscpu.value();
	conn["\uBE0C\uB77C\uC6B0\uC800\u0020CPU\u0020\uCF54\uC5B4"] = WIMB.detect.navigator.hardware_concurrency.value();
	conn["\uBE0C\uB77C\uC6B0\uC800\u0020\uBA54\uBAA8\uB9AC"] = WIMB.detect.navigator.navigator_ram.gigabytes();
    conn["CPU\u0020\uC81C\uC870\uC5C5\uCCB4"] = WIMB.detect.navigator.vendor.value();
	conn["\uBE0C\uB77C\uC6B0\uC800\u0020GPU"] = WIMB.detect.webgl.renderer();
    conn["GPU\u0020\uC81C\uC870\uC5C5\uCCB4"] = WIMB.detect.webgl.vendor();
    conn["\uD655\uC7A5\u0020\uD504\uB85C\uADF8\uB7A8\u0020\u0028\uC560\uB4DC\uC628\u0029"] = WIMB.detect.addons.adblock.detect();
    conn["\uD654\uBA74\u0020\uB113\uC774"] = WIMB.detect.computer.screen.width();
    conn["\uD654\uBA74\u0020\uB192\uC774"] = WIMB.detect.computer.screen.height();
    conn["\uCEF4\uD4E8\uD130\u0020\uC0C9\uC0C1\u0020\uBE44\uD2B8"] = WIMB.detect.computer.screen.color_depth();
    conn["\uBE0C\uB77C\uC6B0\uC800\u0020\uB113\uC774"] = WIMB.detect.window_size.width();
    conn["\uBE0C\uB77C\uC6B0\uC800\u0020\uB192\uC774"] = WIMB.detect.window_size.height();
    conn["\uCEF4\uD4E8\uD130\u0020OS"] = WIMB.detect.computer.platform();
    conn["\uD604\uC7AC\u0020\uBE0C\uB77C\uC6B0\uC800"] = WIMB.detect.navigator.user_agent.value();
	conn["\uBE0C\uB77C\uC6B0\uC800\u0020\uC774\uB984\u0020\uBC0F\u0020\uBC84\uC804"] = WIMB.detect.navigator.browser.name_and_version();
    conn["\uBE0C\uB77C\uC6B0\uC800\u0020\uC0AC\uC6A9\u0020\uC5B8\uC5B4"] = WIMB.detect.navigator.language.value();
    conn["\uCEF4\uD4E8\uD130\u0020\uD45C\uC900\u0020\uC2DC\uAC04\uB300"] = WIMB.detect.timezone.value();
    conn["\uD654\uBA74\u0020\uBAA8\uB4DC"] = WIMB.detect.window_size.orientation().includes("landscape-primary") ? '\uAC00\uB85C\u0020\uBAA8\uB4DC' : '\uC138\uB85C\u0020\uBAA8\uB4DC';
	conn["\uAC00\uC0C1\u0020\uC6F9\u0020\uB4DC\uB77C\uC774\uBC84"] = WIMB.detect.selenium.webdriver();
	conn["\uAC00\uC0C1\u0020\uBCC0\uC870\u0020\uBE0C\uB77C\uC6B0\uC800"] = WIMB.detect.selenium.documentElementAttribute();
	conn["\uAC00\uC0C1\u0020\uBE0C\uB77C\uC6B0\uC800"] = WIMB.detect.selenium.headless();

    return conn;
}