Microsoft Store Direct Download

Adds direct download links to Microsoft Store when browsing apps.

Από την 12/01/2022. Δείτε την τελευταία έκδοση.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey, το Greasemonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

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

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Userscripts για να εγκαταστήσετε αυτόν τον κώδικα.

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

Θα χρειαστεί να εγκαταστήσετε μια επέκταση διαχείρισης κώδικα χρήστη για να εγκαταστήσετε αυτόν τον κώδικα.

(Έχω ήδη έναν διαχειριστή κώδικα χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(Έχω ήδη έναν διαχειριστή στυλ χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

// ==UserScript==
// @name     Microsoft Store Direct Download
// @name:it     Download diretto dal Microsoft Store
// @namespace    StephenP
// @version  1.1.0
// @description  Adds direct download links to Microsoft Store when browsing apps.
// @description:it  Aggiunge i link per il download diretto dal Microsoft Store quando si naviga tra le applicazioni.
// @author       StephenP
// @grant    GM.xmlHttpRequest
// @connect	 rg-adguard.net
// @match    https://www.microsoft.com/*-*/p/*
// ==/UserScript==
var dlBtn;
(function(){
  setInterval(checkReload, 1000);
})();
function checkReload(){
  var moreBtn=document.getElementById("buttonPanel_AppIdentityBuyButton");
  if((moreBtn)&&(!dlBtn)){
    dlBtn = moreBtn.cloneNode(true);
    dlBtn.removeAttribute("aria-haspopup");
    dlBtn.removeAttribute("aria-expanded");
    dlBtn.removeAttribute("data-m");
    dlBtn.setAttribute("aria-label","Download from AdGuard Store");
    dlBtn.setAttribute("class","c-button");
    dlBtn.style.background="#00a686";
    dlBtn.style.color="#ffffff";
    dlBtn.style.minWidth="0";
    dlBtn.style.font="initial";
    dlBtn.innerText="\u25bc";
    dlBtn.addEventListener("click",function(){openLink(document.location.href,"url")});
    moreBtn.parentNode.appendChild(dlBtn);
  }
}
function openLink(id,type){
  try{
    var loading=setInterval(rotateCursor,100);
    var link="type="+type+"&url="+id+"&ring=RP&lang=it-IT";
    GM.xmlHttpRequest({
      method: "POST",
      url: "https://store.rg-adguard.net/api/GetFiles",
      data: link,
      headers: {
        "Content-Type": "application/x-www-form-urlencoded"
      },
      onload: function(response) {
        clearInterval(loading);
        dlBtn.innerText="\u25bc";
        try{
          var oldTable=document.getElementById("linkTable");
          oldTable.parentNode.removeChild(oldTable);
          var oldMsg=document.getElementById("messageFromServer");
          oldMsg.parentNode.removeChild(oldMsg);
        }
        catch(err){
          console.log(err);
        }
        output(response,type);
        if(type==="ProductId"){
          output(err,type);
        }
        else{
          let newId=document.querySelector('[name="ms.prod_id"]').getAttribute("content").toLowerCase();
          openLink(newId,"ProductId");
        }
      }
    });
  }
  catch(err){
    console.log(err);
    if(type==="ProductId"){
      output(err,type);
    }
    else{
      let newId=document.querySelector('[name="ms.prod_id"]').getAttribute("content").toLowerCase();
      openLink(newId,"ProductId");
    }
  }

}
function output(response,type){
  var linkTable = document.createElement("div");
  linkTable.innerHTML=response.responseText;
  var justTable=linkTable.getElementsByTagName("TABLE")[0];
  var messageFromServer=linkTable.getElementsByTagName("P")[0];
  messageFromServer.id="messageFromServer";
  messageFromServer.style.fontWeight="bold";
  if(justTable!==undefined){
    justTable.id="linkTable";
    document.getElementsByClassName("pi-content")[0].appendChild(justTable);
    messageFromServer.style.color="green";
    document.getElementById("purchaseColumn").appendChild(messageFromServer);
  }
  else if((justTable===undefined)&&(type==="url")){
    let newId=document.querySelector('[name="ms.prod_id"]').getAttribute("content").toLowerCase();
    openLink(newId,"ProductId");
  }
  else{
    messageFromServer.style.color="red";
    document.getElementById("purchaseColumn").appendChild(messageFromServer);
  }
}
function rotateCursor(){
  if(dlBtn.innerText=="\u25bc"){
    dlBtn.innerText="\u25d0";
  }
  if(dlBtn.innerText=="\u25d0"){
    dlBtn.innerText="\u25d3";
  }
  else if(dlBtn.innerText=="\u25d3"){
    dlBtn.innerText="\u25d1";
  }
  else if(dlBtn.innerText=="\u25d1"){
    dlBtn.innerText="\u25d2";
  }
  else if(dlBtn.innerText=="\u25d2"){
    dlBtn.innerText="\u25d0";
  }
}