UWP App Jump to Download

Insert a custom link before the first child element on specific app pages, fill in the URL, and auto-click the button

目前为 2024-11-15 提交的版本。查看 最新版本

  1. // ==UserScript==
  2. // @name UWP App Jump to Download
  3. // @version 0.0.1
  4. // @description Insert a custom link before the first child element on specific app pages, fill in the URL, and auto-click the button
  5. // @author aspen138
  6. // @match *://apps.microsoft.com/detail/*
  7. // @namespace tampermonkey
  8. // @license MIT
  9. // @grant none
  10. // ==/UserScript==
  11.  
  12. (function() {
  13. 'use strict';
  14.  
  15. // Wait until the DOM is fully loaded
  16. window.addEventListener('load', function() {
  17. // The link you want to insert
  18. const linkURL = 'https://store.rg-adguard.net/';
  19.  
  20. // Find the first child element of the body or any desired element
  21. const firstChild = document.body.firstElementChild;
  22.  
  23. if (firstChild) {
  24. // Create a new div to serve as the banner
  25. const banner = document.createElement('div');
  26. banner.style.display = 'flex';
  27. banner.style.justifyContent = 'center';
  28. banner.style.alignItems = 'center';
  29. banner.style.height = '100px'; // Adjust the height as needed
  30. banner.style.backgroundColor = '#FF0000'; // Red background for visibility
  31. banner.style.color = '#FFFFFF'; // White text for contrast
  32. banner.style.margin = '10px 0'; // Margin for spacing
  33. banner.style.borderRadius = '5px'; // Rounded corners for the link
  34. banner.style.textDecoration = 'none'; // Remove underline
  35. banner.style.boxSizing = 'border-box'; // Ensure padding and border are included in the element’s total width/height
  36.  
  37. // Create a new anchor tag element
  38. const newLink = document.createElement('a');
  39. newLink.href = linkURL;
  40. newLink.textContent = 'Click here to download app from store.rg-adguard.net';
  41. newLink.target = '_blank';
  42. newLink.style.textAlign = 'center'; // Centers the text
  43. newLink.style.fontSize = '20px'; // Larger font for readability
  44. newLink.style.fontWeight = 'bold'; // Bold text
  45. newLink.style.width = '100%'; // Ensures the link spans the full width of the container
  46. newLink.style.height = '100%'; // Ensures the link spans the full height of the container
  47. newLink.style.display = 'block'; // Makes the link a block-level element (takes full width)
  48.  
  49. // Append the link to the banner
  50. banner.appendChild(newLink);
  51.  
  52. // Insert the new banner before the first child element
  53. document.body.insertBefore(banner, firstChild);
  54. }
  55.  
  56. // Find the input field by its ID and the button to click
  57. const urlInput = document.getElementById('url');
  58. const generateButton = document.querySelector('input[type="button"][value="✔"]');
  59.  
  60. // Check if the elements exist before interacting with them
  61. if (urlInput && generateButton) {
  62. // Fill in the URL input with the current page's URL
  63. urlInput.value = window.location.href;
  64.  
  65. // Simulate a click on the button to generate temporary links
  66. generateButton.click();
  67. }
  68. });
  69. })();