Application UWP Aller au téléchargement

Insérer un lien personnalisé avant le premier élément enfant sur des pages d'application spécifiques, ouvrir la page de téléchargement

Vous devrez installer une extension telle que Tampermonkey, Greasemonkey ou Violentmonkey pour installer ce script.

Vous devrez installer une extension telle que Tampermonkey ou Violentmonkey pour installer ce script.

Vous devrez installer une extension telle que Tampermonkey ou Violentmonkey pour installer ce script.

Vous devrez installer une extension telle que Tampermonkey ou Userscripts pour installer ce script.

Vous devrez installer une extension telle que Tampermonkey pour installer ce script.

Vous devrez installer une extension de gestionnaire de script utilisateur pour installer ce script.

(J'ai déjà un gestionnaire de scripts utilisateur, laissez-moi l'installer !)

Vous devrez installer une extension telle que Stylus pour installer ce style.

Vous devrez installer une extension telle que Stylus pour installer ce style.

Vous devrez installer une extension telle que Stylus pour installer ce style.

Vous devrez installer une extension du gestionnaire de style pour utilisateur pour installer ce style.

Vous devrez installer une extension du gestionnaire de style pour utilisateur pour installer ce style.

Vous devrez installer une extension du gestionnaire de style pour utilisateur pour installer ce style.

(J'ai déjà un gestionnaire de style utilisateur, laissez-moi l'installer!)

