Adds multiple buttons to redirect from Google PlayStore to different websites (A2Zapk, APKMirror, APKpure, ApkCombo).
当前为
// ==UserScript==
// @name Multi-Redirect Buttons for Google PlayStore
// @namespace Multi-Redirect Buttons
// @version 1.8
// @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' }
];
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};
width: auto;
font-family: "GoogleSans", Roboto, Arial, sans-serif;
line-height: 1.25rem;
font-size: .920rem;
letter-spacing: .0178571429em;
font-weight: 500;
height: 36px;
margin: 4px; /* Adjusted margin to reduce wasted space */
cursor: pointer;
min-height: 36px;
min-width: 100px; /* Reduced min-width to fit more buttons */
padding: 0 12px; /* Reduced padding to fit more buttons in one line */
border-radius: 8px; /* Adjusted border-radius for consistent look */
display: inline-block; /* Ensure buttons are inline */
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 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);
})();