Greasy Fork 还支持 简体中文。

Minecraft Helper

为 Minecraft 玩家定制的实用脚本

اعتبارا من 10-04-2023. شاهد أحدث إصدار.

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

ستحتاج إلى تثبيت إضافة مثل Stylus لتثبيت هذا النمط.

ستحتاج إلى تثبيت إضافة لإدارة أنماط المستخدم لتتمكن من تثبيت هذا النمط.

ستحتاج إلى تثبيت إضافة لإدارة أنماط المستخدم لتثبيت هذا النمط.

ستحتاج إلى تثبيت إضافة لإدارة أنماط المستخدم لتثبيت هذا النمط.

(لدي بالفعل مثبت أنماط للمستخدم، دعني أقم بتثبيته!)

// ==UserScript==
// @name         Minecraft Helper
// @namespace    http://tampermonkey.net/
// @version      0.2.0
// @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 模组界面
            "shortcut": true            // 快捷键: <F>iles, <-, ->
        }
    };
    function try_click(selector) {
        let ele = document.querySelector(selector);
        if (ele) ele.click();
    }
    switch (window.location.host) {
        case 'www.minecraft.net': {
            if (config.minecraft["auto-stay"])
                try_click("#popup-btn");
            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"]) {
                try_click(".button-group > a");
            }
            if (config.modrinth.shortcut) {
                document.addEventListener("keydown", (e) => {
                    switch (e.key) {
                        case "ArrowLeft":
                            try_click(".left-arrow");
                            break;
                        case "ArrowRight":
                            try_click(".right-arrow");
                            break;
                        case "f":
                            try_click(".goto-link");
                            break;
                        default:
                            break;
                    }
                })
            }
            break;
        }
    }
})();