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 提交的版本,檢視 最新版本

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         UWP App Jump to Download
// @version      0.0.1
// @description  Insert a custom link before the first child element on specific app pages, fill in the URL, and auto-click the button
// @author       aspen138
// @match        *://apps.microsoft.com/detail/*
// @namespace    tampermonkey
// @license      MIT
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    // Wait until the DOM is fully loaded
    window.addEventListener('load', function() {
        // The link you want to insert
        const linkURL = 'https://store.rg-adguard.net/';

        // Find the first child element of the body or any desired element
        const firstChild = document.body.firstElementChild;

        if (firstChild) {
            // Create a new div to serve as the banner
            const banner = document.createElement('div');
            banner.style.display = 'flex';
            banner.style.justifyContent = 'center';
            banner.style.alignItems = 'center';
            banner.style.height = '100px'; // Adjust the height as needed
            banner.style.backgroundColor = '#FF0000'; // Red background for visibility
            banner.style.color = '#FFFFFF'; // White text for contrast
            banner.style.margin = '10px 0'; // Margin for spacing
            banner.style.borderRadius = '5px'; // Rounded corners for the link
            banner.style.textDecoration = 'none'; // Remove underline
            banner.style.boxSizing = 'border-box'; // Ensure padding and border are included in the element’s total width/height

            // Create a new anchor tag element
            const newLink = document.createElement('a');
            newLink.href = linkURL;
            newLink.textContent = 'Click here to download app from store.rg-adguard.net';
            newLink.target = '_blank';
            newLink.style.textAlign = 'center'; // Centers the text
            newLink.style.fontSize = '20px'; // Larger font for readability
            newLink.style.fontWeight = 'bold'; // Bold text
            newLink.style.width = '100%'; // Ensures the link spans the full width of the container
            newLink.style.height = '100%'; // Ensures the link spans the full height of the container
            newLink.style.display = 'block'; // Makes the link a block-level element (takes full width)

            // Append the link to the banner
            banner.appendChild(newLink);

            // Insert the new banner before the first child element
            document.body.insertBefore(banner, firstChild);
        }

        // Find the input field by its ID and the button to click
        const urlInput = document.getElementById('url');
        const generateButton = document.querySelector('input[type="button"][value="✔"]');

        // Check if the elements exist before interacting with them
        if (urlInput && generateButton) {
            // Fill in the URL input with the current page's URL
            urlInput.value = window.location.href;

            // Simulate a click on the button to generate temporary links
            generateButton.click();
        }
    });
})();