Greasy Fork

偶像大师闪耀色彩跳过培育动画 [目标是双端适配]

跳过培育动画自用,不懂代码,gpt写的.jpg

目前为 2023-08-15 提交的版本。查看 最新版本

// ==UserScript==
// @name         偶像大师闪耀色彩跳过培育动画 [目标是双端适配]
// @namespace    http://tampermonkey.net/
// @version      0.6
// @description  跳过培育动画自用,不懂代码,gpt写的.jpg
// @author       ER@关注b站EreRe_看折纸纸片人谢谢喵
// @match        https://shinycolors.enza.fun/*
// @run-at       document-end
// @icon         https://shinycolors.enza.fun/icon_192x192.png
// @grant        none
// @license      MIT
// ==/UserScript==

(function() {
    'use strict';

    // 标志用于检查是否已添加按钮
    let buttonsAdded = false;

    // 动态添加按钮
    function addButtons() {
        if (buttonsAdded) {
            return;
        }

        // 检测当前URL是否匹配
        if (window.location.href.includes(produce)) {
            buttonsAdded = true;

           // 创建按钮a
        const buttonA = document.createElement('button');
        buttonA.textContent = '◀'; // 向左的三角形
        buttonA.style.cssText = `
            position: fixed;
            bottom: 3vw;
            left: 41vw;
            opacity: 0.4;
            background-color: gray;
            color: white;
            border: none;
            padding: 0;
            cursor: pointer;
            width: 8vw;
            height: 8vw;
            z-index: 9999;
        `;

        // 创建按钮b
        const buttonB = document.createElement('button');
        buttonB.textContent = '▶'; // 向右的三角形
        buttonB.style.cssText = `
            position: fixed;
            bottom: 3vw;
            left: 51vw;
            opacity: 0.4;
            background-color: gray;
            color: white;
            border: none;
            padding: 0;
            cursor: pointer;
            width: 8vw;
            height: 8vw;
            z-index: 9999;
        `;

            // 将按钮添加到页面
            document.body.appendChild(buttonA);
            document.body.appendChild(buttonB);

            // 检测 User Agent,判断设备类型
            const isMobile = /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);

            // 设置按钮的事件类型
            const eventType = isMobile ? 'tap' : 'click';

            // 按钮a的点击事件
            buttonA.addEventListener(eventType, function() {
                if (isMobile) {
                    window.location.href = 'https://shinycolors.enza.fun/produce/?'; // 移动设备跳转到c网页
                } else {
                    navigateToPageA();
                }
            });

            // 按钮b的点击事件
            buttonB.addEventListener(eventType, function() {
                if (isMobile) {
                    window.location.href = 'https://shinycolors.enza.fun/produce/?#'; // 移动设备跳转到d网页
                } else {
                    navigateToPageB();
                }
            });

            // 使用onclick实现跳转
            function navigateToPageA() {
                window.location.href = 'https://shinycolors.enza.fun/produce/?a='; // PC设备跳转到a网页
            }

            function navigateToPageB() {
                window.location.href = 'https://shinycolors.enza.fun/produce/?a=#'; // PC设备跳转到b网页
            }
        }
    }

    // 页面加载完后尝试添加按钮
    document.addEventListener('DOMContentLoaded', addButtons);

    // 监听URL变化,以便在SPA导航时重新检查添加按钮
    window.addEventListener('popstate', addButtons);

})();