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.1
  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 + '/' },
  24. { id: 'a2z-download', text: 'A2zapk Download', url: 'https://a2zapk.io/apk/' + id + '.html' },
  25. { id: 'apkmirror', text: 'Apkmirror', url: 'https://www.apkmirror.com/?post_type=app_release&searchtype=apk&s=' + id },
  26. { id: 'apkpure', text: 'APKpure', url: 'https://apkpure.com/search?q=' + id },
  27. { id: 'apkcombo', text: 'ApkCombo', url: 'https://apkcombo.com/search/' + id + '/' }
  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. // Add button styles
  36. GM_addStyle(`
  37. #${config.id} {
  38. color: #fff;
  39. background-color: #01875f;
  40. width: unset;
  41. font-family: "GoogleSans", Roboto, Arial, sans-serif;
  42. line-height: 1.25rem;
  43. font-size: .920rem;
  44. letter-spacing: .0178571429em;
  45. font-weight: 500;
  46. height: 36px;
  47. margin: 6px 0;
  48. cursor: pointer;
  49. margin-bottom: 2px;
  50. margin-top: 4px;
  51. min-height: 40px;
  52. min-width: 120px;
  53. padding: 0 16px;
  54. border-radius: 8px;
  55. display: inline-flex;
  56. align-items: center;
  57. justify-content: center;
  58. box-sizing: border-box;
  59. }
  60. #${config.id}:hover {
  61. background-color: #056449;
  62. }
  63. `);
  64.  
  65. // Append the button to a specific position
  66. var parentElement = document.querySelector('[data-item-id^="%.@."]');
  67. if (parentElement) {
  68. parentElement.appendChild(button);
  69. }
  70.  
  71. // Add click event to redirect to the configured URL
  72. button.addEventListener('click', function() {
  73. window.location.href = config.url;
  74. });
  75. });
  76. }
  77.  
  78. // Check if the current URL is an app details page and add buttons
  79. if (window.location.href.indexOf("https://play.google.com/store/apps/details") > -1) {
  80. addButtons();
  81. }
  82.  
  83. // Monitor for URL changes to re-add the buttons if needed
  84. let currentPage = location.href;
  85. setInterval(function() {
  86. if (currentPage !== location.href) {
  87. if (window.location.href.indexOf("https://play.google.com/store/apps/details") > -1) {
  88. currentPage = location.href;
  89. setTimeout(addButtons, 500);
  90. }
  91. currentPage = location.href;
  92. }
  93. }, 500);
  94. })();