document.addEventListener('DOMContentLoaded', function() { const refreshButton = document.createElement('button'); const kfButton = document.createElement('button'); refreshButton.innerText = "刷新"; kfButton.innerText = "客服"; const custombuttons = [refreshButton, kfButton]; custombuttons.forEach(button => { button.classList.add('n-button', 'n-button--default-type', 'n-button--small-type', 'n-button--color', 'n-button--secondary', 'hover', 'no-drag'); button.style.cssText = '--n-bezier: cubic-bezier(.4, 0, .2, 1); --n-ripple-duration: .6s; --n-opacity-disabled: 0.5; --n-wave-opacity: 0.6; font-weight: 400; --n-color: rgb(168 168 168 / 15%); --n-color-hover: rgb(168 168 168 / 20%); --n-color-pressed: rgba(46, 51, 56, .13); --n-color-focus: rgba(46, 51, 56, .09); --n-color-disabled: rgba(46, 51, 56, .05); --n-ripple-color: #0000; --n-text-color: #0573df; --n-text-color-hover: #0573df; --n-text-color-pressed: #000; --n-text-color-focus: #000; --n-text-color-disabled: #000; --n-border: 1px solid rgb(224,224,230); --n-height: 28px; --n-font-size: 14px; --n-padding: 0 10px; --n-icon-size: 13px; --n-icon-margin: 6px; --n-border-radius: 6px;'; }); refreshButton.innerHTML = ''; refreshButton.addEventListener('click', function() { window.location.reload(true); }); kfButton.addEventListener('click', function() { window.open('https://ai.getaiai.com/web?_userMenuKey=1794756256867553282&url=https%253A%252F%252Fai.getaiai.com%252Fkf.html', '_blank'); }); const nSpace = document.querySelector('.n-space'); if(nSpace) { custombuttons.forEach(button => { nSpace.insertBefore(button, nSpace.firstChild); }); } (function() { var target = document.body; var observer = new MutationObserver(function(mutations) { mutations.forEach(function(mutation) { if (mutation.attributeName === 'class') { var iframes = document.getElementsByTagName('iframe'); Array.prototype.forEach.call(iframes, function(iframe) { if (iframe.contentWindow) { iframe.contentWindow.postMessage({ type: 'themeChange', newClass: target.className }, '*'); } }); } }); }); var config = { attributes: true, attributeOldValue: true, attributeFilter: ['class'] }; observer.observe(target, config); })(); }); // function checkIframes() { // var iframes = document.getElementsByTagName('iframe'); // 获取所有iframe元素 // var pageOrigin = window.location.origin; // for (var i = 0; i < iframes.length; i++) { // var iframeSrc = iframes[i].getAttribute('src'); // // 忽略空src的iframe // if (!iframeSrc) continue; // try { // var url = new URL(iframeSrc, pageOrigin); // 处理相对URL // if (url.origin !== pageOrigin) { // 不同源 // alert('请在外部浏览器打开!'); // } // } catch (e) { // console.error('Error parsing iframe src:', e); // } // } // } // window.onload = checkIframes; // 页面加载完成时执行检查