您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
在网页顶部中心显示BTC、ETH和ADA的实时价格
// ==UserScript== // @name 显示BTC、ETH和ADA实时价格 // @namespace http://tampermonkey.net/ // @version 0.1 // @description 在网页顶部中心显示BTC、ETH和ADA的实时价格 // @author You // @match *://*/* // @grant none // @license MIT // ==/UserScript== (function() { 'use strict'; // 创建一个div元素来显示价格 var priceDiv = document.createElement('div'); priceDiv.style.position = 'fixed'; priceDiv.style.top = '0'; priceDiv.style.left = '50%'; priceDiv.style.transform = 'translateX(-50%)'; priceDiv.style.backgroundColor = 'transparent'; priceDiv.style.color = '#000000'; priceDiv.style.zIndex = '999999'; priceDiv.style.display = 'inline-block'; // 使用inline-block布局 priceDiv.style.padding = '0'; // 去除内边距 document.body.appendChild(priceDiv); // 每隔5秒更新价格 setInterval(updatePrices, 5000); function updatePrices() { // 从OKX API获取BTC、ETH和ADA价格 Promise.all([ fetch('https://www.okx.com/api/v5/market/ticker?instId=BTC-USDT').then(response => response.json()), fetch('https://www.okx.com/api/v5/market/ticker?instId=ETH-USDT').then(response => response.json()), fetch('https://www.okx.com/api/v5/market/ticker?instId=ADA-USDT').then(response => response.json()) ]) .then(([btcData, ethData, adaData]) => { var btcPrice = btcData.data[0].last; var ethPrice = ethData.data[0].last; var adaPrice = adaData.data[0].last; priceDiv.innerHTML = `<span style="margin-right: 10px;">$${btcPrice}</span><span style="margin-right: 10px;">$${ethPrice}</span><span>$${adaPrice}</span>`; }) .catch(error => console.error(error)); } })();