Greasy Fork 还支持 简体中文。

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

您需要先安裝使用者腳本管理器擴展,如 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.3
// @description  Insert a custom link before the first child element on specific app pages, open the download page
// @author       aspen138
// @match        *://apps.microsoft.com/detail/*
// @namespace    tampermonkey
// @license      MIT
// @grant        none
// @grant        GM_openInTab
// @grant        GM_getValue
// @grant        GM_setValue
// @grant        window.focus
// ==/UserScript==


// test case: https://apps.microsoft.com/detail/9nt1r1c2hh7j?hl=en-us&gl=US

(function () {
    'use strict';

    // Check if we're on the correct page
    if (!window.location.href.includes('/detail/')) return;

    const appUrl = window.location.href;

    // Create the banner element
    const banner = document.createElement('div');
    banner.style.cssText = `
        background-color: #f44336;
        color: white;
        font-size: 16px;
        padding: 10px;
        text-align: center;
        cursor: pointer;
        border-bottom: 2px solid #d32f2f;
        position: sticky;
        top: 0;
        z-index: 1000;
    `;
    banner.textContent = 'Click here to visit store.rg-adguard.net';

    // Function to open the new page and auto-fill the input
    const openNewTab = () => {
        const newTab = window.open('https://store.rg-adguard.net/', '_blank');
        if (newTab) {
            // Inject the script into the new tab after it loads
            newTab.onload = () => {
                const inputElement = newTab.document.getElementById('url');
                console.log("inputElement=",inputElement);
                if (inputElement) {
                    inputElement.value = appUrl; // Set the value
                    inputElement.placeholder = appUrl; // Update the placeholder
                }

                const button = newTab.document.querySelector('input[type="button"]');
                if (button) button.click();
            };
        }
    };

    banner.onclick = openNewTab;

    // Insert the banner at the top of the page
    const firstElement = document.body.firstChild;
    document.body.insertBefore(banner, firstElement);

    // Automatically open the new tab on page load
    openNewTab();

})();


(function () {
    'use strict';

    // Check if we're on the correct page
    if (!window.location.href.includes('/detail/')) return;

    const appUrl = window.location.href;

    // Function to submit form to store.rg-adguard.net
    const submitForm = () => {
        const form = document.createElement('form');
        form.method = 'POST';
        form.action = 'https://store.rg-adguard.net/api/GetFiles';
        form.target = '_blank';

        // Create input elements
        const inputs = [
            { name: 'type', value: 'url' },
            { name: 'url', value: appUrl },
            { name: 'ring', value: 'Retail' },
            { name: 'lang', value: 'en-US' },
        ];

        inputs.forEach(({ name, value }) => {
            const input = document.createElement('input');
            input.type = 'hidden';
            input.name = name;
            input.value = value;
            form.appendChild(input);
        });

        document.body.appendChild(form);
        form.submit();
        document.body.removeChild(form);
    };

    // Automatically submit the form on page load
    submitForm();

})();