UWP App Jump to Download

Insert a custom link before the first child element on specific app pages, open the download page

当前为 2024-11-16 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name UWP App Jump to Download
  3. // @version 0.0.3
  4. // @description Insert a custom link before the first child element on specific app pages, open the download page
  5. // @author aspen138
  6. // @match *://apps.microsoft.com/detail/*
  7. // @namespace tampermonkey
  8. // @license MIT
  9. // @grant none
  10. // @grant GM_openInTab
  11. // @grant GM_getValue
  12. // @grant GM_setValue
  13. // @grant window.focus
  14. // ==/UserScript==
  15.  
  16.  
  17. // test case: https://apps.microsoft.com/detail/9nt1r1c2hh7j?hl=en-us&gl=US
  18.  
  19. (function () {
  20. 'use strict';
  21.  
  22. // Check if we're on the correct page
  23. if (!window.location.href.includes('/detail/')) return;
  24.  
  25. const appUrl = window.location.href;
  26.  
  27. // Create the banner element
  28. const banner = document.createElement('div');
  29. banner.style.cssText = `
  30. background-color: #f44336;
  31. color: white;
  32. font-size: 16px;
  33. padding: 10px;
  34. text-align: center;
  35. cursor: pointer;
  36. border-bottom: 2px solid #d32f2f;
  37. position: sticky;
  38. top: 0;
  39. z-index: 1000;
  40. `;
  41. banner.textContent = 'Click here to visit store.rg-adguard.net';
  42.  
  43. // Function to open the new page and auto-fill the input
  44. const openNewTab = () => {
  45. const newTab = window.open('https://store.rg-adguard.net/', '_blank');
  46. if (newTab) {
  47. // Inject the script into the new tab after it loads
  48. newTab.onload = () => {
  49. const inputElement = newTab.document.getElementById('url');
  50. console.log("inputElement=",inputElement);
  51. if (inputElement) {
  52. inputElement.value = appUrl; // Set the value
  53. inputElement.placeholder = appUrl; // Update the placeholder
  54. }
  55.  
  56. const button = newTab.document.querySelector('input[type="button"]');
  57. if (button) button.click();
  58. };
  59. }
  60. };
  61.  
  62. banner.onclick = openNewTab;
  63.  
  64. // Insert the banner at the top of the page
  65. const firstElement = document.body.firstChild;
  66. document.body.insertBefore(banner, firstElement);
  67.  
  68. // Automatically open the new tab on page load
  69. openNewTab();
  70.  
  71. })();
  72.  
  73.  
  74. (function () {
  75. 'use strict';
  76.  
  77. // Check if we're on the correct page
  78. if (!window.location.href.includes('/detail/')) return;
  79.  
  80. const appUrl = window.location.href;
  81.  
  82. // Function to submit form to store.rg-adguard.net
  83. const submitForm = () => {
  84. const form = document.createElement('form');
  85. form.method = 'POST';
  86. form.action = 'https://store.rg-adguard.net/api/GetFiles';
  87. form.target = '_blank';
  88.  
  89. // Create input elements
  90. const inputs = [
  91. { name: 'type', value: 'url' },
  92. { name: 'url', value: appUrl },
  93. { name: 'ring', value: 'Retail' },
  94. { name: 'lang', value: 'en-US' },
  95. ];
  96.  
  97. inputs.forEach(({ name, value }) => {
  98. const input = document.createElement('input');
  99. input.type = 'hidden';
  100. input.name = name;
  101. input.value = value;
  102. form.appendChild(input);
  103. });
  104.  
  105. document.body.appendChild(form);
  106. form.submit();
  107. document.body.removeChild(form);
  108. };
  109.  
  110. // Automatically submit the form on page load
  111. submitForm();
  112.  
  113. })();
  114.  
  115.  
  116.  

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址