// ==UserScript== // @name 应用宝自动跳转下载 // @namespace https://a.app.qq.com/ // @version 2.0 // @description 访问应用宝详情页时自动提取包名,跳转到 simple.jsp 一键下载 // @author Marvis // @match https://sj.qq.com/appdetail/* // @match https://a.app.qq.com/o/simple.jsp?* // @match https://android.myapp.com/* // @match https://android.myapp.com/myapp/* // @match https://sj.qq.com/myapp/* // @match https://sj.qq.com/myapp/detail.htm* // @run-at document-start // @grant none // ==/UserScript== (function () { "use strict"; const url = location.href; // 已在目标页面,不处理 if (url.startsWith("https://a.app.qq.com/o/simple.jsp?")) return; // 包名正则:com.xxx.xxx 或 xx.xxx.xxx 格式 const PKG_RE = /^([a-zA-Z][a-zA-Z0-9_]*(?:\.[a-zA-Z][a-zA-Z0-9_]*){1,})$/; let pkgname = null; // ① /appdetail/<包名>(最常见) const m1 = url.match(/\/appdetail\/([a-zA-Z][a-zA-Z0-9_.]+)/); if (m1 && PKG_RE.test(m1[1])) pkgname = m1[1]; // ② pkgname=xxx 参数 if (!pkgname) { const m2 = url.match(/[?&]pkgname=([a-zA-Z][a-zA-Z0-9_.]+)/); if (m2 && PKG_RE.test(m2[1])) pkgname = m2[1]; } // ③ detail.htm?apkName=xxx if (!pkgname) { const m3 = url.match(/[?&]apkName=([a-zA-Z][a-zA-Z0-9_.]+)/); if (m3 && PKG_RE.test(m3[1])) pkgname = m3[1]; } if (!pkgname) return; location.replace("https://a.app.qq.com/o/simple.jsp?pkgname=" + pkgname); })();