本帖最后由 reober3 于 2025-12-30 21:50 编辑
之前忙着升级的时候经常喜欢看自己的积分 看看旅程多少了,追随有没有偷偷涨,小数点后是什么数字了…… 虽然鼠标悬浮于右侧栏的“积分”两字时可以快速查看自己的一些属性 但是少了主题和回帖,我想算的时候还得点进自己主页看 所以就在ai帮助下做了一个脚本 只需鼠标悬停于积分数字(1148)上,即可展示出具体的积分组成
复制后新建脚本即可~
@Name @match @Name @Match- // ==UserScript==
- // @name 积分组成便捷显示
- // @version 2.3
- // @description 鼠标悬停积分数字时显示计算详情
- // @author rober
- // @match https://www.gamemale.com/*
- // @match https://www.gamemale.com/forum.php
- // @grant GM_xmlhttpRequest
- // ==/UserScript==
- (function() {
- 'use strict';
- let cache;
- const doc = document;
- const iHTML = 'inner' + 'HTML';
- const disp = 'dis' + 'play';
- const cE = 'create' + 'Element';
- const aC = 'append' + 'Child';
- const tip = doc[cE]('div');
- tip.style.cssText = 'posi'+'tion:fixed;dis'+'play:none;back'+'ground:rgba(0,0,0,0.9);color:#fff;pad'+'ding:12px;border-radius:6px;font-size:13px;line-height:1.6;z-index:99999;pointer-events:none;min-width:190px;border:1px solid #555;font-family:"Microsoft YaHei";box-shadow:0 4px 12px rgba(0,0,0,0.5)';
- doc.body[aC](tip);
- const render = (d) => {
- const s_fol = d.f / 5, s_act = (d.t + d.p) / 10;
- const dv = '<' + 'div';
- const dve = '<' + '/div>';
- tip[iHTML] = `
- ${dv} style="font-weight:bold;color:#f0c14b;border-bottom:1px solid #555;margin-bottom:5px">积分计算详情${dve}
- ${dv} style="display:flex;justify-content:space-between"><span>旅程:</span><b>${d.j}</b>${dve}
- ${dv} style="display:flex;justify-content:space-between"><span>追随/5:</span><span style="color:#aeffc1">${s_fol.toFixed(2)}</span>${dve}
- ${dv} style="display:flex;justify-content:space-between"><span>(主题+回帖)/10:</span><span style="color:#ffb8a2">${s_act.toFixed(2)}</span>${dve}
- ${dv} style="border-top:1px dashed #666;margin-top:5px;padding-top:5px;display:flex;justify-content:space-between">
- <span>总分:</span><strong style="color:#FFD700">${(d.j + s_fol + s_act).toFixed(2)}</strong>
- ${dve}
- ${dv} style="text-align:right;font-size:12px;color:#888;margin-top:4px">(原数据: 追随${d.f}/主题${d.t}/回帖${d.p})${dve}`;
- };
- const getData = () => {
- if (cache) return render(cache);
- tip[iHTML] = '读取中...';
- GM_xmlhttpRequest({
- method: "GET", url: "/home.php?mod=space&do=profile",
- onload: r => {
- const h = r.responseText;
- const get = (re) => parseInt((h.match(re) || [])[1]) || 0;
- cache = {
- j: get(/<em>旅程<\/em>\s*(\d+)/),
- f: get(/<em>追随<\/em>\s*(\d+)/),
- t: get(/>主题(?:数)?\s*(\d+)</),
- p: get(/>回帖(?:数)?\s*(\d+)</)
- };
- render(cache);
- }
- });
- };
- const timer = setInterval(() => {
- const target = doc.querySelector('#extcreditmenu + span a');
- if (target) {
- clearInterval(timer);
- target.addEventListener('mouseenter', () => {
- const rect = target.getBoundingClientRect();
- tip.style.top = (rect.bottom + 8) + 'px';
- tip.style.left = (rect.left - 120) + 'px';
- tip.style[disp] = 'block';
- getData();
- });
- target.addEventListener('mouseleave', () => { tip.style[disp] = 'none'; });
- }
- }, 500);
- })();
复制代码喜欢的话可以点点追随呀~ (暂时不要堕落惹
|