Minecraft Helper

为 Minecraft 玩家定制的实用脚本

当前为 2023-04-09 提交的版本,查看 最新版本

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         Minecraft Helper
// @namespace    http://tampermonkey.net/
// @version      0.1.1
// @description  为 Minecraft 玩家定制的实用脚本
// @author       PRO
// @license      gpl-3.0
// @match        https://www.minecraft.net/*
// @match        https://www.curseforge.com/*
// @match        https://beta.curseforge.com/*
// @match        https://modrinth.com/*
// @icon         https://www.minecraft.net/etc.clientlibs/minecraft/clientlibs/main/resources/img/minecraft-creeper-face.jpg
// @grant        none
// ==/UserScript==

(function () {
    'use strict';
    let config = {
        "minecraft": {
            "auto-stay": true           // 自动点击“留在 Minecraft.net”
        },
        "curseforge": {
            "auto-beta": true,          // 自动转到 beta.curseforge.com (通常访问速度更快)
            "auto-mod": true,           // 首页自动转到 MC 模组界面
            "highlight-files": true,    // 突出显示 "Files" 项目
            "highlight-border": "rgb(241, 100, 54) 0.2em solid"
        },
        "modrinth": {
            "auto-mod": true            // 首页自动转到 MC 模组界面
        }
    };
    switch (window.location.host) {
        case 'www.minecraft.net': {
            if (config.minecraft["auto-stay"])
                document.getElementById("popup-btn").click();
            break;
        }
        case 'www.curseforge.com': {
            if (config.curseforge["auto-beta"]) {
                if (window.location.pathname == '/') {
                    window.location.href = config.curseforge["auto-mod"] ?
                        "https://beta.curseforge.com/minecraft/search?page=1&pageSize=20&sortType=1&class=mc-mods" :
                        "https://beta.curseforge.com/";
                } else if (window.location.pathname.startsWith("/minecraft/")) {
                    window.location.href = "https://beta.curseforge.com" + window.location.pathname;
                }
            }
            if (config.curseforge["auto-mod"] && window.location.pathname == '/') {
                window.location.pathname = "/minecraft/mc-mods";
            }
            break;
        }
        case 'beta.curseforge.com': {
            if (config.curseforge["auto-mod"] && window.location.pathname == '/') {
                window.location.pathname = "/minecraft/mc-mods";
            }
            if (config.curseforge["highlight-files"] && window.location.pathname != "/") {
                let tabs = document.getElementsByClassName("tabs");
                if (tabs.length) {
                    tabs = tabs[0];
                    for (let tab of tabs.children) {
                        if (tab.textContent == "Files") {
                            tab.style.border = config.curseforge["highlight-border"];
                            break;
                        }
                    }
                }
            }
            break;
        }
        case "modrinth.com": {
            if (window.location.pathname == "/" && config.modrinth["auto-mod"]) {
                document.querySelector(".button-group > a").click();
                break;
            }
            break;
        }
    }
})();