小小的制作了一个适用于MJJ的脚本!(手把手教学使用~)

因为本论坛也是基于Discourse模版!所以适用于大多数论坛~

由于众多佬友询问如何使用,那我也不能再偷懒了!下面一步步手把手教学吧!

首先先下载篡改猴插件!

篡改猴 - Microsoft Edge Addons

上面是edge浏览器的,下面是chrome浏览器的!其实通用的!

安装完成之后,将其固定在工具栏中!

image

点击这个进入到扩展选项

点击油猴脚本的图标!

全选删除上面原有代码,将下面的进行复制,粘贴进去即可,按ctrl+s进保持。

// ==UserScript==
// @name         MJJ分数与排名显示
// @namespace    http://tampermonkey.net/
// @version      2025-9-9
// @description  显示排名和积分(含今日排名)
// @author       You
// @match        https://mjjbox.com/*
// @icon         https://mjjbox.com/user_avatar/mjjbox.com/admin/48/106_2.png
// @grant        none
// ==/UserScript==
(function () {
    'use strict';
    // 创建显示元素
    function createDisplay() {
        const headerUL = document.querySelector(".icons.d-header-icons");
        if (!headerUL) return;
        const li = document.createElement('li');
        li.id = 'nodeScoreHeader_score_id';
        li.className = 'icon-header icon-header-small icon-header-link';
        li.style.marginLeft = '12px';
        const button = document.createElement('button');
        button.id = 'nodeScoreHeader_id_val';
        button.className = 'btn no-text btn-icon ai-bot-button icon btn-flat';
        button.style.width = 'auto';
        button.style.cursor = 'pointer';
        button.title = '点击查看排行榜';
        button.innerHTML = '加载中...';
        button.onclick = () => window.open(`${window.location.origin}/leaderboard/1`, '_blank');
        li.appendChild(button);
        headerUL.insertBefore(li, headerUL.firstChild);
    }
    // 获取用户ID并执行后续操作
    function init() {
        const interval = setInterval(() => {
            const userImgBTN = document.getElementById("toggle-current-user");
            if (!userImgBTN) return;
            try {
                const userID = userImgBTN.querySelector("img").src.split('/').slice(-3)[0];
                clearInterval(interval);

                // 获取今日排名
                fetch(`${window.location.origin}/leaderboard/1.json?period=daily`)
                    .then(res => res.json())
                    .then(dailyData => {
                        const dailyRank = dailyData?.personal?.position;

                        // 获取全局排名
                        fetch(`${window.location.origin}/leaderboard/1.json`)
                            .then(res => res.json())
                            .then(data => {
                                const rank = data?.personal?.position;
                                // 获取积分
                                fetch(`${window.location.origin}/u/${userID}.json`)
                                    .then(res => res.json())
                                    .then(data => {
                                        const score = data?.user?.gamification_score;
                                        const btn = document.getElementById("nodeScoreHeader_id_val");
                                        if (btn && rank && score) {
                                            let displayText = '';
                                            // 添加今日排名(如果存在)
                                            if (dailyRank) {
                                                displayText += `今日排名: <span style="color:orange;font-weight:bold">${dailyRank}</span> `;
                                            }
                                            // 添加全局排名和积分
                                            displayText += `排名: <span style="color:red;font-weight:bold">${rank}</span> 积分: <span style="color:green;font-weight:bold">${score}</span>`;
                                            btn.innerHTML = displayText;
                                        }
                                    });
                            });
                    })
                    .catch(() => {
                        // 如果获取今日排名失败,只显示全局排名和积分
                        fetch(`${window.location.origin}/leaderboard/1.json`)
                            .then(res => res.json())
                            .then(data => {
                                const rank = data?.personal?.position;
                                fetch(`${window.location.origin}/u/${userID}.json`)
                                    .then(res => res.json())
                                    .then(data => {
                                        const score = data?.user?.gamification_score;
                                        const btn = document.getElementById("nodeScoreHeader_id_val");
                                        if (btn && rank && score) {
                                            btn.innerHTML = `排名: <span style="color:red;font-weight:bold">${rank}</span> 积分: <span style="color:green;font-weight:bold">${score}</span>`;
                                        }
                                    });
                            });
                    });
            } catch (e) {
                // 忽略错误
            }
        }, 1000);
        // 30秒后清除定时器,避免无限循环
        setTimeout(() => clearInterval(interval), 30000);
    }
    // 执行初始化
    createDisplay();
    init();
})();

如果操作成功,重新访问MJJ网站时就会显示下面的排名积分

image

实际使用效果~

5 个赞

牛逼啊

1 个赞

学习了 :face_holding_back_tears:

1 个赞

脚本越来越多了

1 个赞

牛逼大佬,关键怎么玩

1 个赞

佬给的启发效果好!我也用上了佬推荐的脚本,效果很赞~

直接复制上段的脚本,粘贴到篡改猴脚本使用就行了!:tada: 分享【原创脚本】MJJBOX增强助手 - 等级查看器+自定义背景+美化字体,让论坛更个性! - 教程工坊 - MJJBOX可以参考这个佬的教程步骤!

学习了

1 个赞

真牛

1 个赞

大佬啊,能不能写成组件,直接内置到论坛功能

1 个赞

这~我也只是小白摸索,没接触过具体社区建站内容!感觉难啊!(灰总太看的起我了~):smiling_face_with_three_hearts:

真牛 :saluting_face:

怎么玩的啊

怎么玩的,感觉很厉害的样子

:+1:不错捏

看上面的回复~有个连接点击进去即可参考教程一步步来!

天选MJJ果然不一样

1 个赞

学习

1 个赞

除了看不懂,什么都好,哈哈

1 个赞

学习

1 个赞