挂件头衔✨️靓标库🧚‍♂️名人堂🦄宝可梦🍎水果机🥊猜拳🏧黑市🏧银行💹抽奖
   🎁
返回列表 发布新帖
查看: 183|回复: 0

[代码技巧] 子比美化 – 侧边用户UA信息小工具

[复制链接]
社区贡献

331

主题

204

回帖

2万

积分

等级头衔
Icon组别 : 管理员
Icon等级 :

积分成就
   钻石 : 293 颗
   贡献 : 40842 点
   金币 : 24 枚
Icon在线时间 : 1696 小时
Icon注册时间 : 2024-11-22
Icon最后登录 : 2026-6-11

荣誉勋章

连续签到LV.1累计签到LV.3任务·年会员幸运抽奖·皇幸运抽奖·尊幸运抽奖·豪起源之星摩羯座推广LV.2钻石LV.1注册一周年

总共送礼:1 个    总共收礼:0 个

实力·绝代收藏家

飞流名人堂成员 1 FLLTCN 实名认证 特邀大神 诚信商家 信誉担保 精华作者+ 官方团队 vip vip-year 发表于 2025-10-10 18:16:42 | 查看全部 |阅读模式 浙江金华

交易无需等待,成交就是现在,全面资源整合网络大咖云集,让你轻松玩转互联网!

您需要 登录 才可以下载或查看,没有账号?立即注册

×
这是一款子比主题的侧边侧边用户UA信息小工具,这款小工具非常详细的定位当前的位置,并且还有精准的IP,不过只能用户可以看到自己的地址和IP,喜欢的自行部署吧!

tengfei_down - 2025-10-10T181609.230.webp

代码部署


