var scriptObjs = document.scripts; var currentPath = scriptObjs[scriptObjs.length - 1].src.substring(0, scriptObjs[scriptObjs.length - 1].src.lastIndexOf("/") + 1); var siteUrl = currentPath.substring(0, currentPath.length - 10); function loadScript(url, checkVar, callback) { if (typeof window[checkVar] !== 'undefined') { callback && callback(); return; } var script = document.createElement('script'); script.src = url; script.onload = callback; script.onerror = function() { console.error('脚本加载失败: ' + url); }; document.head.appendChild(script); } // 3. 定义需要 jQuery 才能执行的操作 function dojQueryStuff() { jQuery(document).ready(function() { jQuery(".cxcms_scrambling").remove(); if (jQuery(".ueditor_baidumap").length > 0) { jQuery(".ueditor_baidumap").each(function() { // 注意这里用了 $,但安全起见用 jQuery var $this = jQuery(this); if ($this.attr("width") > jQuery(window).width()) { var ueditor_baidumap_w = Number($this.attr("width")) - 4; $this.attr("src", $this.attr("src").replace("width=" + ueditor_baidumap_w + "&", "width=100%&")); $this.attr("width", "100%"); } console.log(jQuery(window).width()); }); } if (document.title.indexOf(";&#") >= 0) { jQuery.ajax({ url: siteUrl + "plug/websafe/notice.asp", type: "POST", data: { type: 'indexTampered', url: window.location.href, title: document.title }, success: function(res) { console.log(res); }, error: function(err) { console.log(22); } }); } }); } loadScript(siteUrl + 'static/js/jquery.js', 'jQuery', function() { dojQueryStuff(); loadScript(siteUrl + 'static/js/function.js', 'getDeviceFingerprint', function() { if (typeof window.getFingerprintWithCache === 'function') { window.getFingerprintWithCache().then(function(fp) { document.cookie ="DeviceID="+fp+";path=/en/;max-age=" + (30 * 24 * 60 * 60); }).catch(function(err) { console.error('获取设备指纹失败:', err); }); } }); });