➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖
😋rt,用OpenAI写出来的,目前只测试支持官方默认主题
➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖
🚩使用方法
粘贴代码到设置-站点-自定义-自定义头部,然后保存
➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖
⚠外部调用
调用了 https://open.er-api.com 的汇率 api
➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖
👻效果如下

➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖
👾代码如下
➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖
<script>
(function () {
'use strict';
function waitForBody(callback) {
if (document.body) {
callback();
} else {
requestAnimationFrame(() => waitForBody(callback));
}
}
waitForBody(() => {
let rates = null;
/* 获取汇率(基于 CNY) */
fetch('https://open.er-api.com/v6/latest/CNY')
.then(r => r.json())
.then(data => {
if (data && data.rates) {
rates = data.rates;
convertAll();
}
})
.catch(err => console.error('汇率获取失败', err));
const currencyMap = {
"$": "USD",
"€": "EUR",
"£": "GBP",
"₽": "RUB",
"₣": "CHF",
"₹": "INR",
"₫": "VND",
"฿": "THB"
};
function convertText(text) {
if (!rates) return text;
if (text.startsWith('¥')) return text;
for (const symbol in currencyMap) {
if (!text.includes(symbol)) continue;
const code = currencyMap[symbol];
const match = text.match(/([\d]+(?:\.[\d]+)?)/);
if (!match || !rates[code]) return text;
const value = parseFloat(match[1]);
if (isNaN(value)) return text;
const cnyValue = value / rates[code];
const suffix = text.slice(match.index + match[1].length);
return `¥${cnyValue.toFixed(2)}${suffix}`;
}
return text;
}
function convertAll() {
if (!rates) return;
document
.querySelectorAll('span.rt-Badge label.text-xs')
.forEach(label => {
const text = label.innerText.trim();
if (!text) return;
if (text.startsWith('¥')) return;
if (!/[€$£₽₣₹₫฿]/.test(text)) return;
const converted = convertText(text);
if (converted !== text) {
label.innerText = converted;
}
});
}
/* 监听 DOM 变化(支持切换列表/网格、懒加载) */
const observer = new MutationObserver(convertAll);
observer.observe(document.body, {
childList: true,
subtree: true
});
/* 初次执行 */
convertAll();
});
})();
</script>
bd
支持
牛逼 可惜我是第三方主题
牛逼, 不过我还是喜欢原货币
好东西
好东西
拿走了,感谢楼主
要换成视图模式,网格模式不行
收藏了
高手