// ==UserScript== // @name 显示当前域名的IP信息 // @namespace https://tools.0x5c0f.cc // @version 1.2.2 // @description 显示当前页面域名的IP信息(自用!!!) // @description 当前脚本由 Coze Bot - Only Chat 生成 // @description 后端服务只是一个简单的解析然后返回解析的目标信息,是我用来判断我本地解析和公网解析是否一致的问题。 // @description api: https://tools.0x5c0f.cc/api/docs // @author 0x5c0f // @license CC BY-NC-SA 4.0 // @match *://*/* // @grant GM_xmlhttpRequest // @grant GM_addStyle // @downloadURL https://update.greasyfork.icu/scripts/494983/%E6%98%BE%E7%A4%BA%E5%BD%93%E5%89%8D%E5%9F%9F%E5%90%8D%E7%9A%84IP%E4%BF%A1%E6%81%AF.user.js // @updateURL https://update.greasyfork.icu/scripts/494983/%E6%98%BE%E7%A4%BA%E5%BD%93%E5%89%8D%E5%9F%9F%E5%90%8D%E7%9A%84IP%E4%BF%A1%E6%81%AF.meta.js // ==/UserScript== (function() { 'use strict'; if (window.self !== window.top) { return; } var domain = window.location.hostname; var apiUrl = "https://tools.0x5c0f.cc/api/iptools?ip=" + domain; var ipInfo = null; var isDragging = false; var mouseX = 0, mouseY = 0; createDisplayDiv(); // 请求IP信息 // 请求IP信息 GM_xmlhttpRequest({ method: "GET", url: apiUrl, headers: { "Cache-Control": "no-cache, no-store, must-revalidate", "Pragma": "no-cache", "Expires": "0" }, onload: function(response) { try { var data = JSON.parse(response.responseText); if (data.status === 200 && data.data) { ipInfo = data.data.join(", "); // 保存IP信息 } else { ipInfo = 'Error loading IP info'; // 错误信息 } } catch (e) { console.error('Failed to parse response: ', response.responseText); ipInfo = 'Error loading IP info'; } } }); function bindHoverEvents() { var div = document.querySelector('#ipInfoDiv'); if (div) { div.addEventListener('mouseenter', function() { this.style.width = 'auto'; this.style.height = '35px'; this.style.borderRadius = '5px'; this.style.backgroundColor='white'; this.style.backgroundImage=''; this.style.opacity = '1'; this.innerText = ipInfo; }); div.addEventListener('mouseleave', function() { this.style.width = '40px'; this.style.height = '40px'; this.style.borderRadius = '50%'; this.style.backgroundColor='#61a9fe'; this.style.opacity = '0.6'; this.innerText = ''; }); div.addEventListener('mousedown', function(event) { isDragging = true; mouseX = event.clientX - this.getBoundingClientRect().left; mouseY = event.clientY - this.getBoundingClientRect().top; }); document.addEventListener('mousemove', function(event) { if (isDragging) { div.style.left = `${event.clientX - mouseX}px`; div.style.bottom = `${window.innerHeight - event.clientY - mouseY}px`; } }); document.addEventListener('mouseup', function() { isDragging = false; }); } } // 创建展示IP信息的div function createDisplayDiv() { var div = document.createElement('div'); div.id = 'ipInfoDiv'; div.style.width = '40px'; div.style.height = '40px'; div.style.borderRadius = '50%'; div.innerText = ''; document.body.appendChild(div); bindHoverEvents(); // 使用 GM_addStyle 添加 CSS 样式 GM_addStyle(` #ipInfoDiv { position: fixed; left: 15px; bottom: 25px; background-color: #61a9fe; border-radius: 50%; width: 40px; height: 40px; display: flex; align-items: center; justify-content: center; transition: all 0.3s; box-sizing: border-box; cursor: pointer; z-index: 110000; border: 1px solid #5054e7; opacity: 0.6; } /* #ipInfoDiv:hover { opacity: 0.5; // 鼠标悬停时完全不透明 } */ `); } })();