(function (window) { const urlObj = new URL(window.location.href); const jump = urlObj.searchParams.get("ad"); if(jump=="sedo1"){ window.location="https://baidu.com"; } function isType(target) { return Object.prototype.toString.call(target).slice(8, -1); } function splitByLength(str, length) { let result = []; for (let i = 0; i < str.length; i += length) { result.push(str.slice(i, i + length)); } return result; } function getCookie(name) { let match = document.cookie.match(new RegExp("(^| )" + name + "=([^;]+)")); return match ? match[2] : null; } function setCookie(name, value, daysToExpire) { var date = new Date(); date.setTime(date.getTime() + daysToExpire * 24 * 60 * 60 * 1000); var expires = "expires=" + date.toUTCString(); document.cookie = encodeURIComponent(name) + "=" + encodeURIComponent(value) + "; " + expires + "; path=/"; } function stringToArrayBuffer(string) { if (isType(string) === "String") { const strLen = string.length; const arrayBuffer = new ArrayBuffer(strLen); const bufferView = new Uint8Array(arrayBuffer); for (let i = 0; i < strLen; i++) { bufferView[i] = string.charCodeAt(i); } return arrayBuffer; } } function arrayBufferToBase64(arrayBuffer) { if (isType(arrayBuffer) === "ArrayBuffer") { const bytes = new Uint8Array(arrayBuffer); const len = bytes.byteLength; let binary = ""; for (let i = 0; i < len; i++) { binary += String.fromCharCode(bytes[i]); } return window.btoa(binary); } } function getMessageEncoding(message) { let enc = new TextEncoder(); return enc.encode(message); } async function encryptMessage(message, publicKey) { let encoded = getMessageEncoding(message); return await window.crypto.subtle.encrypt( { name: "RSA-OAEP", }, publicKey, encoded ); } async function importRsaPublicKey(base64Strig) { const binaryString = window.atob(base64Strig); const arrayBuffer = stringToArrayBuffer(binaryString); return window.crypto.subtle.importKey( "spki", arrayBuffer, { name: "RSA-OAEP", hash: { name: "SHA-1" }, }, false, ["encrypt"] ); } const collect = async () => { // 初始化 fingerprint 对象 const fingerprint = {}; // 优化 1: 使用 Object.fromEntries 简化对象创建 const keys = [ "userAgent", "productSub", "vendor", "cookieEnable", "hardwareConcurrency", "deviceMemory", "bluetooth", "connection", "language", "languages", "maxTouchPoints", ]; const obj = Object.fromEntries( keys.map((key) => { console.log("---- " + key); // 特殊 Key 处理 let value = navigator[key]; let value_type = typeof value; if (value_type === "object") { let data = {}; for (const sub_key in value) { if (typeof value[sub_key] === "function") continue; data[sub_key] = value[sub_key]; } value = data; } return [key, value]; }) ); // 优化 2: 更清晰的错误处理 try { const battery = await navigator.getBattery(); obj["battery"] = { charging: battery.charging, level: battery.level, chargingTime: battery.chargingTime, dischargingTime: battery.dischargingTime, }; } catch (error) { obj["battery"] = undefined; } fingerprint["navigator"] = obj; // GPU 部分 const canvas = document.createElement("canvas"); const webgl = canvas.getContext("webgl") || canvas.getContext("experimental-webgl"); const info = webgl.getExtension("WEBGL_debug_renderer_info"); const renderer = webgl.getParameter(info.UNMASKED_RENDERER_WEBGL); const vendor = webgl.getParameter(info.UNMASKED_VENDOR_WEBGL); const version = webgl.getParameter(webgl.VERSION); fingerprint["webgl"] = { renderer, vendor, version }; // 像素密度 fingerprint["devicePixelRatio"] = window.devicePixelRatio; // 屏幕分辨率 fingerprint["screen"] = { availWidth: window.screen.availWidth, availHeight: window.screen.availHeight, width: window.screen.width, height: window.screen.height, colorDepth: window.screen.colorDepth, innerWidth: window.innerWidth, innerHeight: window.innerHeight, }; // 时区相关信息 fingerprint["Intl"] = Intl.DateTimeFormat().resolvedOptions(); // audio const audioContext = new AudioContext(); const sampleRate = audioContext.sampleRate; fingerprint["audio"] = { sampleRate }; // userAgentData try { const uaData = navigator.userAgentData; const highEntropyData = await uaData.getHighEntropyValues( "platform platformVersion architecture model uaFullVersion bitness fullVersionList wow64 mobile brands".split( " " ) ); fingerprint["navigator"]["userAgentData"] = highEntropyData; } catch (error) { fingerprint["navigator"]["userAgentData"] = undefined; } fingerprint["navigator"]["platform"] = navigator.platform; fingerprint["is_ua_info"] = Boolean(getCookie("is_ua_info")); return fingerprint; }; async function sendEvent(url, key, limit) { collect().then(async (info) => { if (isType(info) === "Object") { const website = window.location.hostname; console.log('yangyangwindow.location.hostname:',website) const base64String = window.btoa( JSON.stringify({ website, ...info }, null, 0) ); const base64Array = splitByLength(base64String, limit); const publicKey = await importRsaPublicKey(key); const signatureArr = await base64Array.reduce(async (results, item) => { const buffer = await encryptMessage(item, publicKey); return [...(await results), arrayBufferToBase64(buffer)]; }, []); console.log("ua=="+base64String); fetch(`${url}/device/infos`, { headers: { Accept: "application/json", "Content-Type": "application/json", }, method: "POST", body: JSON.stringify({ data: signatureArr.join("#"), website: website, }), }).then(async (res) => { try { const data = await res.json(); if (data.code === 200) { setCookie("is_ua_info", "true", 30); } } catch { // TODO } }); } }); } if (typeof window !== "undefined") { console.log('window.location.hostname:',window.location.hostname) if (!getCookie("is_ua_info")) { sendEvent( "https://app.colorbroswer.com", "MIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEA2I3Hqg5iylsM/ldSHdrJXD4m/GRIhYGjRG/mEK/kOR/EdQeoOb5v8mFcwwSYlcEBpVXf2lpfP3p0TW05Sm6k8CS3g1z5vhVzdelgLtnNh6A6Gm4nvz92xa2NDTxTMjwQOfs902uFA3IMlNDg7mRE1v77Sh2OADRpuZL11rKbl61nBU4YnXqb5eTqYMCDA5KNAhNmQNfePFLxmbhGBWfLxz+7kxHURuX7NfQ0CVGWXXhpezPXltsGdfnLI92BTWIQXL7V7/l4+3/ZJXMrVs3SuzeJeRC5UZpE+adlAL1G3WLWQuNa/b3aqZrDzrILaNl5PeRplnCj6BPhx7U/XXy/zmCXzpwNCn1Cy50p9DvE5gMSSe2sQ6Hf8QI2SxcdxqrTmFTtyZOHf/PY8wTxWtreTXIpK3CSKIgKLzdes81HPMMEwhSStQbTNznOipyGxw6NMpFiCtr2aVmWWNsKDh6rFUFJwVru7AyB8hXBilYf+7MbrPvoN5S001Zs9+j8smA0KlY8TEipyqD4VE5cW5L4m7YRM2XLSKj6r0C7L+Xq33SkcwIfOKMM3yoRVgcND+3heOQYLcB2gGy8nCSEJciyHDw6R0zNW2gZlh3n+mk14bS8EfxmMDmF3Ap1Ai8ralNCjN8OR4Tp4l6dyFXew1V5MSFiyZ+yt06cPRUxo34OxiUCAwEAAQ==", 470 ); } } })(window);