定位:WP后台–>>外观–>>小工具–>>自定义HTML,将下面的代码放到里面即可!
  1. <div class="ua-info-widget" style="border: 1px solid #333; border-radius: 10px; padding: 15px; box-shadow: 0 3px 10px rgba(0,0,0,0.2); background-color: #1a1a1a; color: #f0f0f0; max-width: 300px; transition: all 0.3s ease;">
  2.     <h3 style="margin-top: 0; color: #ffffff; border-bottom: 1px solid #444; padding-bottom: 10px; font-size: 16px; font-family: Arial, sans-serif;">设备信息</h3>
  3.     <div id="ua-loading" style="color: #bbb; padding: 10px 0; font-size: 14px;">加载中...</div>
  4.     <ul id="ua-info-list" style="display: none; list-style: none; padding: 0; margin: 10px 0;">
  5.         <li style="padding: 6px 0; border-bottom: 1px dashed #444; font-size: 14px; font-family: Arial, sans-serif;"><strong style="color: #81c3ff; min-width: 65px; display: inline-block;">IP:</strong> <span id="ua-ip" style="color: #f0f0f0;"></span></li>
  6.         <li style="padding: 6px 0; border-bottom: 1px dashed #444; font-size: 14px; font-family: Arial, sans-serif;"><strong style="color: #81c3ff; min-width: 65px; display: inline-block;">位置:</strong> <span id="ua-address" style="color: #f0f0f0;"></span></li>
  7.         <li style="padding: 6px 0; border-bottom: 1px dashed #444; font-size: 14px; font-family: Arial, sans-serif;"><strong style="color: #81c3ff; min-width: 65px; display: inline-block;">浏览器:</strong> <span id="ua-browser" style="color: #f0f0f0;"></span></li>
  8.         <li style="padding: 6px 0; border-bottom: 1px dashed #444; font-size: 14px; font-family: Arial, sans-serif;"><strong style="color: #81c3ff; min-width: 65px; display: inline-block;">系统:</strong> <span id="ua-os" style="color: #f0f0f0;"></span></li>
  9.         <li style="padding: 6px 0; font-size: 14px; font-family: Arial, sans-serif;"><strong style="color: #81c3ff; min-width: 65px; display: inline-block;">设备:</strong> <span id="ua-device" style="color: #f0f0f0;"></span></li>
  10.     </ul>
  11.     <div id="ua-error" style="display: none; color: #ff6b6b; font-size: 14px; padding: 10px; background-color: #2d1b1b; border-radius: 6px; border: 1px solid #4a2727;"></div>
  12. </div>

  13. <script>
  14. // 检测系统是否偏好暗色模式并适配
  15. if (window.matchMedia && window.matchMedia('(prefers-color-scheme: light)').matches) {
  16.     // 如果是亮色模式,调整样式
  17.     document.querySelector('.ua-info-widget').style.backgroundColor = '#ffffff';
  18.     document.querySelector('.ua-info-widget').style.color = '#333';
  19.     document.querySelector('.ua-info-widget').style.borderColor = '#e0e0e0';
  20.    
  21.     // 调整文本颜色
  22.     const textElements = document.querySelectorAll('#ua-info-list span');
  23.     textElements.forEach(el => {
  24.         el.style.color = '#333';
  25.     });
  26.    
  27.     // 调整标题和分隔线
  28.     document.querySelector('.ua-info-widget h3').style.color = '#333';
  29.     document.querySelector('.ua-info-widget h3').style.borderBottomColor = '#f0f0f0';
  30.    
  31.     // 调整加载状态
  32.     document.getElementById('ua-loading').style.color = '#666';
  33. }

  34. // 获取UA信息
  35. fetch('https://v2.xxapi.cn/api/ua')
  36.     .then(response => {
  37.         if (!response.ok) {
  38.             throw new Error('网络响应不正常');
  39.         }
  40.         return response.json();
  41.     })
  42.     .then(data => {
  43.         document.getElementById('ua-loading').style.display = 'none';
  44.         
  45.         if (data.code === 200 && data.data) {
  46.             document.getElementById('ua-info-list').style.display = 'block';
  47.             document.getElementById('ua-ip').textContent = data.data.ip || '未知';
  48.             document.getElementById('ua-address').textContent = data.data.address || '未知';
  49.             document.getElementById('ua-browser').textContent =
  50.                 (data.data.browser || '未知') + ' ' + (data.data.browserVersion || '');
  51.             document.getElementById('ua-os').textContent = data.data.os || '未知';
  52.             document.getElementById('ua-device').textContent = data.data.deviceType || '未知';
  53.         } else {
  54.             document.getElementById('ua-error').textContent = data.msg || '获取信息失败';
  55.             document.getElementById('ua-error').style.display = 'block';
  56.         }
  57.     })
  58.     .catch(error => {
  59.         document.getElementById('ua-loading').style.display = 'none';
  60.         document.getElementById('ua-error').textContent = '加载失败: ' + error.message;
  61.         document.getElementById('ua-error').style.display = 'block';
  62.     });
  63. </script>
复制代码


本帖被以下淘专辑推荐:

路虽远,行则将至;事虽难,做则必成。
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

飞流广播+ 发布

系统消息:飞流安卓客户端APP已上线,请在QQ群(123129)群文件内获取下载。
02-21 02:22
01-24 12:40
站内通告

📢 六月份后均不在线,请悉知

提供资源交易、信息共享、靓号交流、技术变现、学习问答、兴趣娱乐等全面服务。

1.丰富功能系统,扩展社区特色玩法,打造最好的互联网聚集圈子。

2.准确信息真实交易,安全快捷又方便,让虚拟交易面对面。

3. 天上不会掉馅饼,话术骗术迷人心,切勿脱离平台线下交易,被骗与平台无关!

4. 欺诈骗钱,违规违法将视情受到警告&禁言&封号甚至检举至👮🏻‍♀️处理!

官方Q群:1003810038钉推群:BAYR2383 站长QQ:3388700000

飞流论坛(FLLT.CN),一个专注于资源信息发布、虚拟网络交易、技术学习与娱乐社交的交流平台。
  • 钉钉新帖推送群
  • 官方交流QQ群
  • 站长唯一微信号

💥客户端|🧿小黑屋|📴手机页|飞流网 |网站地图

GMT+8, 2026-6-12 06:52 , Processed in 0.097652 second(s), 84 queries, MemCached On , Gzip On.

飞流论坛 HanAnalytics icp

Copyright © 2024-2026 飞流网 版权所有 All Rights Reserved. X3.5

快速回复 返回顶部 返回列表