Multi-Redirect Buttons for Google PlayStore

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

  1. // ==UserScript==
  2. // @name Multi-Redirect Buttons for Google PlayStore
  3. // @namespace Multi-Redirect Buttons
  4. // @version 2.3
  5. // @description Adds multiple buttons to redirect from Google PlayStore to different websites (A2Zapk, APKMirror, APKPure, ApkCombo).
  6. // @match https://play.google.com/store/apps/details?id=*
  7. // @icon https://www.google.com/s2/favicons?sz=64&domain=a2zapk.com
  8. // @grant GM_addStyle
  9. // ==/UserScript==
  10.  
  11. (function() {
  12. 'use strict';
  13.  
  14. // Function to create and insert the buttons
  15. function addButtons() {
  16. // Extract the package name from the URL
  17. var idMatch = location.href.match(/id=([a-zA-Z0-9._]+)/);
  18. if (!idMatch) return; // If no match found, exit the function
  19. var id = idMatch[1];
  20.  
  21. // Define the button configurations
  22. const buttonsConfig = [
  23. { id: 'a2z-history', text: 'A2zapk History', url: 'https://a2zapk.io/History/' + id + '/', color: '#00875f' },
  24. { id: 'a2z-download', text: 'A2zapk Download', url: 'https://a2zapk.io/apk/' + id + '.html', color: '#00875f' },
  25. { id: 'apkmirror', text: 'Apkmirror', url: 'https://www.apkmirror.com/?post_type=app_release&searchtype=apk&s=' + id, color: '#FF8B14' },
  26. { id: 'apkpure', text: 'APKpure', url: 'https://apkpure.net/search?q=' + id, color: '#24cd77' },
  27. { id: 'apkcombo', text: 'ApkCombo', url: 'https://apkcombo.net/search?q=' + id, color: '#286090' } // Updated URL
  28. ];
  29.  
  30. // Parent container styling to ensure buttons fit
  31. GM_addStyle(`
  32. .button-container {
  33. display: flex;
  34. flex-wrap: wrap;
  35. gap: 4px; /* Adjust gap to control spacing */
  36. justify-content: flex-start;
  37. }
  38. `);
  39.  
  40. let parentElement = document.querySelector('[data-item-id^="%.@."]');
  41. if (parentElement) {
  42. // Create a container for the buttons
  43. let buttonContainer = document.createElement('div');
  44. buttonContainer.className = 'button-container';
  45.  
  46. // Append the container to the parent element
  47. parentElement.appendChild(buttonContainer);
  48.  
  49. // Append each button to the button container
  50. buttonsConfig.forEach(config => {
  51. // Create button element
  52. let button = document.createElement('button');
  53. button.id = config.id;
  54. button.innerHTML = config.text;
  55.  
  56. // Add button styles
  57. GM_addStyle(`
  58. #${config.id} {
  59. color: #fff;
  60. background-color: ${config.color};
  61. font-family: "GoogleSans", Roboto, Arial, sans-serif;
  62. line-height: 1.25rem;
  63. font-size: .920rem;
  64. letter-spacing: .0178571429em;
  65. font-weight: 500;
  66. height: 36px;
  67. margin: 0; /* Remove margin, handled by container gap */
  68. cursor: pointer;
  69. padding: 0 12px; /* Reduced padding to fit more buttons */
  70. border-radius: 8px; /* Adjusted border-radius for consistent look */
  71. display: inline-flex;
  72. align-items: center;
  73. justify-content: center;
  74. box-sizing: border-box;
  75. transition: transform 0.2s, filter 0.2s;
  76. }
  77. #${config.id}:hover {
  78. filter: brightness(0.85);
  79. transform: translateY(-2px);
  80. }
  81. `);
  82.  
  83. // Append the button to the container
  84. buttonContainer.appendChild(button);
  85.  
  86. // Add click event to redirect to the configured URL
  87. button.addEventListener('click', function() {
  88. window.location.href = config.url;
  89. });
  90. });
  91. }
  92. }
  93.  
  94. // Check if the current URL is an app details page and add buttons
  95. if (window.location.href.indexOf("https://play.google.com/store/apps/details") > -1) {
  96. addButtons();
  97. }
  98.  
  99. // Monitor for URL changes to re-add the buttons if needed
  100. let currentPage = location.href;
  101. setInterval(function() {
  102. if (currentPage !== location.href) {
  103. if (window.location.href.indexOf("https://play.google.com/store/apps/details") > -1) {
  104. currentPage = location.href;
  105. setTimeout(addButtons, 500);
  106. }
  107. currentPage = location.href;
  108. }
  109. }, 500);
  110. })();