Greasy Fork

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

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

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

// ==UserScript==
// @name         偶像大师闪耀色彩跳过培育动画 [大概双端适配]
// @namespace    http://tampermonkey.net/
// @version      1.0
// @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';

    // Function to add buttons
    function addButtons() {
        // Check if buttons already exist on the page
        if (document.querySelector('.custom-button')) {
            return;
        }

        // Create buttons
        const button1 = document.createElement('button');
        const button2 = document.createElement('button');

        // Add class to buttons for identification
        button1.classList.add('custom-button');
        button2.classList.add('custom-button');

        // Apply button styles
        button1.textContent = '◀';
        button2.textContent = '▶';
        button1.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;
        `;
        button2.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;
        `;
        // Check if the device is mobile or PC and set button actions
        if (/Mobi|Android/i.test(navigator.userAgent)) {
            button1.addEventListener('touchstart', function() {
                window.location.href = '/produce/?a=';
            });
            button2.addEventListener('touchstart', function() {
                window.location.href = '/produce/?a=#';
            });
        } else {
            button1.addEventListener('click', function() {
                window.location.href = '/produce/?a=';
            });
            button2.addEventListener('click', function() {
                window.location.href = '/produce/?a=#';
            });
        }

        // Add buttons to the page
        document.body.appendChild(button1);
        document.body.appendChild(button2);
    }

    // Function to check and update buttons when URL changes
    function checkAndAddButtons() {
        const currentURL = window.location.href;
        if (currentURL.includes('produce')) {
            addButtons();
        }
    }

    // Observe changes to the URL and add buttons if necessary
    const urlObserver = new MutationObserver(checkAndAddButtons);
    const observerConfig = { childList: true, subtree: true };
    urlObserver.observe(document.documentElement, observerConfig);
})();