Multi-Redirect Buttons for Google PlayStore

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

目前为 2024-05-27 提交的版本。查看 最新版本

// ==UserScript==
// @name         Multi-Redirect Buttons for Google PlayStore
// @namespace    Multi-Redirect Buttons
// @version      1.1
// @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 + '/' },
            { id: 'a2z-download', text: 'A2zapk Download', url: 'https://a2zapk.io/apk/' + id + '.html' },
            { id: 'apkmirror', text: 'Apkmirror', url: 'https://www.apkmirror.com/?post_type=app_release&searchtype=apk&s=' + id },
            { id: 'apkpure', text: 'APKpure', url: 'https://apkpure.com/search?q=' + id },
            { id: 'apkcombo', text: 'ApkCombo', url: 'https://apkcombo.com/search/' + id + '/' }
        ];

        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: #01875f;
                    width: unset;
                    font-family: "GoogleSans", Roboto, Arial, sans-serif;
                    line-height: 1.25rem;
                    font-size: .920rem;
                    letter-spacing: .0178571429em;
                    font-weight: 500;
                    height: 36px;
                    margin: 6px 0;
                    cursor: pointer;
                    margin-bottom: 2px;
                    margin-top: 4px;
                    min-height: 40px;
                    min-width: 120px;
                    padding: 0 16px;
                    border-radius: 8px;
                    display: inline-flex;
                    align-items: center;
                    justify-content: center;
                    box-sizing: border-box;
                }
                #${config.id}:hover {
                    background-color: #056449;
                }
            `);

            // Append the button to a specific position
            var parentElement = document.querySelector('[data-item-id^="%.@."]');
            if (parentElement) {
                parentElement.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);
})();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址