// ==UserScript==
// @name         UWP App Jump to Download
// @description  Insert a custom link before the first child element on specific app pages, open the download page
// @name:ar          تطبيق UWP الانتقال إلى التنزيل
// @description:ar    إدراج رابط مخصص قبل العنصر الفرعي الأول في صفحات تطبيقات معينة، وفتح صفحة التنزيل
// @name:bg          UWP App Преминаване към изтегляне
// @description:bg    Вмъкване на персонализирана връзка преди първия дъщерен елемент на определени страници с приложения, отваряне на страницата за изтегляне
// @name:cs          UWP aplikace Skok ke stažení
// @description:cs    Vložení vlastního odkazu před první podřízený prvek na konkrétních stránkách aplikací, otevření stránky pro stažení
// @name:da          UWP App Hop til download
// @description:da    Indsæt et brugerdefineret link før det første underordnede element på specifikke appsider, åbn downloadsiden
// @name:de          UWP App Zum Download springen
// @description:de    Einen benutzerdefinierten Link vor dem ersten untergeordneten Element auf bestimmten App-Seiten einfügen, die Download-Seite öffnen
// @name:el          UWP App Άλμα στη λήψη
// @description:el    Εισαγωγή ενός προσαρμοσμένου συνδέσμου πριν από το πρώτο θυγατρικό στοιχείο σε συγκεκριμένες σελίδες εφαρμογών, άνοιγμα της σελίδας λήψης
// @name:eo          UWP App Saltu al Elŝuto
// @description:eo    Enmeti kutiman ligilon antaŭ la unua infana elemento en specifaj aplikaĵpaĝoj, malfermi la elŝutan paĝon
// @name:es          Aplicación UWP Saltar a la descarga
// @description:es    Insertar un enlace personalizado antes del primer elemento secundario en páginas de aplicaciones específicas, abrir la página de descarga
// @name:fi          UWP-sovellus Hyppää lataukseen
// @description:fi    Lisää mukautettu linkki ennen ensimmäistä alielementtiä tietyillä sovellussivuilla, avaa lataussivu
// @name:fr          Application UWP Aller au téléchargement
// @description:fr    Insérer un lien personnalisé avant le premier élément enfant sur des pages d'application spécifiques, ouvrir la page de téléchargement
// @name:fr-CA       Application UWP Aller au téléchargement
// @description:fr-CA    Insérer un lien personnalisé avant le premier élément enfant sur des pages d'application spécifiques, ouvrir la page de téléchargement
// @name:he          אפליקציית UWP קפיצה להורדה
// @description:he    הוספת קישור מותאם אישית לפני רכיב הצאצא הראשון בדפי אפליקציות ספציפיים, פתיחת דף ההורדה
// @name:hr          UWP aplikacija Skoči na preuzimanje
// @description:hr    Umetanje prilagođene veze prije prvog podređenog elementa na određenim stranicama aplikacije, otvaranje stranice za preuzimanje
// @name:hu          UWP App Ugrás a letöltéshez
// @description:hu    Egyéni hivatkozás beszúrása az első gyermek elem elé adott alkalmazásoldalakon, a letöltési oldal megnyitása
// @name:id          Aplikasi UWP Lompat ke Unduhan
// @description:id    Sisipkan tautan khusus sebelum elemen anak pertama di halaman aplikasi tertentu, buka halaman unduhan
// @name:it          App UWP Salta al download
// @description:it    Inserisci un collegamento personalizzato prima del primo elemento figlio nelle pagine delle app specifiche, apri la pagina di download
// @name:ja          UWPアプリのダウンロードにジャンプ
// @description:ja    特定のアプリページの最初の子要素の前にカスタムリンクを挿入し、ダウンロードページを開きます
// @name:ka          UWP აპი გადადით ჩამოტვირთვაზე
// @description:ka    მორგებული ბმულის ჩასმა პირველ შვილობილ ელემენტამდე კონკრეტულ აპლიკაციის გვერდებზე, ჩამოტვირთვის გვერდის გახსნა
// @name:ko          UWP 앱 다운로드로 이동
// @description:ko    특정 앱 페이지의 첫 번째 자식 요소 앞에 사용자 지정 링크를 삽입하고 다운로드 페이지를 엽니다.
// @name:nb          UWP App Hopp til nedlasting
// @description:nb    Sett inn en egendefinert lenke før det første underordnede elementet på spesifikke appsider, åpne nedlastingssiden
// @name:nl          UWP-app Ga naar downloaden
// @description:nl    Voeg een aangepaste link in voor het eerste onderliggende element op specifieke app-pagina's, open de downloadpagina
// @name:pl          Aplikacja UWP Przejdź do pobierania
// @description:pl    Wstaw niestandardowy link przed pierwszym elementem podrzędnym na konkretnych stronach aplikacji, otwórz stronę pobierania
// @name:pt-BR       Aplicativo UWP Ir para Download
// @description:pt-BR    Inserir um link personalizado antes do primeiro elemento filho em páginas de aplicativos específicas, abrir a página de download
// @name:ro          Aplicație UWP Salt la descărcare
// @description:ro    Inserați un link personalizat înainte de primul element copil pe paginile specifice ale aplicației, deschideți pagina de descărcare
// @name:ru          UWP App Перейти к загрузке
// @description:ru    Вставить пользовательскую ссылку перед первым дочерним элементом на определенных страницах приложений, открыть страницу загрузки
// @name:sk          UWP Aplikácia Skočiť na stiahnutie
// @description:sk    Vloženie vlastného odkazu pred prvý podradený prvok na konkrétnych stránkach aplikácií, otvorenie stránky na stiahnutie
// @name:sr          UWP апликација Скочи на преузимање
// @description:sr    Уметање прилагођене везе пре првог подређеног елемента на одређеним страницама апликација, отварање странице за преузимање
// @name:sv          UWP-app Hoppa till nedladdning
// @description:sv    Infoga en anpassad länk före det första underordnade elementet på specifika appsidor, öppna nedladdningssidan
// @name:th          แอป UWP ไปที่ดาวน์โหลด
// @description:th    แทรกลิงก์ที่กำหนดเองก่อนองค์ประกอบลูกตัวแรกในหน้าแอปเฉพาะ เปิดหน้าดาวน์โหลด
// @name:tr          UWP Uygulaması İndirmeye Git
// @description:tr    Belirli uygulama sayfalarında ilk alt öğeden önce özel bir bağlantı ekleyin, indirme sayfasını açın
// @name:ug          UWP ئەپ دېتالى چۈشۈرۈشكە سەكرەش
// @description:ug    ئەپ دېتالىنىڭ كونكرېت بېتىدىكى بىرىنچى پەرزەنت ئېلېمېنتىنىڭ ئالدىغا ئىختىيارى ئۇلىنىش قىستۇرۇڭ ، چۈشۈرۈش بېتىنى ئېچىڭ
// @name:uk          UWP App Перейти до завантаження
// @description:uk    Вставити спеціальне посилання перед першим дочірнім елементом на певних сторінках програм, відкрити сторінку завантаження
// @name:vi          Ứng dụng UWP Chuyển đến Tải xuống
// @description:vi    Chèn một liên kết tùy chỉnh trước phần tử con đầu tiên trên các trang ứng dụng cụ thể, mở trang tải xuống
// @name:zh          UWP 应用跳转到下载页面
// @description:zh    在特定应用页面的第一个子元素前插入自定义链接,打开下载页面
// @name:zh-CN       UWP 应用跳转到下载页面
// @description:zh-CN    在特定应用页面的第一个子元素前插入自定义链接,打开下载页面
// @name:zh-HK       UWP 應用跳轉到下載頁面
// @description:zh-HK    在特定應用頁面的第一個子元素前插入自定義鏈接,打開下載頁面
// @name:zh-SG       UWP 应用跳转到下载页面
// @description:zh-SG    在特定应用页面的第一个子元素前插入自定义链接,打开下载页面
// @name:zh-TW       UWP 應用跳轉到下載頁面
// @description:zh-TW    在特定應用頁面的第一個子元素前插入自定義鏈接,打開下載頁面
// @version      0.0.5.2
// @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



const openDownloadPage= () =>{
    '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();

};

(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 open Download page of this UWP App';

    // 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 = openDownloadPage;

    // 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
    let autoOpenNewTab=false;
    if(autoOpenNewTab) openNewTab();

})();