// ==UserScript== // @name 福利云xwteam金价信息美化显示 // @namespace http://tampermonkey.net/ // @version 1.0 // @description 美化https://free.xwteam.cn/api/gold/trade页面的JSON数据显示 // @author Dr.S // @match https://free.xwteam.cn/api/gold/trade // @grant MIT // ==/UserScript== (function() { 'use strict'; // 创建一个样式用于优化显示 const style = document.createElement('style'); style.innerHTML = ` body { font-family: "Helvetica Neue", Arial, sans-serif; background-color: #f7f7f7; padding: 15px; color: #333; } .container { max-width: 800px; margin: 0 auto; background: #fff; border-radius: 8px; box-shadow: 0 4px 12px rgba(0,0,0,0.1); padding: 20px; } h1, h2 { color: #0066cc; } table { width: 100%; border-collapse: collapse; margin-bottom: 20px; } th, td { border: 1px solid #ddd; padding: 12px 8px; text-align: left; } th { background-color: #0066cc; color: white; } tr:nth-child(even) { background-color: #f2f2f2; } tr:hover { background-color: #ddd; } @media (max-width: 600px) { th, td { display: block; width: 100%; text-align: right; } td:before { content: attr(data-label); float: left; font-weight: bold; } } `; document.head.appendChild(style); // 获取原始JSON数据并替换页面内容 fetch('https://free.xwteam.cn/api/gold/trade') .then(response => response.json()) .then(data => { let htmlContent = '
| 名称 | 买入价 | 卖出价 | 最高价 | 最低价 |
|---|---|---|---|---|
| ${item.Name} | ${item.BP} | ${item.SP} | ${item.High} | ${item.Low} |