Multi-Redirect Buttons for Google PlayStore

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

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

  1. // ==UserScript==
  2. // @name Multi-Redirect Buttons for Google PlayStore
  3. // @namespace Multi-Redirect Buttons
  4. // @version 1.6
  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: auto;
  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: 2px 4px; /* Adjusted margin to reduce wasted space */
  49. cursor: pointer;
  50. min-height: 36px;
  51. min-width: 110px;
  52. padding: 0 12px; /* Reduced padding to fit more buttons in one line */
  53. border-radius: 8px; /* Adjusted border-radius for consistent look */
  54. display: inline-block; /* Ensure buttons are inline */
  55. align-items: center;
  56. justify-content: center;
  57. box-sizing: border-box;
  58. transition: transform 0.2s, filter 0.2s;
  59. }
  60. #${config.id}:hover {
  61. filter: brightness(0.85);
  62. transform: translateY(-2px);
  63. }
  64. `);
  65.  
  66. // Append the button to a specific position
  67. var parentElement = document.querySelector('[data-item-id^="%.@."]');
  68. if (parentElement) {
  69. parentElement.appendChild(button);
  70. }
  71.  
  72. // Add click event to redirect to the configured URL
  73. button.addEventListener('click', function() {
  74. window.location.href = config.url;
  75. });
  76. });
  77. }
  78.  
  79. // Check if the current URL is an app details page and add buttons
  80. if (window.location.href.indexOf("https://play.google.com/store/apps/details") > -1) {
  81. addButtons();
  82. }
  83.  
  84. // Monitor for URL changes to re-add the buttons if needed
  85. let currentPage = location.href;
  86. setInterval(function() {
  87. if (currentPage !== location.href) {
  88. if (window.location.href.indexOf("https://play.google.com/store/apps/details") > -1) {
  89. currentPage = location.href;
  90. setTimeout(addButtons, 500);
  91. }
  92. currentPage = location.href;
  93. }
  94. }, 500);
  95. })();