Multi-Redirect Buttons for Google PlayStore

Adds multiple buttons to redirect from Google PlayStore to different websites (A2Zapk, APKMirror, APKpure, ApkCombo).

À partir de 2024-05-31. Voir la dernière version.

Vous devrez installer une extension telle que Tampermonkey, Greasemonkey ou Violentmonkey pour installer ce script.

Vous devrez installer une extension telle que Tampermonkey ou Violentmonkey pour installer ce script.

Vous devrez installer une extension telle que Tampermonkey ou Violentmonkey pour installer ce script.

Vous devrez installer une extension telle que Tampermonkey ou Userscripts pour installer ce script.

Vous devrez installer une extension telle que Tampermonkey pour installer ce script.

Vous devrez installer une extension de gestionnaire de script utilisateur pour installer ce script.

(J'ai déjà un gestionnaire de scripts utilisateur, laissez-moi l'installer !)

Vous devrez installer une extension telle que Stylus pour installer ce style.

Vous devrez installer une extension telle que Stylus pour installer ce style.

Vous devrez installer une extension telle que Stylus pour installer ce style.

Vous devrez installer une extension du gestionnaire de style pour utilisateur pour installer ce style.

Vous devrez installer une extension du gestionnaire de style pour utilisateur pour installer ce style.

Vous devrez installer une extension du gestionnaire de style pour utilisateur pour installer ce style.

(J'ai déjà un gestionnaire de style utilisateur, laissez-moi l'installer!)

// ==UserScript==
// @name         Multi-Redirect Buttons for Google PlayStore
// @namespace    Multi-Redirect Buttons
// @version      1.9
// @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.com/search?q=' + id, color: '#24cd77' },
            { id: 'apkcombo', text: 'ApkCombo', url: 'https://apkcombo.com/search/' + id + '/', color: '#286090' }
        ];

        // 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);
})();