Greasy Fork is available in English.
将微软商店的应用链接粘贴到store.rg-adguard.net,并自动解析下载地址。Paste the Microsoft Store app link into store.rg-adguard.net to automatically resolve the download URL.
// ==UserScript==
// @name MS Store Helper
// @namespace http://tampermonkey.net/
// @description 将微软商店的应用链接粘贴到store.rg-adguard.net,并自动解析下载地址。Paste the Microsoft Store app link into store.rg-adguard.net to automatically resolve the download URL.
// @license MIT
// @version 1.0
// @match https://apps.microsoft.com/*
// @match https://store.rg-adguard.net/*
// @grant GM_setValue
// @grant GM_getValue
// @grant GM_deleteValue
// ==/UserScript==
(function () {
'use strict';
// =========================
// 1️⃣ Microsoft Store 页面
// =========================
if (location.host.includes("apps.microsoft.com")) {
function getProductId() {
// 从路径中提取 /detail/ 后面的部分,例如 /detail/9NBLGGH4NNS1?hl=...
const match = location.pathname.match(/\/detail\/([^/?]+)/);
return match ? match[1] : null;
}
function addBtn() {
var btn = document.createElement("button");
btn.innerText = "获取 MSIX 下载地址";
btn.style.cssText = `
position: fixed; top: 100px; right: 20px; z-index: 9999;
padding: 10px 15px; background: #0078d7; color: white;
border: none; border-radius: 6px; cursor: pointer;
font-size: 14px; box-shadow: 0 2px 5px rgba(0,0,0,0.2);
`;
btn.onclick = () => {
var pid = getProductId();
if (!pid) {
alert("未找到 ProductId");
return;
}
GM_setValue("rg_pid", pid);
window.open("https://store.rg-adguard.net/", "_blank");
};
document.body.appendChild(btn);
}
window.addEventListener("load", addBtn);
}
// =========================
// 2️⃣ RG-Adguard 页面
// =========================
if (location.host.includes("store.rg-adguard.net")) {
function autoSubmit() {
var pid = GM_getValue("rg_pid", null);
if (!pid) return;
var timer = setInterval(() => {
var type = document.querySelector("#type");
var url = document.querySelector("#url");
var ring = document.querySelector("#ring");
var btn = document.querySelector("input[type=button]");
if (type && url && ring && btn) {
clearInterval(timer);
url.value = "https://www.microsoft.com/store/productId/" + pid;
type.value = "url";
ring.value = "Retail";
GM_deleteValue("rg_pid");
// 🔥 自动点击生成
btn.click();
}
}, 300);
}
window.addEventListener("load", autoSubmit);
}
})();