Multi-Redirect Buttons for Google PlayStore

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

当前为 2024-05-27 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Multi-Redirect Buttons for Google PlayStore
  3. // @namespace Multi-Redirect Buttons
  4. // @version 1.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.com/search?q=' + id, color: '#24cd77' },
  27. { id: 'apkcombo', text: 'ApkCombo', url: 'https://apkcombo.com/search/' + id + '/', color: '#286090' }
  28. ];
  29.  
  30. buttonsConfig.forEach(config => {
  31. // Create button element
  32. let button = document.createElement('button');
  33. button.id = config.id;
  34. button.innerHTML = config.text;
  35.  
  36. // Add button styles
  37. GM_addStyle(`
  38. #${config.id} {
  39. color: #fff;
  40. background-color: ${config.color};
  41. width: unset;
  42. font-family: "GoogleSans", Roboto, Arial, sans-serif;
  43. line-height: 1.25rem;
  44. font-size: .920rem;
  45. letter-spacing: .0178571429em;
  46. font-weight: 500;
  47. height: 36px;
  48. margin: 6px 8px; /* Added margin to space out buttons */
  49. cursor: pointer;
  50. margin-bottom: 2px;
  51. margin-top: 4px;
  52. min-height: 40px;
  53. min-width: 120px;
  54. padding: 0 16px;
  55. border-radius: 12px; /* Increased border-radius for curvy corners */
  56. display: inline-flex;
  57. align-items: center;
  58. justify-content: center;
  59. box-sizing: border-box;
  60. transition: transform 0.2s, filter 0.2s;
  61. }
  62. #${config.id}:hover {
  63. filter: brightness(0.85);
  64. transform: translateY(-2px);
  65. }
  66. `);
  67.  
  68. // Append the button to a specific position
  69. var parentElement = document.querySelector('[data-item-id^="%.@."]');
  70. if (parentElement) {
  71. parentElement.appendChild(button);
  72. }
  73.  
  74. // Add click event to redirect to the configured URL
  75. button.addEventListener('click', function() {
  76. window.location.href = config.url;
  77. });
  78. });
  79. }
  80.  
  81. // Check if the current URL is an app details page and add buttons
  82. if (window.location.href.indexOf("https://play.google.com/store/apps/details") > -1) {
  83. addButtons();
  84. }
  85.  
  86. // Monitor for URL changes to re-add the buttons if needed
  87. let currentPage = location.href;
  88. setInterval(function() {
  89. if (currentPage !== location.href) {
  90. if (window.location.href.indexOf("https://play.google.com/store/apps/details") > -1) {
  91. currentPage = location.href;
  92. setTimeout(addButtons, 500);
  93. }
  94. currentPage = location.href;
  95. }
  96. }, 500);
  97. })();