Multi-Redirect Buttons for Google PlayStore// ==UserScript==

Adds multiple buttons to redirect from Google PlayStore to different websites.

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         Multi-Redirect Buttons for Google PlayStore// ==UserScript==
// @name         Multi-Redirect Buttons for Google PlayStore (Clean Version)
// @namespace    Multi-Redirect Buttons
// @version      2.4
// @description  Adds multiple buttons to redirect from Google PlayStore to different websites.
// @match        https://play.google.com/store/apps/details?id=*
// @grant        GM_addStyle
// ==/UserScript==

(function () {
    'use strict';

    // Safe style injection
    function safeAddStyle(css) {
        if (typeof GM_addStyle !== "undefined") {
            GM_addStyle(css);
        } else {
            let style = document.createElement("style");
            style.textContent = css;
            document.head.appendChild(style);
        }
    }

    // Button builder
    function addButtons(parent) {
        if (!parent || document.getElementById("a2z-history")) return;

        const idMatch = location.href.match(/id=([a-zA-Z0-9._]+)/);
        if (!idMatch) return;
        const id = idMatch[1];

        const buttonsConfig = [
            { id: 'a2z-history', text: 'A2zapk History', url: 'https://a2zapk.io/History/' + id + '/', color: '#00875f' },
            { id: 'a2z-download', text: 'A2zapk Download', url: 'https://a2zapk.io/apk/' + id + '.html', color: '#00875f' },
            { id: 'apkmirror', text: 'Apkmirror', url: 'https://www.apkmirror.com/?post_type=app_release&searchtype=apk&s=' + id, color: '#FF8B14' },
            { id: 'apkpure', text: 'APKPure', url: 'https://apkpure.com/search?q=' + id, color: '#24cd77' },
            { id: 'apkcombo', text: 'ApkCombo', url: 'https://apkcombo.com/search?q=' + id, color: '#286090' }
        ];

        // Inject CSS once
        safeAddStyle(`
            .button-container {
                display: flex;
                flex-wrap: wrap;
                gap: 4px;
                margin-top: 8px;
            }
            .button-container button {
                color: #fff;
                font-family: Roboto, Arial, sans-serif;
                font-size: .9rem;
                font-weight: 500;
                height: 36px;
                cursor: pointer;
                padding: 0 12px;
                border-radius: 8px;
                display: inline-flex;
                align-items: center;
                justify-content: center;
                box-sizing: border-box;
                transition: transform 0.2s, filter 0.2s;
                border: none;
            }
            .button-container button:hover {
                filter: brightness(0.85);
                transform: translateY(-2px);
            }
        `);

        let container = document.createElement("div");
        container.className = "button-container";
        parent.appendChild(container);

        buttonsConfig.forEach(cfg => {
            let btn = document.createElement("button");
            btn.id = cfg.id;
            btn.textContent = cfg.text;
            btn.style.backgroundColor = cfg.color;
            btn.addEventListener("click", () => { window.location.href = cfg.url; });
            container.appendChild(btn);
        });
    }

    // Mutation observer, disconnect after success
    function observeDOM() {
        const observer = new MutationObserver(() => {
            let title = document.querySelector("h1 span");
            if (title) {
                addButtons(title.parentElement);
                observer.disconnect(); // stop once buttons are added
            }
        });
        observer.observe(document.body, { childList: true, subtree: true });
    }

    if (location.href.includes("/store/apps/details")) {
        observeDOM();
    }

})();
// @version      2.3
// @description  Adds multiple buttons to redirect from Google PlayStore to different websites (A2Zapk, APKMirror, APKPure, ApkCombo).
// @match        https://play.google.com/store/apps/details?id=*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=a2zapk.com
// @grant        GM_addStyle
// ==/UserScript==

(function() {
    'use strict';

    // Function to create and insert the buttons
    function addButtons() {
        // Extract the package name from the URL
        var idMatch = location.href.match(/id=([a-zA-Z0-9._]+)/);
        if (!idMatch) return; // If no match found, exit the function
        var id = idMatch[1];

        // Define the button configurations
        const buttonsConfig = [
            { id: 'a2z-history', text: 'A2zapk History', url: 'https://a2zapk.io/History/' + id + '/', color: '#00875f' },
            { id: 'a2z-download', text: 'A2zapk Download', url: 'https://a2zapk.io/apk/' + id + '.html', color: '#00875f' },
            { id: 'apkmirror', text: 'Apkmirror', url: 'https://www.apkmirror.com/?post_type=app_release&searchtype=apk&s=' + id, color: '#FF8B14' },
            { id: 'apkpure', text: 'APKpure', url: 'https://apkpure.net/search?q=' + id, color: '#24cd77' },
            { id: 'apkcombo', text: 'ApkCombo', url: 'https://apkcombo.net/search?q=' + id, color: '#286090' } // Updated URL
        ];

        // Parent container styling to ensure buttons fit
        GM_addStyle(`
            .button-container {
                display: flex;
                flex-wrap: wrap;
                gap: 4px; /* Adjust gap to control spacing */
                justify-content: flex-start;
            }
        `);

        let parentElement = document.querySelector('[data-item-id^="%.@."]');
        if (parentElement) {
            // Create a container for the buttons
            let buttonContainer = document.createElement('div');
            buttonContainer.className = 'button-container';

            // Append the container to the parent element
            parentElement.appendChild(buttonContainer);

            // Append each button to the button container
            buttonsConfig.forEach(config => {
                // Create button element
                let button = document.createElement('button');
                button.id = config.id;
                button.innerHTML = config.text;

                // Add button styles
                GM_addStyle(`
                    #${config.id} {
                        color: #fff;
                        background-color: ${config.color};
                        font-family: "GoogleSans", Roboto, Arial, sans-serif;
                        line-height: 1.25rem;
                        font-size: .920rem;
                        letter-spacing: .0178571429em;
                        font-weight: 500;
                        height: 36px;
                        margin: 0; /* Remove margin, handled by container gap */
                        cursor: pointer;
                        padding: 0 12px; /* Reduced padding to fit more buttons */
                        border-radius: 8px; /* Adjusted border-radius for consistent look */
                        display: inline-flex;
                        align-items: center;
                        justify-content: center;
                        box-sizing: border-box;
                        transition: transform 0.2s, filter 0.2s;
                    }
                    #${config.id}:hover {
                        filter: brightness(0.85);
                        transform: translateY(-2px);
                    }
                `);

                // Append the button to the container
                buttonContainer.appendChild(button);

                // Add click event to redirect to the configured URL
                button.addEventListener('click', function() {
                    window.location.href = config.url;
                });
            });
        }
    }

    // Check if the current URL is an app details page and add buttons
    if (window.location.href.indexOf("https://play.google.com/store/apps/details") > -1) {
        addButtons();
    }

    // Monitor for URL changes to re-add the buttons if needed
    let currentPage = location.href;
    setInterval(function() {
        if (currentPage !== location.href) {
            if (window.location.href.indexOf("https://play.google.com/store/apps/details") > -1) {
                currentPage = location.href;
                setTimeout(addButtons, 500);
            }
            currentPage = location.href;
        }
    }, 500);
})();